Quick overview This workflow powers an OpenAI-based chat agent in n8n that persists long-term conversation memory in an n8n Data Table by session ID, optionally recalling past context via name/email lookups while enforcing an identity-verification flow. How it works 1. Receives a chat message via the n8n Chat Trigger and uses the provided sessionId to identify the conversation. 2. Searches the n8n Data Table for an existing row with the same sessionid and either loads the saved fields or

Quick overview This workflow powers an OpenAI-based chat agent in n8n that persists long-term conversation memory in an n8n Data Table by session ID, optionally recalling past context via name/email lookups while enforcing an identity-verification flow. How it works 1. Receives a chat message via the n8n Chat Trigger and uses the provided sessionId to identify the conversation. 2. Searches the n8n Data Table for an existing row with the same sessionid and either loads the saved fields or creates a new session record. 3. Uses an OpenAI chat model with a sliding window memory (last 10 turns) to generate the assistant response based on the user message and any loaded session context. 4. Updates the current session’s Data Table row with newly captured details (for example name, email, company, interests, topics, and chat history) according to the agent’s rules. 5. When the user provides a name or email, queries the Data Table for past sessions via the lookup-by-name and lookup-by-email tools to support a privacy-preserving “welcome back” flow. Setup 1. Create or select an n8n Data Table (for example, chatsessiondata) with columns that match the workflow fields you want to store (such as sessionid, firstname, lastname, userid/email, company, interestedin, lasttopic, and chathistory). 2. Add an OpenAI API credential and select the model in the OpenAI Chat Model node. 3. Update the Data Table ID references in the Data Table and Data Table Tool nodes to point to your table. 4. Activate the Chat Trigger and use the generated chat/webhook endpoint in your chat entry point (or test from n8n’s chat UI). 5. Set the workflow timezone in n8n settings to ensure timestamps and session timing align with your locale. Requirements - OpenAI GPT-5.2 Customization - Change the agent name, company name, and role description in the system prompt to match your own use case - Add or remove data table fields to capture different information relevant to your business domain - Swap OpenAI for any other LLM that supports tool calling (Anthropic Claude, Google Gemini, etc.) - Replace email as the identity verification key with phone number or membership ID by updating the lookup tool filters - Extend to additional chat channels such as WhatsApp or Telegram by adding a channel-specific trigger and reusing the same data table - Write a schedule triggered workflow to clean-up old session records based on updateAt date, or just manually delete Additional info Works on self-hosted and cloud
Download the workflow JSON file after purchase.
Open n8n → click the menu → Import from File.
Select the downloaded JSON and import.
Set up credentials for each node that requires them.
Click Execute Workflow to test, then activate.
Setup guide included
Purchase to unlock the full step-by-step guide
No reviews yet
Be the first to buy and share your experience.
Leave a review
Sign in to share your experience with this workflow.
Create a free account to purchase workflows.
Need help setting this up?
Book a 3-hour live setup session with an Agility consultant.