Simple Memory Node Not Isolating Sessions Correctly (Session ID Issue)
Hello n8n Community,
I’m currently working on a chatbot project using n8n Cloud (free tier) and I’m encountering a persistent issue with the Simple Memory
node that I can’t seem to resolve, despite extensive debugging.
Project Overview:
I have a web-based chatbot (HTML/JavaScript frontend) that communicates with an n8n webhook. The n8n workflow uses an AI Agent
(connected to Google Gemini) for chatbot logic and aims to store conversation history using the Simple Memory
node. User and bot messages, along with a unique sessionId
(UUID generated on the frontend), are then passed through the workflow.
The Problem:
The Simple Memory
node does not appear to be isolating chat history based on the provided sessionId
. Even when I open the chatbot on different devices or in new Incognito/Private browser windows, the bot continues the conversation from a previous session, as if it’s using a single, global memory store instead of creating/retrieving memory per sessionId
.
What I’ve Already Checked and Confirmed:
- Frontend
sessionId
Generation: The frontend successfully generates a unique UUID forsessionId
for each new browser session (or whenlocalStorage
is cleared). - Webhook Input: The
Webhook
node correctly receives theuserMessage
and thesessionId
within thebody
of the incoming JSON. For example, the input to theSimple Memory
node consistently contains a uniquesessionId
like"fbafe9c1-5b6d-49e5-9f3d-f56741a24515"
. Edit Fields
Node: A precedingEdit Fields
node correctly transforms{{ $json.body.userMessage }}
into abody
field that contains the user’s message.AI Agent
Node Prompt: ThePrompt (User Message)
field in theAI Agent
node is correctly set to{{ $json.body }}
.Simple Memory
Node Configuration:Session ID
is set to{{ $json.body.sessionId }}
(and it’s confirmed to be recognized as an expression, not plain text).Key
is set touserMessage
.Context Window Length
is50
.
Simple Memory
Node Behavior: Despite a uniquesessionId
being passed into theSimple Memory
node’s INPUT, thechatHistory
in its OUTPUT (and thus passed to theAI Agent
) often contains messages from previous, unrelated sessions. It seems the memory is not being correctly partitioned by thesessionId
. For instance, if a new session starts with “hello,” thechatHistory
might still include “smart fridge” from an earlier, distinct session.- Debugging Steps: I’ve tried deactivating and reactivating the workflow in n8n Cloud, and testing with clean browser sessions (incognito mode), but the issue persists.
My Question:
Given that the sessionId
is correctly transmitted and configured in the Simple Memory
node, what could be causing the memory not to be isolated per session? Is this a known limitation or bug with the Simple Memory
node, especially on the free tier of n8n Cloud? Or am I missing a crucial configuration step for proper session isolation?
Any help or insights would be greatly appreciated!
Thank you!