Activity
Mon
Wed
Fri
Sun
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
What is this?
Less
More

Memberships

AI Automation Society

208.5k members • Free

1 contribution to AI Automation Society
How to Store user_id in PostgreSQL Chat Memory in n8n?
Hi everyone, I'm currently setting up a PostgreSQL Chat Memory node in n8n to store user conversations, but I'm struggling to properly include and save the user_id alongside each chat session. (I already have this question posted on https://community.n8n.io/t/how-to-store-user-id-in-postgresql-chat-memory-in-n8n/76889/1 but no one seems to be able to help.) **What I'm trying to achieve:** * Each chat message should be stored in PostgreSQL with a session ID and user ID. * The user_id is included in the JSON payload sent to n8n. * I need to ensure that the PostgreSQL Chat Memory node correctly maps and stores the user_id in my database. **My Current Setup:** Incoming JSON Payload (from API to n8n Webhook): ``` { "sessionId": "123e4567-e89b-12d3-a456-426614174000", "question": "Hello!", "userId": "d2aacd76-d26f-4eda-93f0-739c12da4ea2" } ``` Code Node (Pre-processing the Data Before Saving to PostgreSQL): ``` return { sessionId: $json.sessionId, question: $json.question, userId: $json.userId, // Ensuring userId is at the top level originalData: $json }; ``` PostgreSQL Chat Memory Node (Input Mapping): * Session ID: {{$json["sessionId"]}} ✅ (works) * Question: {{$json["question"]}} ✅ (works) * User ID: {{$json["userId"]}} ❌ (not getting stored) As you can see in the image I have with this post. **Issue:** Even though I can see userId in the incoming JSON and in my Debug Panel, the PostgreSQL Chat Memory node does not seem to store it in my database. I don't see an option to directly map user_id in the node settings. **My Questions:** 1. How can I properly map the user_id so that it gets saved in PostgreSQL? 2. Does the PostgreSQL Chat Memory node support storing additional fields like user_id? 3. If not, is there a recommended workaround to ensure that every chat message is linked to the correct user? Any help or insights would be greatly appreciated! Thanks in advance.Any help or insights would be greatly appreciated! Thanks in advance.
How to Store user_id in PostgreSQL Chat Memory in n8n?
0 likes • Feb 20
@Chaplain TIG Heaslet I have not, but I don't get an error. Also I don't have the n8n cloud anymore, I use it on my docker, which doesn't support the AI Helper. Can you remember what fixed it for you?
0 likes • Feb 24
@Raoni Gabriel I guess this is the only way! Thanks! I got it figured out now
1-1 of 1
@mark-luiken-6353
Hi

Active 127d ago
Joined Jan 25, 2025
Powered by