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
ListTablesandGetTableSchema - Generates three SQL queries using
get_query_and_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 |
| get_query_and_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:
1. 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.
2. 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:
Build_your_own_PostgreSQL_MCP_server_No_visuals_.jsoncheckdatabase.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
Build_your_own_PostgreSQL_MCP_server_No_visuals_.json– MCP agent logiccheckdatabase.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
PostgreSQL Conversational Agent with Claude/Deepseek (Multi-KPI, Secure)
This n8n workflow creates a robust conversational AI agent capable of interacting with a PostgreSQL database. It leverages an AI agent (powered by Anthropic's Claude or Deepseek models) to interpret user queries, execute SQL commands against a PostgreSQL database, and provide intelligent responses, all while maintaining conversational memory. The workflow also incorporates a secure Model Context Protocol (MCP) for inter-workflow communication, allowing for advanced, multi-workflow AI interactions.
What it does
This workflow orchestrates a sophisticated AI agent to perform the following steps:
- Listens for Chat Messages: Initiates the workflow upon receiving a chat message, likely from a user interacting with the AI agent.
- Manages Conversational Memory: Utilizes a simple memory buffer to maintain context throughout the conversation, allowing the AI to recall previous interactions.
- Processes User Input with an AI Agent: An AI Agent node (configured with an Anthropic Chat Model) interprets the user's query and decides on the appropriate action.
- Provides "Think" Capability: Includes a "Think" tool, allowing the AI agent to articulate its thought process before taking action, enhancing transparency and debugging.
- Interacts with PostgreSQL Database: Employs a PostgreSQL node as a tool for the AI agent to execute SQL queries and retrieve data from the database.
- Enables Secure Inter-Workflow Communication: Utilizes an "MCP Client Tool" to securely call other n8n workflows, enabling complex, multi-workflow AI solutions via the Model Context Protocol.
- Handles External Workflow Triggers: The "When Executed by Another Workflow" trigger allows this workflow to be called as a sub-workflow, supporting modular AI agent designs.
- Acts as an MCP Server: The "MCP Server Trigger" allows this workflow to receive requests from other MCP clients, facilitating a distributed AI architecture.
- Conditional Logic for Workflow Execution: A "Switch" node is present, indicating potential branching logic based on conditions, though the specific conditions are not defined in the provided JSON. This suggests the workflow can adapt its behavior based on input or internal state.
- Provides Informational Notes: Includes a "Sticky Note" for documentation or temporary notes within the workflow.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running n8n instance to import and execute the workflow.
- PostgreSQL Database: Access to a PostgreSQL database with appropriate credentials.
- Anthropic API Key: Credentials for Anthropic's Claude or Deepseek chat models (or another compatible LLM configured within the AI Agent node).
- n8n Credentials: Configured credentials for PostgreSQL and Anthropic within your n8n instance.
- Understanding of Langchain Concepts: Familiarity with AI agents, tools, and memory concepts in Langchain is beneficial.
- Model Context Protocol (MCP): If utilizing the MCP client/server nodes, ensure you understand how to configure and deploy workflows that communicate via MCP.
Setup/Usage
- Import the Workflow: Download the provided JSON and import it into your n8n instance.
- Configure Credentials:
- Set up your PostgreSQL credentials in n8n.
- Set up your Anthropic (or other LLM) API key credentials in n8n.
- Configure Nodes:
- Postgres Node: Configure the PostgreSQL node with your database connection details and any specific query settings if not intended for dynamic AI agent use.
- Anthropic Chat Model Node: Ensure the correct Anthropic model (e.g., Claude, Deepseek) is selected and configured with your credentials.
- AI Agent Node: Review the agent's prompt, tools, and memory settings. If you intend for the agent to use the PostgreSQL node, ensure it's added as a tool.
- Call n8n Workflow Tool: If using this tool, specify the workflow ID of the n8n workflow it should execute.
- MCP Client/Server Nodes: If leveraging MCP, configure the client to point to the server workflow and vice-versa, ensuring secure communication.
- Activate the Workflow: Once configured, activate the workflow. It will then listen for incoming chat messages to trigger the AI agent.
- Interact with the Agent: Send chat messages to the configured Chat Trigger endpoint to begin interacting with your conversational agent.
Related Templates
AI-powered code review with linting, red-marked corrections in Google Sheets & Slack
Advanced Code Review Automation (AI + Lint + Slack) Who’s it for For software engineers, QA teams, and tech leads who want to automate intelligent code reviews with both AI-driven suggestions and rule-based linting — all managed in Google Sheets with instant Slack summaries. How it works This workflow performs a two-layer review system: Lint Check: Runs a lightweight static analysis to find common issues (e.g., use of var, console.log, unbalanced braces). AI Review: Sends valid code to Gemini AI, which provides human-like review feedback with severity classification (Critical, Major, Minor) and visual highlights (red/orange tags). Formatter: Combines lint and AI results, calculating an overall score (0–10). Aggregator: Summarizes results for quick comparison. Google Sheets Writer: Appends results to your review log. Slack Notification: Posts a concise summary (e.g., number of issues and average score) to your team’s channel. How to set up Connect Google Sheets and Slack credentials in n8n. Replace placeholders (<YOURSPREADSHEETID>, <YOURSHEETGIDORNAME>, <YOURSLACKCHANNEL_ID>). Adjust the AI review prompt or lint rules as needed. Activate the workflow — reviews will start automatically whenever new code is added to the sheet. Requirements Google Sheets and Slack integrations enabled A configured AI node (Gemini, OpenAI, or compatible) Proper permissions to write to your target Google Sheet How to customize Add more linting rules (naming conventions, spacing, forbidden APIs) Extend the AI prompt for project-specific guidelines Customize the Slack message formatting Export analytics to a dashboard (e.g., Notion or Data Studio) Why it’s valuable This workflow brings realistic, team-oriented AI-assisted code review to n8n — combining the speed of automated linting with the nuance of human-style feedback. It saves time, improves code quality, and keeps your team’s review history transparent and centralized.
Automate RSS to social media pipeline with AI, Airtable & GetLate for multiple platforms
Overview Automates your complete social media content pipeline: sources articles from Wallabag RSS, generates platform-specific posts with AI, creates contextual images, and publishes via GetLate API. Built with 63 nodes across two workflows to handle LinkedIn, Instagram, and Bluesky—with easy expansion to more platforms. Ideal for: Content marketers, solo creators, agencies, and community managers maintaining a consistent multi-platform presence with minimal manual effort. How It Works Two-Workflow Architecture: Content Aggregation Workflow Monitors Wallabag RSS feeds for tagged articles (to-share-linkedin, to-share-instagram, etc.) Extracts and converts content from HTML to Markdown Stores structured data in Airtable with platform assignment AI Generation & Publishing Workflow Scheduled trigger queries Airtable for unpublished content Routes to platform-specific sub-workflows (LinkedIn, Instagram, Bluesky) LLM generates optimized post text and image prompts based on custom brand parameters Optionally generates AI images and hosts them on Imgbb CDN Publishes via GetLate API (immediate or draft mode) Updates Airtable with publication status and metadata Key Features: Tag-based content routing using Wallabag's native system Swappable AI providers (Groq, OpenAI, Anthropic) Platform-specific optimization (tone, length, hashtags, CTAs) Modular design—duplicate sub-workflows to add new platforms in \~30 minutes Centralized Airtable tracking with 17 data points per post Set Up Steps Setup time: \~45-60 minutes for initial configuration Create accounts and get API keys (\~15 min) Wallabag (with RSS feeds enabled) GetLate (social media publishing) Airtable (create base with provided schema—see sticky notes) LLM provider (Groq, OpenAI, or Anthropic) Image service (Hugging Face, Fal.ai, or Stability AI) Imgbb (image hosting) Configure n8n credentials (\~10 min) Add all API keys in n8n's credential manager Detailed credential setup instructions in workflow sticky notes Set up Airtable database (\~10 min) Create "RSS Feed - Content Store" base Add 19 required fields (schema provided in workflow sticky notes) Get Airtable base ID and API key Customize brand prompts (\~15 min) Edit "Set Custom SMCG Prompt" node for each platform Define brand voice, tone, goals, audience, and image preferences Platform-specific examples provided in sticky notes Configure platform settings (\~10 min) Set GetLate account IDs for each platform Enable/disable image generation per platform Choose immediate publish vs. draft mode Adjust schedule trigger frequency Test and deploy Tag test articles in Wallabag Monitor the first few executions in draft mode Activate workflows when satisfied with the output Important: This is a proof-of-concept template. Test thoroughly with draft mode before production use. Detailed setup instructions, troubleshooting tips, and customization guidance are in the workflow's sticky notes. Technical Details 63 nodes: 9 Airtable operations, 8 HTTP requests, 7 code nodes, 3 LangChain LLM chains, 3 RSS triggers, 3 GetLate publishers Supports: Multiple LLM providers, multiple image generation services, unlimited platforms via modular architecture Tracking: 17 metadata fields per post, including publish status, applied parameters, character counts, hashtags, image URLs Prerequisites n8n instance (self-hosted or cloud) Accounts: Wallabag, GetLate, Airtable, LLM provider, image generation service, Imgbb Basic understanding of n8n workflows and credential configuration Time to customize prompts for your brand voice Detailed documentation, Airtable schema, prompt examples, and troubleshooting guides are in the workflow's sticky notes. Category Tags social-media-automation, ai-content-generation, rss-to-social, multi-platform-posting, getlate-api, airtable-database, langchain, workflow-automation, content-marketing
Ai website scraper & company intelligence
AI Website Scraper & Company Intelligence Description This workflow automates the process of transforming any website URL into a structured, intelligent company profile. It's triggered by a form, allowing a user to submit a website and choose between a "basic" or "deep" scrape. The workflow extracts key information (mission, services, contacts, SEO keywords), stores it in a structured Supabase database, and archives a full JSON backup to Google Drive. It also features a secondary AI agent that automatically finds and saves competitors for each company, building a rich, interconnected database of company intelligence. --- Quick Implementation Steps Import the Workflow: Import the provided JSON file into your n8n instance. Install Custom Community Node: You must install the community node from: https://www.npmjs.com/package/n8n-nodes-crawl-and-scrape FIRECRAWL N8N Documentation https://docs.firecrawl.dev/developer-guides/workflow-automation/n8n Install Additional Nodes: n8n-nodes-crawl-and-scrape and n8n-nodes-mcp fire crawl mcp . Set up Credentials: Create credentials in n8n for FIRE CRAWL API,Supabase, Mistral AI, and Google Drive. Configure API Key (CRITICAL): Open the Web Search tool node. Go to Parameters → Headers and replace the hardcoded Tavily AI API key with your own. Configure Supabase Nodes: Assign your Supabase credential to all Supabase nodes. Ensure table names (e.g., companies, competitors) match your schema. Configure Google Drive Nodes: Assign your Google Drive credential to the Google Drive2 and save to Google Drive1 nodes. Select the correct Folder ID. Activate Workflow: Turn on the workflow and open the Webhook URL in the “On form submission” node to access the form. --- What It Does Form Trigger Captures user input: “Website URL” and “Scraping Type” (basic or deep). Scraping Router A Switch node routes the flow: Deep Scraping → AI-based MCP Firecrawler agent. Basic Scraping → Crawlee node. Deep Scraping (Firecrawl AI Agent) Uses Firecrawl and Tavily Web Search. Extracts a detailed JSON profile: mission, services, contacts, SEO keywords, etc. Basic Scraping (Crawlee) Uses Crawl and Scrape node to collect raw text. A Mistral-based AI extractor structures the data into JSON. Data Storage Stores structured data in Supabase tables (companies, company_basicprofiles). Archives a full JSON backup to Google Drive. Automated Competitor Analysis Runs after a deep scrape. Uses Tavily web search to find competitors (e.g., from Crunchbase). Saves competitor data to Supabase, linked by company_id. --- Who's It For Sales & Marketing Teams: Enrich leads with deep company info. Market Researchers: Build structured, searchable company databases. B2B Data Providers: Automate company intelligence collection. Developers: Use as a base for RAG or enrichment pipelines. --- Requirements n8n instance (self-hosted or cloud) Supabase Account: With tables like companies, competitors, social_links, etc. Mistral AI API Key Google Drive Credentials Tavily AI API Key (Optional) Custom Nodes: n8n-nodes-crawl-and-scrape --- How It Works Flow Summary Form Trigger: Captures “Website URL” and “Scraping Type”. Switch Node: deep → MCP Firecrawler (AI Agent). basic → Crawl and Scrape node. Scraping & Extraction: Deep path: Firecrawler → JSON structure. Basic path: Crawlee → Mistral extractor → JSON. Storage: Save JSON to Supabase. Archive in Google Drive. Competitor Analysis (Deep Only): Finds competitors via Tavily. Saves to Supabase competitors table. End: Finishes with a No Operation node. --- How To Set Up Import workflow JSON. Install community nodes (especially n8n-nodes-crawl-and-scrape from npm). Configure credentials (Supabase, Mistral AI, Google Drive). Add your Tavily API key. Connect Supabase and Drive nodes properly. Fix disconnected “basic” path if needed. Activate workflow. Test via the webhook form URL. --- How To Customize Change LLMs: Swap Mistral for OpenAI or Claude. Edit Scraper Prompts: Modify system prompts in AI agent nodes. Change Extraction Schema: Update JSON Schema in extractor nodes. Fix Relational Tables: Add Items node before Supabase inserts for arrays (social links, keywords). Enhance Automation: Add email/slack notifications, or replace form trigger with a Google Sheets trigger. --- Add-ons Automated Trigger: Run on new sheet rows. Notifications: Email or Slack alerts after completion. RAG Integration: Use the Supabase database as a chatbot knowledge source. --- Use Case Examples Sales Lead Enrichment: Instantly get company + competitor data from a URL. Market Research: Collect and compare companies in a niche. B2B Database Creation: Build a proprietary company dataset. --- WORKFLOW IMAGE --- Troubleshooting Guide | Issue | Possible Cause | Solution | |-------|----------------|-----------| | Form Trigger 404 | Workflow not active | Activate the workflow | | Web Search Tool fails | Missing Tavily API key | Replace the placeholder key | | FIRECRAWLER / find competitor fails | Missing MCP node | Install n8n-nodes-mcp | | Basic scrape does nothing | Switch node path disconnected | Reconnect “basic” output | | Supabase node error | Wrong table/column names | Match schema exactly | --- Need Help or More Workflows? Want to customize this workflow for your business or integrate it with your existing tools? Our team at Digital Biz Tech can tailor it precisely to your use case from automation logic to AI-powered enhancements. Contact: shilpa.raju@digitalbiz.tech For more such offerings, visit us: https://www.digitalbiz.tech ---