Build an advanced n8n workflow using OpenAI Assistants, PostgreSQL memory, and external API calls (MySQL/HTTP). This n8n template manages context and retrieves real-time data.
Download this n8n workflow template and start using it instantly.
Automation specialists looking for complex n8n templates integrating AI agents.
E-commerce or service providers needing a smart chatbot that leverages real-time product data (MySQL).
Developers utilizing n8n to manage conversational context with persistent database memory (Postgres).
Teams who want to extend their OpenAI Assistant capabilities using custom n8n node tooling.
This is a powerful, production-ready n8n workflow designed to power a modern chat assistant. The primary challenge this n8n template solves is maintaining conversational state (memory) and enabling the AI to interact with external systems for real-time data access. It uses PostgreSQL to ensure long-term, persistent memory storage, allowing the AI to recall details about the user, even across sessions. Furthermore, by utilizing specialized n8n node components like the MySQL Tool and HTTP Request Tool, the OpenAI assistant can perform complex tasks, such as looking up product quotes based on detailed user criteria (age, location, group size), transforming the chat assistant from a simple responder into a powerful service agent. This architecture highlights the flexibility of the n8n platform for advanced AI orchestration.
The n8n workflow begins execution using the dedicated Chat Trigger n8n node, which initiates the conversation upon receiving a user request, along with session information and optional lead data.
leadData) is present.leadData exists, the flow takes the true path. An Edit Fields n8n node constructs a highly specific, non-conversational instruction prompt using the available user data (age, city, profession, etc.). This prompt is fed into the first OpenAI n8n node, whose sole purpose is to utilize the Postgres Chat Memory n8n node to silently save this lead information, establishing context for future interactions.To deploy this advanced n8n workflow, follow these steps:
asstnumdCoMZPQ6GwfiJg5drg9hr and asstx2qfc7EuoPv7XGOL84ClEZ3L) which must be pre-configured in your OpenAI account, including their function calling capabilities matching the tools defined in this n8n template.aimessages) exists for storing chat history. Chat Trigger (n8n trigger): The entry point of this n8n workflow. It is publicly accessible and listens for incoming chat requests, providing the initial chatInput and sessionid.
If n8n node: Controls the branching logic. It determines if the incoming payload contains leadData, routing the request either to a data ingestion path or directly to the standard conversation path.
Edit Fields (Set n8n node): Used to construct specialized system prompts for the AI, particularly for silently uploading user lead information into the chat memory, which is critical for personalized responses.
OpenAI (LangChain Assistant n8n node): There are two instances managing the conversational flow. They utilize specific OpenAI Assistants to process queries, handle tool utilization, and generate the final output for this n8n workflow.
Postgres Chat Memory (LangChain Memory n8n node): A crucial n8n node for persistent state management. It retrieves and saves session history using the sessionid key, allowing the AI to maintain long-term context using Postgres.
Products in Daatabase (MySQL Tool n8n node): Allows the AI to execute a complex SQL query to search for filtered product results based on criteria (like age and city), enabling real-time data querying within the n8n workflow.
Use this core logic n8n workflow to reliably change the file extension and associated MIME type of binary data passing through your n8n automation. Essential for consistent file processing.

Centralize your n8n error handling with this robust n8n workflow. Automatically configure error handlers, catch failures, and send detailed Gmail alerts for instant visibility across all your n8n projects.

Use this robust n8n workflow to automatically aggregate customer reviews from Trustpilot, Google, and Facebook APIs, normalize the data, and save it directly to Google Sheets for centralized reporting.

Use this foundational n8n workflow to integrate diverse AI models, like Mistral, through OpenRouter.ai. Learn how to configure the n8n HTTP Request node for custom LLM automation.

This n8n workflow automates a full RAG system using Google Drive, OCR (Mistral AI), OpenAI embeddings, and Supabase vectors. Utilize these n8n templates to power a multi-channel AI chat agent across Slack, Telegram, and Gmail.








































