Skip to main content
Choosing between $memory and $context comes down to one simple question: do you need this data after the conversation ends?

Use $context when

Use $context when the data is only needed during the current conversation. Use cases:
  • Checking product availability: The user asks about a product, you query your inventory and save the available stock in $context.stock to display it and validate the quantity they want to buy in the following nodes
  • Validating a discount code: The user enters a coupon, you validate it with your API and save the percentage in $context.discount to apply it when calculating the total
  • Temporary authentication: You get a token from your API and save it in $context.token to use in subsequent calls within the same flow
  • Intermediate calculations: The user selects products, you keep adding up the subtotal in $context.subtotal to display it before confirming the purchase
Example:
1. User asks: "Do you have the blue shirt in size M?"
2. API node → Queries inventory and saves $context.stock = 5
3. Message node → "We have {{$context.stock}} units available"
4. User purchases → You validate the quantity does not exceed $context.stock

Use $memory when

Use $memory when the data must persist between conversations. You can configure the time-to-live (TTL) for each variable. Use cases:
  • Remembering the user’s name to greet them personally
  • Saving the last shipping address to offer it as a default
  • Storing preferences that improve the experience in future interactions
  • Remembering that the user completed a verification step
Example:
Conversation 1: User says "My name is Maria"
→ You save $memory.name = "Maria"

Conversation 2 (same day):
→ You use {{$memory.name}} to greet: "Hello Maria"
For details on data types, TTL, files, and available methods, see the complete Memory guide.

Quick decision criteria

1

Do you need the data in future conversations?

No → Use $contextYes → Use $memory

Summary

Aspect$context$memory
DurationOnly during the conversationConfigurable (TTL): up to 1 day (JSON) or 1 week (files)
TypesAny JavaScript valuePrimitives, JSON (5 KB), Files (10 MB)
UseTemporary conversation dataImprove experience between conversations
SecurityIdeal for temporary sensitive dataDo not use for sensitive data