Introduction
Memory lets you store variables that persist between conversations, skills, and nodes. Unlike Context (which is only available during the current conversation), Memory keeps data available for future interactions with the user.
Key features
| Feature | Description |
|---|
| Configurable TTL | Define the time-to-live of each variable in seconds |
| Multiple types | Supports primitives, JSON, and files |
| File storage | Store images, videos, audio, and documents up to 10 MB |
| Specific methods | Differentiated API for each data type |
Data types
| Type | Max size | TTL | Max TTL |
|---|
| String | 255 characters | Optional | - |
| Number | 15 digits | Optional | - |
| Boolean | - | Optional | - |
| JSON | 5 KB | Required | 86,400 s (1 day) |
| File | 10 MB | Required | 604,800 s (1 week) |
TTL (Time To Live): Lifetime in seconds. Once the TTL elapses, the variable is automatically deleted. For example, 3600 = 1 hour, 86400 = 1 day.
Saving variables
Using the Variable node
To save variables without code, use the Variable node inside the Logic section. In Variable enter the name and in Value what you want to save; it can be plain text, another variable, or a context value.
Variable: name
Value: {{$user.names}}
The Variable node is ideal for saving primitives (string, number, boolean) quickly and visually.
Each Variable node allows a maximum of 20 variables. If you need more, use multiple nodes or save the values from a code node.
Using code nodes
For greater control over TTL and complex data types, use the $memory methods in code nodes:
// Primitives (string, number, boolean) - TTL optional
$memory.set('name', 'John')
$memory.set('attempts', 3)
$memory.set('verified', true)
// Primitive with TTL (expires in 1 hour)
$memory.set('temporaryCode', 'ABC123', 3600)
// JSON - TTL required (maximum 1 day)
$memory.setJson('preferences', {
language: 'en',
notifications: true
}, 86400)
// File - async, TTL required, MIME required (maximum 1 week)
await $memory.setFile('receipt', base64String, 604800, 'application/pdf')
Reading variables
In any node
Inside any node you can access Memory with the syntax {{$memory.variableName}}. For example, if the variables in memory are:
{
"name": "John",
"lastOrder": { "id": "ORD-123", "status": "on the way" }
}
Then:
{{$memory.name}} shows John
{{$memory.lastOrder.status}} shows on the way
In code nodes
Use the specific methods according to the data type:
// Primitives
const name = $memory.get('name')
const name = $memory.get('name', 'Guest') // with default value
// JSON
const prefs = $memory.getJson('preferences')
const prefs = $memory.getJson('preferences', {}) // with default value
// Files - returns FileHandle
const file = $memory.getFile('receipt')
Working with files
When saving a file in Memory, you must provide the content in base64, the TTL, and the MIME type:
// Save a file
await $memory.setFile('document', base64Content, 604800, 'application/pdf')
When reading a file with $memory.getFile() you get a FileHandle with three methods to access the content:
| Method | Description | Async |
|---|
.toUrl() | Temporary URL for download (S3) | No |
.toBase64() | Content as a base-64 string | Yes |
.toRaw() | Buffer / Uint8Array | Yes |
// Get temporary URL
const url = $memory.getFile('receipt').toUrl()
// Get content in base64
const base64 = await $memory.getFile('receipt').toBase64()
// Get file content
const content = await $memory.getFile('receipt').toRaw()
Allowed MIME types
| Category | MIME types |
|---|
| Text | text/plain |
| JSON | application/json |
| XML | application/xml, text/xml |
| Images | image/jpeg, image/png, image/gif |
| Videos | video/mp4, video/ogg, video/webm, video/x-msvideo, video/mpeg |
| Audio | audio/mpeg, audio/wav, audio/ogg, audio/aac, audio/flac |
| Documents | application/pdf |
The methods $memory.setFile(), $memory.getFile().toBase64(), and $memory.getFile().toRaw() are asynchronous. You must use await when calling them.
Deleting variables
You can delete variables before their TTL expires:
// Delete a variable
$memory.delete('temporary')
// Delete multiple variables
$memory.delete(['cache', 'session', 'temporary'])
Security
Do not store sensitive data in Memory:
- Passwords or credit card numbers
- Long-lived authentication tokens
- Highly sensitive personally identifiable information (PII)
For long-term persistence, use Datum.