Skip to main content

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

FeatureDescription
Configurable TTLDefine the time-to-live of each variable in seconds
Multiple typesSupports primitives, JSON, and files
File storageStore images, videos, audio, and documents up to 10 MB
Specific methodsDifferentiated API for each data type

Data types

TypeMax sizeTTLMax TTL
String255 charactersOptional-
Number15 digitsOptional-
Boolean-Optional-
JSON5 KBRequired86,400 s (1 day)
File10 MBRequired604,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:
MethodDescriptionAsync
.toUrl()Temporary URL for download (S3)No
.toBase64()Content as a base-64 stringYes
.toRaw()Buffer / Uint8ArrayYes
// 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

CategoryMIME types
Texttext/plain
JSONapplication/json
XMLapplication/xml, text/xml
Imagesimage/jpeg, image/png, image/gif
Videosvideo/mp4, video/ogg, video/webm, video/x-msvideo, video/mpeg
Audioaudio/mpeg, audio/wav, audio/ogg, audio/aac, audio/flac
Documentsapplication/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.