Back to Catalog

Templates by hippolyte-hu

Conversing with data: transforming text into SQL queries and visual curves

Conversational Data Retrieval and Visualization Workflow This workflow enables users to interact with a PostgreSQL database using natural language. It translates text inputs into SQL queries, retrieves the corresponding data, and generates visualizations using QuickChart, facilitating seamless data analysis without manual query writing. Table of Contents Pre-conditions and Requirements Database Schema Setup Step-by-Step Workflow Explanation Customization Guide Pre-conditions and Requirements API Keys and Services Required To operate this workflow, access to the following services is necessary: DeepSeek API: For converting natural language into SQL queries. API Key: Obtain from your DeepSeek account. QuickChart: For generating data visualizations. Service URL: https://quickchart.io/chart n8n Instance Setup n8n Installation: Install and run n8n using the Official Guide. Credential Configuration: DeepSeek API: Set up DeepSeek credentials in n8n by adding your API key. PostgreSQL Database: Local Database Access: If your PostgreSQL database is hosted locally and needs to be accessed over the internet (e.g., by n8n running on a different machine or in the cloud), you can expose it using ngrok: Install ngrok: Download and install ngrok from ngrok.com. Start ngrok Tunnel: Run the command ngrok tcp 5432 to expose your local PostgreSQL server. This will provide a forwarding address like tcp://0.tcp.ngrok.io:12345 that can be used to connect to your local database remotely. Update n8n Credentials: In n8n, configure the PostgreSQL node to use the ngrok forwarding address, ensuring remote access to your local database. Database Schema Setup Before initiating the workflow, ensure that the database schema is extracted and saved: Extract Schema: Retrieve the database schema, including table names and column details. Save Schema: Store the extracted schema in a JSON file for reference during query generation. Step-by-Step Workflow Explanation User Input Handling The workflow begins by receiving a natural language query from the user. Schema Retrieval Loads the previously saved database schema from the JSON file. AI-Based SQL Generation Combines the user's query with the database schema. Utilizes the DeepSeek API to translate the natural language query into a SQL statement. SQL Query Execution Executes the generated SQL query against the PostgreSQL database. Retrieves the data corresponding to the query. Data Visualization Formats the retrieved data into a structure compatible with QuickChart. Sends the data to QuickChart to generate a visual representation. Example: To create a bar chart, construct a URL with the chart configuration: https://quickchart.io/chart?c={type:'bar',data:{labels:['Label1','Label2'],datasets:[{label:'Dataset1',data:[10,20]}]}} This URL returns an image of the chart. Response Delivery Presents the generated visualizations and data insights to the user. Customization Guide Modifying the AI Model Alternative AI Services: Replace DeepSeek with other AI models by adjusting the API call configurations in the workflow. Changing Visualization Services Visualization Tools: Swap QuickChart with other visualization services by modifying the data processing and visualization steps. Expanding Database Support Additional Databases: Adapt the workflow to support other databases (e.g., MySQL, MongoDB) by configuring the respective database credentials and query execution nodes. --- This workflow streamlines the process of data retrieval and visualization, allowing users to interact with their database using natural language, thereby enhancing accessibility and efficiency in data analysis. ---

hippolyte-huBy hippolyte-hu
3321

Conversational PostgreSQL agent with visuals, multi-KPI, and data editing (MCP)

