Overview
The "Smart Memory" node provides configuration-driven memory management for chatbots, enabling them to store, retrieve, and clear conversational context across sessions. It supports operations to insert new messages into memory, fetch the current memory state, or clear stored memory for a given session.
This node is beneficial in chatbot workflows where maintaining conversation history is essential for context-aware responses. For example, it can be used to keep track of user inputs and bot replies during a chat session, allowing subsequent nodes or services to access recent messages and generate more relevant answers.
Practical examples:
- Insert each user message and bot response into memory to build a conversation history.
- Retrieve the last N messages from memory to provide context for an AI language model.
- Clear memory when a session ends or resets to avoid stale data.
Properties
| Name | Meaning |
|---|---|
| Session ID | Unique identifier for the session; required to distinguish different conversation contexts. |
| Storage Backend | Where to store the memory; currently supports only "In-Memory". |
Note: The provided properties JSON only lists "Session ID" and "Storage Backend", but the node supports additional properties depending on the operation (insert/get/clear), such as:
- Operation: Choose between "Insert Message", "Get Memory", or "Clear Memory".
- Message Content (for insert): Text content of the message to add.
- Memory Window Size (for insert/get): Number of messages to keep or retrieve.
- Insert Mode (for insert): How to insert the message ("Append" or "Replace Memory").
- Message Settings (for insert): Collection of optional metadata about the message and chat (chat ID, type, name, message ID, reply context options).
- Identity Settings (for insert): Information about the message sender or bot (roles, display names, usernames).
- Memory Settings (for insert/get): Options to include timestamp and token estimate in output.
Output
The node outputs JSON objects with the following structure depending on the operation:
- Insert Message: Returns the updated memory after insertion, including chat info, messages array, and message count. Optionally includes token estimate if enabled.
- Get Memory: Returns the current memory for the session with similar structure as above.
- Clear Memory: Returns a simple confirmation message
{ message: "Memory cleared" }. - Error: If an error occurs, outputs
{ error: "error message" }.
The messages array contains stored messages with associated metadata. If enabled, timestamps and token estimates are included. The node does not output binary data.
Dependencies
- Uses an internal in-memory storage backend by default.
- No external API keys or services are required.
- Relies on internal utility modules for normalization, output cleaning, and constants.
- Requires proper session ID input to function correctly.
Troubleshooting
- Missing or empty Session ID: The node throws an error if the session ID is missing or blank. Ensure this property is set and unique per conversation.
- Unsupported storage backend: Currently, only "In-Memory" storage is supported. Using other values will cause an error.
- Invalid memory window size: The memory window size must be a number within allowed min/max limits; otherwise, defaults are applied.
- Errors during insert/get/clear: Any unexpected errors are caught and returned in the output JSON under the
errorfield. - Empty memory retrieval: If no memory exists for a session, the output will indicate "No memory found for this session".
To resolve issues, verify all required parameters are correctly set and conform to expected types and constraints.
Links and References
- No external links are referenced in the source code.
- For general chatbot memory management concepts, see: