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.
**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.
### **Extra Information:**
* **n8n Version:** `1.74.3`
* **Database:** PostgreSQL (running on Supabase)
* **n8n EXECUTIONS_PROCESS setting:** `own`
* **Running n8n via:** Docker Desktop App
* **Operating System:** Windows