Ask your PostgreSQL database complex questions and receive clear summaries, charts, and even update or insert data โ€” all through one smart agent powered by n8nโ€™s Model Context Protocol (MCP). Supports: Multi-KPI insights in one prompt Auto-generated QuickChart bar/pie charts Natural-language inserts and updates Markdown-friendly output for dashboards --- ๐Ÿš€ Why This Version Stands Out This version goes beyond reporting: ๐Ÿ“ˆ Auto-generates charts (QuickChart) ๐Ÿงฎ Answers multiple KPIs in one message โœ๏ธ Add and update records securely ๐Ÿง  Uses up to 30 planned steps for smart reasoning ๐Ÿ’ฐ Estimated cost per run: ~$0.02 --- ๐Ÿ’ฌ Example Output --- ๐Ÿงฐ Key Components MCP Server Trigger โ†’ Receives natural queries Claude 3.5 Haiku โ†’ Plans, reasons, splits tasks DeepSeek โ†’ SQL and QuickChart generation checkdatabase subflow โ†’ Validates SQL Plot Tool โ†’ Converts data to QuickChart URLs Insert/Update nodes โ†’ Edits PostgreSQL records Markdown Formatter โ†’ Combines output into readable message --- ๐Ÿค– Model Configuration Notes This workflow uses two models: Claude 3.5 Haiku (Anthropic) Used as the MCP agent for reasoning, planning, and tool calling. Claude is the native model for MCP and delivers reliable results in fewer steps. DeepSeek Used in: checkdatabase for SQL generation Plot Tool for QuickChart JSON generation ๐Ÿง  All models are modular โ€” you can plug in OpenAI, Gemini, or Mistral if desired. --- ๐Ÿ” Security by Design No raw SQL from user input Fully parameterized queries Structured tool calling with validation Safe output format (text + chart links) --- ๐Ÿงช Try This Prompt > โ€œShow me top 5 products by revenue, revenue per month chart, and best customers.โ€ Expected output: 3 KPIs Multiple SQL queries 2โ€“3 QuickChart links Markdown summary for dashboard/Slack --- ๐Ÿ›  How to Use Import: BuildyourownPostgreSQLMCPservervisualscapable_.json checkdatabase.json Plot_tool.json Create your PostgreSQL credential under โ€œCredentialsโ€ in n8n: Must match the name used in the workflow (e.g., Postgres account 3) Assign AI models: Claude 3.5 Haiku โ†’ MCP agent (Claude 3.5 MCP Agent) DeepSeek โ†’ LLM nodes inside checkdatabase and Plot Tool Trigger the workflow using the URL from the MCP Server Trigger node (e.g., in a chatbot, HTTP request, or Webhook UI) --- ๐Ÿ“ฆ End-User Setup Guide If you're using this template for the first time, follow these exact steps: Go to your n8n dashboard and import all three workflows (main + subflows) Create a PostgreSQL credential using your host, database, user, and password Go to the Claude and DeepSeek nodes, and connect them to your account(s) Use the Webhook URL in the MCP Server Trigger to connect your chatbot or frontend Send a prompt like: โ€œShow me revenue per month, top 5 products, and a chart of best customers.โ€ Optional: You can increase the MCP Agentโ€™s MaxIterations to go deeper (default is 30) You can use Switch nodes to limit access to certain tables or actions Insert/Update nodes are already included and can be safely enabled โœ… Once this is done, your AI assistant will: Read from your database Visualize data via QuickChart Insert or update rows Respond in clear, markdown-formatted summaries --- ๐Ÿ”— More Templates by the Same Creator PostgreSQL Conversational Agent with Claude & DeepSeek (Multi-KPI, Secure) Conversing with Data: Transforming Text into SQL Queries and Visual Curves Customer Feedback Analysis with AI, QuickChart & HTML Report Generator

hippolyte-huBy hippolyte-hu
2185

Customer feedback analysis with AI, QuickChart & HTML report generator

