solved it! Spent hours on research and with the help of Cursor and Gemini2.5 I re-created my workflow and now my agent has memory again. Find attached an image of what the workflow looks like. Also: I had to implement a script into my frontend, which stores and sends a thread ID.
Here is what I did on my frontend (website with chatwindow):
1. Thread ID Storage Variable
// A variable to hold the thread ID. This acts as the "memory" on the browser.
// It starts as null because we don't have a thread ID yet.
let currentThreadId = null;
2. Sending Thread ID with Requests
// Prepare the data to send.
const bodyData = {
message: message
};
// THIS IS THE CRITICAL LOGIC FOR FOLLOW-UP MESSAGES
// If we have stored a thread ID from a previous message, add it to the request.
if (currentThreadId) {
bodyData.thread_id = currentThreadId;
}
3. Storing Thread ID from Response
const data = await response.json();
// THIS IS THE MOST IMPORTANT STEP
// After getting a response from n8n, check if it contains a thread_id
// and save it in our variable for the next message.
if (data.thread_id) {
currentThreadId = data.thread_id;
}
How it works:
- Initial state:
currentThreadIdstarts asnull - First message: Only sends the message (no thread_id)
- Response handling: If the n8n response contains a
thread_id, it’s stored incurrentThreadId - Follow-up messages: All subsequent messages include the stored
thread_idin the request body - Thread continuity: This allows the conversation to maintain context across multiple messages
The key insight is that the thread ID acts as a “memory” on the client side, persisting the conversation context between requests to your n8n webhook.```
–
hope this helps!
