SQL Agent with Chart Generation Capabilities
detail.loadingPreview
Enhance SQL querying with dynamic chart generation using OpenAI.
About This Workflow
This workflow combines a native SQL Agent's data querying capabilities with OpenAI's ability to generate structured chart definitions. It allows users to ask questions in natural language, have the agent query a database, and then optionally visualize the results as charts. This fosters data analysis and visualization within a team by integrating AI-powered chart creation directly into the workflow.
Key Features
- SQL Agent Integration: Connects to SQL databases (PostgreSQL, MySQL, SQLite) to query data based on natural language input.
- Intelligent Chart Generation: Leverages OpenAI's structured output (JSON schema) to generate Chart.js definitions for visualizations.
- Dynamic Chart Creation: Uses Quickchart.io to render charts from the generated definitions.
- Text Classifier: Determines whether a chart would be beneficial for understanding the data, allowing for text-only or text-and-chart responses.
- Configurable Memory: Utilizes a window buffer for conversation memory, improving context awareness.
- Structured Output: OpenAI's
json_schemafeature ensures consistent and valid chart definitions.
How To Use
- Database Setup: Connect to your SQL database by configuring the
credentialsfor theAI Agentnode (e.g.,Coffee Sales Postgres). You can use provided Kaggle datasets and upload them to Supabase, or use SQLite binaries. - Activation: Activate the n8n workflow.
- Interaction: Start chatting with the
AI Agentby sending messages through theWhen chat message receivedtrigger. - Response: The agent will query the database and determine if a chart is needed.
- If a chart is required, it will be generated and appended to the text response.
- If not, only the text response from the SQL Agent will be provided.
- Customization: Adjust the
Prefix Promptin theAI Agentnode for specific database interactions or model behavior. Modify the JSON schema in theOpenAI - Generate Chart definition with Structured Outputnode for different chart types or customization options.
Apps Used
Workflow JSON
{
"id": "d9484ae1-5e60-4bf7-8679-10bada0ef7c2",
"name": "SQL Agent with Chart Generation Capabilities",
"nodes": 28,
"category": "AI",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: d9484ae1-5e60...
About the Author
SaaS_Connector
Integration Guru
Connecting CRM, Notion, and Slack to automate your life.
Statistics
Related Workflows
Discover more workflows you might like
Build an AI Documentation Expert Chatbot with Gemini RAG
This n8n workflow automates the creation of an AI-powered expert chatbot capable of answering questions based on your documentation. It intelligently ingests, cleans, and processes your knowledge base, preparing it for a Retrieval Augmented Generation (RAG) pipeline with Google Gemini.
Generate Multilingual Image Captions and Overlay
This workflow generates captions for images using Google Gemini and overlays them onto the image, with support for multilingual output.
LangChain Workflow Retriever Example
Demonstrates using LangChain's Retriever QA Chain to query data retrieved from another workflow.