Generative Customer Insights from Feedback Data using AI Agents & Charts This workflow automates the analysis of customer feedback or social media data from Google Sheets using DeepSeek LLM, transforming raw text into structured semantic insights. The workflow also generates data visualizations and produces a final HTML report, ready for email delivery. --- Table of Contents What This Workflow Does Pre-conditions and Requirements Step-by-Step Workflow Explanation Example Results Customization Guide --- What This Workflow Does This workflow performs automated semantic analysis on unstructured feedback data (from Google Sheets), using LLM-based agents and a sequence of transformations. It achieves: Prompt proposal generation: AI generates generalizable prompts for various analysis dimensions. Row-level analysis: Each row of data is evaluated against all prompts. Output merging and refinement: Raw analysis outputs are merged, deduplicated, and semantically clustered. Visualization and report generation: QuickChart is used to create graphs, and an HTML report is produced. Email delivery: The full report is sent automatically via Gmail. --- Pre-conditions and Requirements API Keys DeepSeek API Key Gmail OAuth2 (for sending results) Google Sheet Access A preformatted Google Sheet containing social listening feedback The sheet must include at least 20 rows for sample prompt generation n8n Configuration Nodes used: Google Sheets, LangChain (LLM/Agent/Parser), Function, Merge, QuickChart (via URL), Gmail Ensure all credentials are configured properly in n8nโ€™s credential manager --- Step-by-Step Workflow Explanation Google Sheet Import Retrieves feedback rows from a specific Google Sheet tab Filters to the first 20 rows for prompt generation Prompt Proposal Agent AI generates 3โ€“6 row-level analysis prompts in a structured JSON format Prompts must be agnostic to product names and column headers Prompt Injection and Pairing Each row is paired with all prompts Combined into a single dataset for row-by-row LLM evaluation First Iteration of Analysis An LLM answers all injected prompts row-by-row Output is parsed and transformed into structured fields Semantic Merging and Refinement Merged lists of values from all rows AI clusters synonyms and regenerates improved prompt definitions Second Iteration of Analysis The refined prompts are used to re-analyze each row A new structured output per row is generated and merged into one object Summarization and Visualization AI generates summaries per dimension (e.g., sentiment) QuickChart visualizations are created and URL-encoded Cross-dimensional insights and a global narrative are generated Final Report Generation and Emailing A final HTML report is generated Sent to the specified email using Gmail node --- Example Results Customization Guide Modify Data Source Change the Google Sheet ID or sheet tab Add filters for specific time periods or product names Adjust Prompt Definitions Refine the initial prompt agent instruction to tailor the type of analysis Swap LLM Models Replace DeepSeek with OpenAI or another LLM via LangChain nodes Visual Styling Customize QuickChart configurations to adjust chart types, colors, legends Report Format Update the final HTML prompt to reflect brand design or restructure sections Add Report Destinations Replace Gmail with Google Drive upload, Notion page creation, or Slack post --- This end-to-end AI-powered social listening workflow enables scalable, repeatable, and customizable insights generation from unstructured customer feedback.

hippolyte-huBy hippolyte-hu
1011

PostgreSQL conversational agent with Claude & DeepSeek (Multi-KPI, Secure)

