What This Workflow Does
This n8n workflow bridges the gap between natural language questions and database queries by leveraging GPT AI. It allows non-technical users to ask questions in plain English and receive accurate responses from your MySQL database without writing SQL.
The system interprets the user's intent, converts it to proper SQL syntax, executes the query against your database, and returns the results in a human-readable format. This eliminates the need for database expertise while maintaining data security and accuracy.
How It Works
1. Natural Language Input
Users submit questions through a chat interface or web form. Example: "Show me last month's top 10 customers by revenue."
2. AI Query Conversion
The GPT model analyzes the question, understands the intent, and generates appropriate SQL syntax based on your database schema.
3. Query Execution
The workflow executes the generated SQL against your MySQL database with proper authentication and connection parameters.
4. Result Formatting
The raw database results are processed and formatted into a clean, readable response for the end user.
Who This Is For
This solution benefits business teams that need database access but lack SQL skills, including:
- Marketing teams analyzing campaign performance
- Sales managers tracking pipeline metrics
- Operations staff monitoring inventory levels
- Executives needing ad-hoc business insights
What You'll Need
- Self-hosted n8n instance (community edition works)
- MySQL database credentials with read access
- OpenAI API key for GPT integration
- Basic understanding of your database schema
Quick Setup Guide
- Download and import the JSON template into your n8n instance
- Configure your MySQL database connection details
- Add your OpenAI API key in the GPT node settings
- Map your database schema fields in the workflow
- Test with sample natural language questions
Key Benefits
Democratize data access: Enable non-technical teams to get answers directly from your database without IT bottlenecks.
Reduce SQL training costs: Eliminate the need for staff SQL training while maintaining data governance.
Accelerate decision-making: Get answers to business questions in seconds rather than waiting for reports.
Improve data accuracy: AI-generated queries follow proper syntax and database constraints.