Adding chat memory to an n8n agent with MemorySync
Описание и применение
В статье описывается, как подключить узел MemorySync к AI Agent в n8n, чтобы сохранять историю чата и извлекать долговременные факты между выполнениями workflow.
Задача
n8n’s AI Agent node only remembers conversation history while the workflow runs; after a workflow ends the chat history is lost, preventing long‑term context and fact lookup.
Результат
The workflow persists chat history and user facts across executions, allowing the AI Agent to resume conversations and retrieve long‑term facts via MemorySync tools.
Рабочий процесс
- Install the n8n-nodes-memorysync community node via Settings → Community Nodes → Install.
- Add a MemorySync API credential with a valid API key.
- Create a two‑node smoke test: Manual Trigger → MemorySync (Add Memory) with End User ID "alice" and a fact, then MemorySync (Search Memories) querying "what does Alice eat?".
- Build the AI Agent workflow: Chat Trigger → AI Agent, set the Memory port to MemorySync Chat Memory, configure Session ID and End User ID, leave Context Window Length at 10.
- Attach a MemorySync Search Memories node as a tool under the agent’s Tools, using the same End User ID expression.
- Optionally use the Recall Context operation in non‑agent workflows to fetch a single context block for a prompt.
Доказательства
n8n's AI Agent node remembers a conversation only as long as its memory sub-node does.
The simplest option, Simple Memory, "stores a customizable length of chat history for the current session".
It moves the agent's chat history into MemorySync, so a conversation can pick up again in a later execution.
The node is marked as usable as a tool, so the agent can decide on its own when to look something up.
- Дата записи: 2026-10-20T17:56:27.234Z