# Generate SQL from natural language via chat with MySQL and AI
This automation enables natural language interaction with a MySQL database through a chat interface. Using n8n, LangChain, and OpenAI, it loads the database schema and generates accurate SQL queries based on user input. The generated queries are executed, and results are returned in a readable format—accelerating data analysis and reducing dependency on SQL expertise.
## Who it´s for
- Data analysts who need to generate SQL quickly without deep syntax knowledge
- Developers automating chat-based database access
- Technical specialists training colleagues on data systems
- Project owners wanting to give non-technical users data access
## What the automation does
- On first run, extracts and stores the MySQL database schema
- Accepts user messages via chat or manual trigger
- Uses LangChain and OpenAI to generate SQL based on input and schema
- Executes generated queries against MySQL and formats results
- Returns agent response along with query output
- Can answer structural questions (e.g., “What tables exist?”) using schema only
## What´s included
- Ready-to-use n8n workflow
- Trigger logic: chat message or manual start
- Integrations with MySQL, OpenAI API, and HTTP API
- Basic text guide for setup and adaptation
## Requirements for setup
- MySQL instance with read (and query execution) access
- OpenAI account with valid API key
- Running n8n instance (self-hosted or cloud)
- Configured HTTP API endpoint to receive incoming messages
## Benefits and outcomes
- Faster data analysis by eliminating manual SQL writing
- Reduced reliance on SQL experts for routine queries
- Team training via conversational data exploration
- Prototype for a natural language database assistant
- Reusable logic for other AI-driven workflows
- Context-aware responses based on up-to-date schema
## Important: template only
Important: you are purchasing a ready-made automation workflow template only. Rollout into your infrastructure, connecting specific accounts and services, 1:1 setup help, custom adjustments for non-standard stacks and any consulting support are provided as a separate paid service at an individual rate. To discuss custom work or 1:1 help, contact via chat
No feedback yet