This workflow automates intelligent database querying via natural language, replacing complex manual SQL processes for data teams. The Manual Trigger initiates schema extraction, the Chat Trigger enables conversational queries, a MySQL node connects to the database, Code nodes extract schema, validate inputs, and process SQL with security checks, an AI Agent node generates safe SELECT queries using a provided schema, and result formatting delivers clear, tabular outputs. This streamlines data access for teams handling 100+ queries weekly, enhancing productivity for businesses with 10-50 team members.\n\nThis workflow saves 8-12 hours weekly for teams managing 100+ queries, improving query efficiency by 85%. Use cases include business analytics for ad-hoc reporting, customer support for data lookup, or e-commerce for inventory analysis. Requires MySQL database (e.g., db4free, free), OpenAI API ($0.01-$0.10/1k tokens), and n8n (free or cloud from $20/month). Scalable to 1,000 daily queries with optimized database and AI.\n\nThis workflow requires n8n setup via n8n.io download or cloud.n8n.io signup. For MySQL, configure credentials (host, user, password, database) and store as DB_NAME. For OpenAI, get API key from platform.openai.com, store as OPENAI_API_KEY. Set ENABLE_PII_REDACTION (true/false) for data protection and MAX_TOKENS (e.g., 3000) for AI processing. Import JSON, run Schema Setup Trigger to generate './devhub_database_schema.json,' then use Chat Trigger for queries.\n\nThis workflow’s testing uses sample chat inputs (e.g., 'Show recent orders') via the Chat Trigger. Verify schema file creation, query outputs in logs, and formatted results. Common errors: invalid MySQL credentials (check connection), missing schema file (run setup), unsafe queries (rephrase to SELECT-only). Activate in production, monitor n8n dashboard. Maintain by updating schema monthly, refreshing API keys quarterly, and scaling with cloud database for high volumes.\n\nRequired Variables:\n- DB_NAME: MySQL database name\n- OPENAI_API_KEY: OpenAI API key for AI model\n- ENABLE_PII_REDACTION: true/false for PII protection\n- MAX_TOKENS: Token limit for AI processing (e.g., 3000)", "businessValue": "Saves 8-12 hours/week automating 100+ database queries, improving efficiency by 85%", "setupTime": "30-45 minutes", "difficulty": "Intermediate", "requirements": ["MySQL database (e.g., db4free, free)", "OpenAI API ($0.01-$0.10/1k tokens)", "n8n instance"], "useCase": "Natural language database querying with AI-generated SQL"
$6.99
Workflow steps: 17
Integrated apps: manualTrigger, chatTrigger, code