๐Ÿง  Conversational PostgreSQL Agent Enable AI-driven conversations with your PostgreSQL database using a secure and visual-free agent powered by n8nโ€™s Model Context Protocol (MCP). This template allows users to ask multiple KPIs in a single message, returning consolidated insights โ€” more efficient than the original Conversing with Data template. --- ๐Ÿš€ Why This Template Unlike the Conversing with Data workflow, which handles one KPI per message, this version: โœ… Supports multi-KPI questions โœ… Returns structured, human-readable reports โœ… Uses fewer AI calls, making it faster and cheaper โœ… Avoids raw SQL execution for enhanced security ๐Ÿ’ฒ Estimated cost per full multi-request run: ~$0.01 This template is optimized for efficiency. Each message can return 2โ€“4 KPIs (You can change the MaxIteration of the Agent to make it more, it is currently set up at 30 iterations) using a single Claude 3.5 Haiku session and DeepSeek-based SQL generation โ€” balancing speed, reasoning, and affordability. --- ๐Ÿ’ฌ Sample Use Case User: โ€œCan you show product performance, revenue trends, and top 5 customers?โ€ Agent: Uses ListTables and GetTableSchema Generates three SQL queries using getqueryand_data Returns: ๐Ÿ“Š Product Performance High-Waist Jeans โ€” 10 units, $1,027 revenue Denim Jacket โ€” 10 units, $783 revenue ๐Ÿ“ˆ Sales Trends Peak Month: January 2024 โ€” 32 units, $2,378 Average Monthly Units: 10โ€“16 ๐Ÿง Customer Insights Bob Brown โ€” $1,520 spent Diana Wilson โ€” $925 spent All from one natural prompt. --- ๐Ÿ–ผ๏ธ Real-World Interaction Screenshot --- ๐Ÿงฐ Whatโ€™s Inside | Node | Purpose | |----------------------------|-----------------------------------------------------------| | MCP Server Trigger | Receives user queries via /mcp/... | | AI Agent + Memory | Understands and plans multi-step queries | | Think Tool | Breaks down the userโ€™s question into structured goals | | getqueryand_data | Generates SQL securely from natural language | | ListTables, GetSchema | AI tools to explore DB safely | | Read/Insert/Update Tools | Execute structured operations (never raw SQL) | | checkdatabase Subflow | Validates SQL, formats response as clean text | --- ๐Ÿค– Model Selection Recommendations This template uses two types of models, selected for cost-performance balance and role alignment: Claude 3.5 Haiku (Anthropic) โ€“ for the MCP Agent The main conversational agent uses Claude 3.5 Haiku, ideal for MCP because it was built by Anthropic โ€” the creators of the MCP standard. Itโ€™s fast, affordable, and performs excellently in tool-calling and reasoning tasks. DeepSeek โ€“ for the SQL subworkflow The subworkflow that turns natural language into SQL uses DeepSeek. Itโ€™s one of the most affordable and performant models available today for structured outputs like SQL, making it a perfect fit for utility logic. โœ… This setup provides top-tier reasoning + low-cost execution. --- ๐Ÿ” Security Benefits No raw SQL accepted from the user or LLM All queries are parameterized Schema is dynamically retrieved Final output is clean, safe, and human-readable --- ๐Ÿงช Try a Prompt > โ€œShow me the top 5 products by units sold and revenue, total monthly sales trend, and top 5 customers by spending.โ€ In one message, the agent will: Generate and run multiple queries Use the schema to validate logic Return a single, comprehensive answer --- ๐Ÿ›  How to Use ๐Ÿ“ฅ Upload both workflow files into your n8n instance: BuildyourownPostgreSQLMCPserverNovisuals.json checkdatabase.json ๐Ÿ” Set up PostgreSQL credentials (e.g. โ€œPostgres account 3โ€) ๐Ÿง  Confirm model setup: Claude 3.5 Haiku for the main agent DeepSeek for the subflow ๐ŸŒ Use the /mcp/... URL from the MCP Server Trigger to connect your frontend or chatbot ๐Ÿ—ฃ Ask questions naturally โ€” the agent takes care of planning, querying, and formatting --- ๐Ÿ”„ Customization Ideas Swap Claude or DeepSeek for OpenAI, Mistral, Gemini, etc. Export insights to Slack, Notion, or Google Sheets Add Switch nodes to control access to specific tables Integrate with any front-end app, internal dashboard, or bot --- ๐Ÿ“ฆ What's Included BuildyourownPostgreSQLMCPserverNovisuals.json โ€“ MCP agent logic checkdatabase.json โ€“ SQL generation and formatting utility workflow ๐Ÿ“ These must be uploaded into your n8n workspace for the template to function. --- ๐Ÿ“Š Comparison: Conversing with Data vs This Workflow | Feature | Conversing with Data | This Workflow | |------------------------------|---------------------------|---------------------------------| | Handles multi-KPI questions | โŒ No | โœ… Yes | | Secure query execution | โœ… Yes | โœ… Yes | | Structured response | โš ๏ธ JSON / raw | โœ… Clean natural language | | Cost-efficiency | โš ๏ธ More calls | โœ… Optimized with fewer calls | | Endpoint support | โŒ Manual interaction | โœ… MCP-ready (/mcp/...) | ๐Ÿ”— Prefer something more lightweight and cost-sensitive? Try the original Conversing with Data template (single KPI + chart support): Conversing with Data: Transforming Text into SQL Queries and Visual Curves > I used this version for over 3 months and only spent $0.80 total, making it a great entry point if you're just getting started or on a limited budget. --- ๐Ÿ“š More from the Same Creator Looking for a different kind of AI reporting workflow? Explore: Customer Feedback Analysis with AI, QuickChart & HTML Report Generator โ†’ Automatically analyze customer input and generate full reports with insights and charts. Customer Feedback Analysis with AI, QuickChart & HTML Report Generator

hippolyte-huBy hippolyte-hu
977
All templates loaded