- Home
- Resources
- Integrations
- Postgres Chat Memory
n8n Postgres Chat Memory nodeConfigure Postgres Chat Memory in n8n.
An AI agent forgets everything between two messages unless something stores the conversation. The n8n Postgres Chat Memory node writes that history to a Postgres table and reads it back on the next run. Two parameters to set, one port to plug into, and the table is created for you.
Verified Trustpilot reviews · AI, automation & growth agency
What does the n8n Postgres Chat Memory node actually do?
Postgres Chat Memory is a sub-node, meaning a node that never runs on its own and has no main input. You attach it to the memory port of a root node such as an AI Agent, and every exchange of the conversation then lands in a Postgres table. On the next message, the agent reads that table back instead of starting from nothing. Memory, in an AI context, is simply the message context a tool keeps between interactions.
Take a customer support assistant answering on a messaging channel. Without memory, a shopper who writes "and in blue?" gets a blank stare, because the agent has no idea what "it" was. Plug this sub-node into the AI Agent memory port, point Table Name at a table of your choice, and the thread holds together across messages, days and workflow restarts.
The second case is a shared assistant used by many people at once. Every conversation needs its own bucket, which is what Session ID decides: either the sub-node picks up the sessionId field coming from a directly connected Chat Trigger, or you write an expression such as {{ $json.userId }} to build the key yourself. Two people chatting at the same time, two session keys, two histories that never bleed into each other.
The third one is an internal data agent. You wire a chat model from OpenAI or Anthropic to the agent, give it a couple of tools that query your own APIs, and keep the history in Postgres so a colleague can ask a follow-up question an hour later and still be understood. The same sub-node also serves an AI Agent Tool when the agent itself is called by another workflow.
When would you reach for something else? If the goal is to read, edit or wipe stored messages rather than just accumulate them, that job belongs to the Chat Memory Manager root node, not to a memory sub-node. And if your workflow uses an AI chain rather than an agent, memory is not an option at all: n8n agent nodes can use memory, chains cannot.
Two limits worth knowing before you build. First, several Postgres Chat Memory nodes in one workflow share the same memory instance by default, so a destructive action in one place can overwrite what another node stored; different session IDs keep them apart. Second, the node exposes 2 head parameters at version 1 and nothing more, so anything fancier than storing and replaying a thread has to happen around it. The n8n training walks through that kind of assembly if agents are new territory.
What do you need before the node will run?
- 01
Create the Postgres credential
Open the Credentials menu in n8n and add a Postgres credential. It asks for a Host, a Database name, a User and a Password, plus a Port, an SSL mode and, only if the database sits behind one, an SSH Tunnel. The same credential then serves every workflow on the instance, on n8n Cloud or self-hosted. You create it once, you select it in the node, and never paste connection details again.
- 02
Attach the sub-node to a memory port
This node has no main input, so dropping it on the canvas alone does nothing. Drag its connector to the memory port of a root node that accepts it: AI Agent, AI Agent Tool, Chat Memory Manager or Chat Trigger. The link is what tells n8n which conversation the table belongs to. Until that connection exists the sub-node stays idle, and the agent keeps answering each message as if it were the first one.
- 03
Set the table and the session key
Fill Table Name with the table that will hold the chat history. If it does not exist yet, n8n creates it, so a fresh name is a perfectly valid answer on a first run. Then choose how Session ID is built:
fromInputto reuse thesessionIdfield arriving from a directly connected Chat Trigger, orcustomKeyto define the value yourself with an expression or static text.
Where does this sub-node plug in?
n8n AI workflows are built as a root node that receives the items, surrounded by sub-nodes clipped onto its ports, one type of sub-node per port.
Output (what it plugs into)
- Memory
ai_memory
01Memory
Postgres Chat Memory exposes a single memory output and that is the only place it belongs. The root node you connect it to decides which conversation gets persisted.
Key parameters
- Optional: a root node runs without memory, it simply answers each message with no recollection of the previous one.
- AI Agent and AI Agent Tool: the usual hosts, for an assistant that holds a thread across turns.
- Chat Memory Manager and Chat Trigger: the other two root nodes that accept this port.
Which parameters do you actually set?
The Postgres Chat Memory node has 2 parameters. For each one: the node as you configure it in n8n, what the parameter changes, and our field notes.
Parameters index
Session ID
sessionIdTypeWhat you see in n8n
Notes & use cases
This parameter answers one question: under which key is this conversation filed? Get it wrong and two users share a history, or the same person starts over at every message.
Key parameters
- Connected Chat Trigger Node (
fromInput): looks for an input field calledsessionIdcoming from a directly connected Chat Trigger. - Define below (
customKey): use an expression to reference data in previous nodes, or enter static text. - Key (
sessionKey): the key used to store the session ID in the memory.
{{ $json.userId }} gives each person a private thread.Table Name
tableNameWhat you see in n8n
Notes & use cases
Here you name the Postgres table that holds the chat history. Nothing to prepare on the database side: if the table does not exist, it gets created on the first run.
Key parameters
- Table Name (
tableName): the table name to store the chat history in, created automatically when missing.
Need help automating Postgres Chat Memory with n8n?
A person reads every message.
Questions people ask next
01Is the Postgres Chat Memory node included in n8n?
02What do you need for the node to work?
03What are the limits of the n8n Postgres Chat Memory node?
04What is the minimum you must connect to an AI agent?
05n8n or Make for an AI assistant with memory?
Get our weekly integration tips.
No spam. Unsubscribe anytime.


