n8n AI Agent 如何按用戶保存可跨重啟延續的記憶
n8n AI agent memory per user that survives restarts
MemorySync Chat Memory 可供自行架設的 n8n AI Agent 按 End User ID 保存跨會話記憶,並以 Session ID 區分對話。該子節點需要 n8n 2.16.0 或更新版本,API key 亦須開啟 Write 權限。n8n Cloud 暫不適用;若遇到找不到 Session ID,應先檢查 Chat Trigger 的輸出。
Disclosure: I work on MemorySync (I'm Mohammed, the founder). I drafted this page with AI assistance and checked it against the MemorySync n8n guide, n8n's docs and the two forum threads below. I didn't run the setup for this page.
The MemorySync n8n guide covers moving an n8n AI Agent's memory off Simple Memory. This page answers two questions that come up on the n8n forum, and says when that move fits.
"My agent forgets everything after a page refresh"
In this thread, a user storing history in Simple Memory found that everything worked during an active chat, but after refreshing the page the AI acted as if it was talking to the user for the first time. Replies said this is expected: Simple Memory keys history by session ID, so a new session ID means an empty window. One reply pointed to the Chat Trigger's "Load Previous Session: From Memory" option (available once the chat is public), with the same Simple Memory node connected to both the trigger and the agent. Others said that memory across sessions needs a persistent store rather than Simple Memory.
n8n's docs add that Simple Memory shouldn't be used in queue mode, because n8n can't guarantee every call reaches the same worker (Simple Memory docs).
Where MemorySync fits: if you want a person's facts to carry into a new session, MemorySync Chat Memory replaces Simple Memory on the agent's Memory port. Per the guide, durable facts belong to an End User ID (a stable ID such as a Telegram chat ID, Slack user ID or email), while the Session ID only separates conversations. A refresh that starts a new session still finds the same person's facts, as long as the End User ID stays the same.
"No session ID found"
In this thread, a user on n8n Cloud got Error in sub-node Simple Memory: No session ID found with a Chat Trigger → AI Agent workflow. The first suggestion was to set Simple Memory's Session ID to "Connected Chat Trigger Node". That worked once, then failed on the second attempt. Two replies blamed the Chat Trigger's responseMode: lastNode setting, but resetting it didn't fix it. The last suggestion was to set the Session ID explicitly to {{ $('When chat message received').item.json.sessionId }}. The thread closed without a confirmed fix.
n8n's Simple Memory common issues page says to first check that the Chat Trigger's output includes a sessionId, and that without the chat trigger you have to manage sessions yourself.
Where MemorySync fits: honestly, this is a session-ID wiring problem, and switching memory backends won't fix it on its own. MemorySync Chat Memory needs a Session ID too (the guide uses {{ $json.sessionId }} for the Chat Trigger), so check the trigger output first. Also, this user was on n8n Cloud: installing community nodes from npm is a self-hosted feature, and n8n Cloud only lists nodes n8n has verified (MemorySync's verification is in progress).
When MemorySync fits, and when it doesn't
- Fits: a self-hosted n8n agent (Chat Trigger, Telegram, Slack, WhatsApp, webhook) that should remember each person across sessions, restarts or workers.
- Before you set it up: the Chat Memory sub-node needs n8n 2.16.0 or later. Create the API key with Write turned on: under Permissions, turn on Write as well as Read — new keys start read-only, and Add Memory, Add Conversation Turn and the Chat Memory sub-node all need Write.
- Doesn't fit: n8n Cloud, for now, or a one-off test chat nobody comes back to.
The install, credential and End User ID steps are in my earlier n8n chat memory tutorial.
Next step
The community node's source and install notes: n8n-nodes-memorysync.
Read the MemorySync n8n guide, then follow the tutorial for setup. To see save and recall in your browser first, try the MemorySync playground ($0 plan, no credit card required).
Sources
- n8n community: "I'm storing conversation history in Simple Memory", https://community.n8n.io/t/308432 (read 2026-10-27)
- n8n community: "SessionID not in output of chat node", https://community.n8n.io/t/277437 (read 2026-10-27)
- n8n docs: Simple Memory and Simple Memory common issues
- MemorySync n8n guide: docs.memorysync.io/guides/n8n
來源:DEV Community · dev.to