Use this powerful n8n workflow template to query your MySQL database using plain English via an AI Agent powered by OpenAI. This n8n workflow integrates multiple n8n node types for advanced data access.
Download this n8n workflow template and start using it instantly.
Data Analysts who need a rapid, conversational way to extract information without writing complex SQL.
Technical Leaders looking to create self-service data access tools for non-technical teams.
n8n Automation Specialists developing powerful AI-driven n8n templates.
Developers seeking to implement advanced RAG and Tool-use patterns within an n8n workflow.
Data access often requires specialized knowledge, typically SQL proficiency. This sophisticated n8n workflow template bridges that gap, allowing any user to query complex MySQL databases using simple, plain English questions. By leveraging an advanced Langchain-based AI Agent, this n8n automation first intelligently checks the database schema using a specific n8n node (the 'SQL DB - List Tables and Schema' tool), ensures the generated query is valid, and then executes it using another n8n node (the 'Execute a SQL query in MySQL' tool).
This setup provides a high degree of control, accuracy, and efficiency. It demonstrates the power of integrating AI tools and core database operations within a single n8n workflow, making it an indispensable asset for modern data operations. This is a highly practical n8n workflow that showcases advanced Langchain integration.
This process begins with the designated n8n trigger: the 'When chat message received' n8n node, which captures the user's natural language question.
To deploy this powerful n8n workflow template, follow these steps:
gpt-4.1-mini model, but you can adjust this.yourdatabasename with the actual name of your database.This n8n workflow relies on a few key specialized n8n node types:
When chat message received (Langchain ChatTrigger): This is the initiating n8n trigger. It listens for incoming chat messages (often via a connected chat interface or webhook) to start the natural language query process.
AI Agent (Langchain Agent): The brain of the n8n workflow. It orchestrates tool use, deciding when to check the schema, when to execute a query, and how to formulate the final answer based on strict instructions.
OpenAI Chat Model (Langchain LLM): Supplies the language generation capability, translating the user's need and the schema into precise SQL commands. It uses credentials linked to your OpenAI account.
Simple Memory (Langchain Memory): A critical n8n node for maintaining conversation context. It allows the agent to recall the previous five messages, ensuring follow-up questions are understood within the context of the running n8n workflow session.
SQL DB - List Tables and Schema (MySQL Tool n8n node): This tool provides introspection. It runs a query to list the available tables and columns, feeding this vital context to the AI before query generation. This dramatically improves the accuracy of the generated SQL in this n8n workflow.
Execute a SQL query in MySQL (MySQL Tool n8n node): This final action n8n node executes the SQL code generated by the AI Agent and returns the resulting data set.
Automate natural language queries for Monday.com tasks using this powerful n8n workflow. Integrate GPT-4o to analyze real-time board data instantly, eliminating manual searches.

Use this sophisticated n8n workflow to sync Google Sheets data to PostgreSQL, then query the database naturally using a Gemini AI Agent. Leverage powerful n8n templates for RAG.

Deploy an advanced AI assistant using this n8n workflow. It combines Retrieval-Augmented Generation (RAG) via Supabase and Text-to-SQL via Peliqan to query internal documents and quantitative business data effectively. This n8n template accelerates BI.

Use this specialized n8n workflow to leverage the power of Perplexity AI within your automation projects. Configure system prompts, user questions, and restrict searches to specific domains using a custom n8n node.









































