Smart Memory

Configuration-driven memory management for chatbots

Overview

The "Smart Memory" node provides configuration-driven memory management for chatbot sessions. It allows storing, retrieving, and clearing conversational memory associated with unique session IDs. This is useful in scenarios where chatbots need to maintain context over multiple messages or interactions, enabling more coherent and context-aware responses.

Practical examples include:

  • Inserting new user or bot messages into the session memory to keep track of conversation history.
  • Retrieving recent messages from memory to provide context for generating replies.
  • Clearing the memory when a session ends or needs to be reset.

The "Clear Memory" operation specifically removes all stored memory for a given session ID, effectively resetting the conversation context.

Properties

Name Meaning
Session ID Unique identifier for the session. Required to identify which session's memory to clear.
Storage Backend Where to store the memory. Supported option: "In-Memory".

Output

The output JSON for the "Clear Memory" operation contains a simple confirmation message:

{
  "message": "Memory cleared"
}

If an error occurs (e.g., missing session ID), the output JSON will contain an error message:

{
  "error": "Error description here"
}

No binary data is produced by this operation.

Dependencies

  • The node uses an internal in-memory storage backend for managing memory.
  • No external services or API keys are required.
  • No special environment variables or n8n configurations are needed beyond standard node setup.

Troubleshooting

  • Missing or empty Session ID: The node requires a non-empty session ID. If omitted or blank, it throws an error "Session ID is required and cannot be empty".
  • Unsupported storage backend: Currently, only "In-Memory" storage is supported. Selecting any other backend will cause an error indicating unsupported storage.
  • General errors: Any unexpected issues during execution will return an error message in the output JSON under the error field.

To resolve these issues:

  • Ensure the Session ID property is set and not empty.
  • Use the supported storage backend option ("In-Memory").
  • Check the error message returned in the output for guidance.

Links and References

Discussion