Postgres Automation Workflows
165 ready-made Postgres workflows for n8n, Make, Zapier, Activepieces, and Pipedream. Database-driven workflows: query, sync, and react to Postgres data.
Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database
# Telegram AI Assistant with Multi-File Media Group Handling, Smart File Processing & PostgreSQL Integration > **AI-powered Telegram bot for text, voice, video, documents & media** - with database-driven grouping and Telegram-safe formatting. --- ## Description This n8n template creates a **next-generation Telegram AI assistant** capable of handling **text messages, media files, and documents** with advanced processing, PostgreSQL integration, and AI-powered responses. It is designed to **solve Telegram's media group challenge** - when multiple files are sent together, they are stored, processed, and combined into one coherent AI-generated reply. ### Key Features - **Multi-file media group management** with PostgreSQL: - `media_group` - `media_queue` - `chat_histories` - **Document parsing** for CSV, HTML, ICS, JSON, ODS, PDF (with AI fallback), RF, X, XML, and spreadsheets. - **Voice & video transcription** for AI analysis. - **Image, audio, and video description** for richer AI context. - **Telegram-safe MarkdownV2 formatting** with auto-splitting for messages over 4096 chars. - **Error fallback** for unsupported file types. --- ## Acknowledgment A huge thank you to **Ezema Gingsley Chibuzo** for the inspiration of the first version of this workflow: [Create a Multi-Modal Telegram Support Bot with GPT-4 and Supabase RAG](https://n8n.io/workflows/5589-create-a-multi-modal-telegram-support-bot-with-gpt-4-and-supabase-rag/) Your pioneering work laid the foundation for this improved, **database-powered multi-modal assistant**. --- ## Tags `telegram` `ai-assistant` `postgresql` `multi-file` `media-group` `file-processing` `voice-transcription` `document-parser` `pdf-extraction` `markdown-formatting` `n8n-template` --- ## Use Case Use this template if you need an AI-powered Telegram bot that can: - Handle **multiple files sent in a single message** (albums, multiple PDFs, etc.). - Extract & analyze **content from many file formats**. - Transcribe **voice and video messages**. - Maintain **chat memory** for contextual AI answers. - Avoid **Telegram formatting errors** and length limit issues. This workflow automates the full chain: **Receive → Process → AI Analysis → Telegram-safe Reply**. --- ## Example User Interactions - **Multiple PDFs with a caption** → AI extracts and summarizes all PDFs in one combined reply. - **Voice message** → AI transcribes and replies with a contextual answer. - **CSV or spreadsheet file** → AI parses and summarizes the data. - **Multiple images** → AI describes each image and replies in a single message. --- ## Required Credentials - **Telegram Bot API** (Bot Token) - **PostgreSQL** (Connection credentials) - **AI Provider API** (OpenAI, Google Gemini, or compatible LLM) --- ## Setup Instructions 1. **Create the PostgreSQL tables** (Gray section SQL): - `media_group` - `media_queue` - `chat_histories` 2. Configure the **Telegram Trigger** with your bot token. 3. Connect your **AI provider** credentials. 4. Set up **PostgreSQL** credentials in the database nodes. 5. Deploy the workflow in n8n. 6. Start sending messages and files to your bot. --- ## Extra Notes - **Green section** ensures only one trigger per media group. - **Yellow section** guarantees captions and files are stored in the correct sequence. - **Purple section** formats AI output to be Telegram-safe and split if needed. - AI prompt is **not fixed**, allowing full customization. --- ## Need Assistance? If you'd like help customizing or extending this workflow, feel free to reach out: - Email: [johnsilva11031@gmail.com](mailto:johnsilva11031@gmail.com) - LinkedIn: [John Alejandro Silva Rodríguez](https://www.linkedin.com/in/john-alejandro-silva-rodriguez-48093526b/)
n8n$24.99Interactive Chat with PostgreSQL Using AI
Enable seamless interaction with your PostgreSQL database through natural language queries using AI. This workflow leverages n8n's chat interface and OpenAI to process and execute SQL queries, providing users with relevant data insights.
n8n$9.99Query PostgreSQL Database with Natural Language using GPT-4-mini
## This Database SQL Query Agent converts natural language into SQL queries to get results Turn your PostgreSQL database into a conversational AI agent! Ask questions in plain English and get instant data results without writing SQL. ## What It Does - **Natural Language Queries**: Show laptops under $500 in stock — Automatic SQL generation - **Smart Column Mapping**: Understands your terms and maps them to actual database columns - **Conversational Memory**: Maintains context across multiple questions - **Universal Compatibility**: Works with any PostgreSQL table structure ## Perfect For - Business analysts querying data without SQL knowledge - Customer support finding information quickly - Product managers analyzing inventory/sales data - Anyone who needs database insights fast ## Quick Setup ### Step 1: Prerequisites - n8n instance (cloud/self-hosted) - PostgreSQL database with read access - OpenAI API key/You can use other LLM as well ### Step 2: Import & Configure 1. Import this workflow template into n8n 2. **Add Credentials**: - OpenAI API: Add your API key - PostgreSQL: Configure database connection 3. **Set Table Name**: Edit Set Table Name node — Replace `table_name` with your actual table 4. **Test Connection**: Ensure your database user has SELECT permissions ### Step 3: Deploy & Use 1. Start the workflow 2. Open the chat interface 3. Ask questions like: - Show all active users - Find orders from last month over $100 - List products with low inventory ## Configuration Details ### Required Settings - **Table Name**: Update in Set Table Name node - **Database Schema**: Default is public (modify SQL if different) - **Result Limit**: Default 50 rows (adjustable in system prompt) ### Optional Customizations - **Multi-table Support**: Modify system prompt and add table selection logic - **Custom Filters**: Add business rules to restrict data access - **Output Format**: Customize response formatting in the agent prompt ## Example Queries ### E-commerce Show me all electronics under $200 that are in stock ### HR Database List employees hired in 2024 with salary over 70k ### Customer Data Find VIP customers from California with recent orders ## Security Features - **Read-only Operations**: Only SELECT queries allowed - **SQL Injection Prevention**: Parameterized queries and validation - **Result Limits**: Prevents overwhelming queries - **Safe Schema Discovery**: Uses information_schema tables ## How It Works 1. **Schema Discovery**: Agent fetches table structure and column info 2. **Query Planning**: Maps natural language to database columns 3. **SQL Generation**: Creates safe, optimized queries 4. **Result Formatting**: Returns clean, user-friendly data ## Quick Troubleshooting - **No Results**: Check table name and ensure data exists - **Permission Error**: Verify database user has SELECT access - **Connection Failed**: Confirm PostgreSQL credentials and network access - **Unexpected Results**: Try more specific queries with exact column names ## Use Cases - **Inventory Management**: Show low-stock items by category - **Sales Analysis**: Top 10 products by revenue this quarter - **Customer Support**: Find customer orders with status pending - **Data Exploration**: What are the unique product categories? ## Advanced Tips - **Performance**: Add database indexes on frequently queried columns - **Customization**: Modify the system prompt for domain-specific terminology - **Scaling**: Use read replicas for high-query volumes - **Integration**: Connect to Slack/Teams for team-wide data access --- **Tags**: AI, PostgreSQL, Natural Language, SQL, Business Intelligence, LangChain, Database Query **Difficulty**: Beginner to Intermediate **Setup Time**: 10-15 minutes
n8n$9.99Intelligent AI-Powered PostgreSQL Query Assistant with Dual-Agent Architecture
Leverage natural language processing to interact with your PostgreSQL database using a dual-agent AI system. This workflow ensures safe and efficient query execution, ideal for commercial applications.
n8n$14.99Automate Restaurant Call Handling and Table Booking with VAPI and PostgreSQL
This workflow automates restaurant call handling by using VAPI to manage incoming calls and PostgreSQL to check and book table availability, providing a seamless virtual receptionist experience.
n8n$9.99Automate Document Data Extraction and Export with AI and PostgreSQL
Streamline the extraction of structured data from various document types using AI, and export the results to a PostgreSQL database or CSV file.
n8n$9.99"Multi-AI Agent Chatbot for PostgreSQL/Supabase DB and QuickCharts + Cool Router"
# Multi-AI Agent Chatbot for Postgres/Supabase Databases and QuickChart Generation ## Who is this for? This workflow is ideal for **data analysts**, **developers**, and **business intelligence teams** who need an AI-powered chatbot to query Postgres/Supabase databases and generate dynamic charts for data visualization. ## What problem does this solve? It simplifies data exploration by combining conversational AI with database querying and chart generation. Users can interact with their database using natural language, retrieve insights, and visualize data without manual SQL queries or chart configuration. ## What this workflow does 1. **AI-Powered Chat Interface**: - Accepts natural language prompts to query databases or generate charts. - Routes user requests through a tool agent system to determine the appropriate action (query or chart). 2. **Database Querying**: - Executes SQL queries on Postgres/Supabase databases based on user input. - Retrieves schema information, table definitions, and specific data records. 3. **Dynamic Chart Generation**: - Uses QuickChart to create bar charts, line charts, or other visualizations from database records. - Outputs a shareable chart URL or JSON configuration for further customization. 4. **Memory Integration**: - Maintains chat history using Postgres memory nodes, enabling context-aware interactions. Workflow diagram showcasing AI agents, database querying, and chart generation paths. ## Setup 1. **Prerequisites**: - A Postgres-compatible database (e.g., Supabase). - API credentials for OpenAI. 2. **Configuration Steps**: - Add your database connection credentials in the Postgres nodes. - Set up OpenAI credentials for GPT-4-mini in the language model nodes. - Adjust the QuickChart schema in the QuickChart Object Schema node to fit your use case. 3. **Testing**: - Trigger the chat workflow via the "When chat message received" node. - Test with prompts like "Generate a bar chart of sales data" or "Show me all users in the database." ## How to customize this workflow - **Modify AI Prompts** - **Add Chart Types** - **Integrate Other Tools**
n8n$24.99Build a Secure Document Q&A System with Llama3, Postgres, Qdrant, and Google Drive
Create a private, on-premises AI assistant that leverages your documents for intelligent Q&A. This workflow integrates Google Drive, Llama3, Postgres, and Qdrant to ensure data privacy while providing robust AI capabilities.
n8n$14.99Automate Restaurant Bookings and Orders with Voice AI and PostgreSQL
This workflow enables restaurants to automate table reservations, food orders, and information requests using voice AI technology integrated with VAPI and PostgreSQL.
n8n$9.99Build an Interactive Slack AI Chatbot with OpenRouter and Postgres
Create a Slack AI chatbot that supports multiple chat threads, a thinking UI, and chat history storage using OpenRouter and Postgres.
n8n$9.99Automate WhatsApp Lead Nurturing with Personalized Messages Using Postgres and Gallabox
This n8n workflow automates the process of nurturing unqualified leads by sending personalized WhatsApp messages via Gallabox API, fetching data from Postgres, and logging activities.
n8n$9.99Deploy a Custom AI Chatbot with Supabase and Postgres Memory
Create a versatile AI chatbot that leverages Supabase for knowledge storage and Postgres for conversation memory, suitable for various platforms like websites and Slack.
n8n$4.99SMS Alerts Based on Database Queries with Twilio and Postgres
This workflow automates the process of sending SMS alerts using Twilio based on data retrieved from a Postgres database. It begins with a scheduled trigger via a Cron node that executes a query to check for sensor readings that exceed a specified ...
n8n$4.99Create a Secure PostgreSQL MCP Server with n8n
Set up a PostgreSQL MCP server using n8n to manage database operations securely, supporting select, insert, and update queries.
n8n$9.99Email to Notion Knowledge Base with IMAP, Postgres Dedup, and Telegram Alert
Please correct the following description: Filter incoming emails via IMAP, extract & clean the body into plain text, normalize (title/slug/snippet/date/from/url), check for duplicates in Postgres, store as a row in a Notion database, then send a Telegram notification. Perfect for building a knowledge base or inbox triage automation without duplicate noise. **Key Features** - IMAP polling (Only UNSEEN). - Extract & clean HTML to plain text. - Normalization: title, snippet, body text, slug, messageId, sentAt, fromAddress, sourceUrl. - Deduplication via Postgres (SELECT EXISTS). - Create page in Notion database (property mapping). - Telegram success notification. - Tags: email, imap, notion, postgres, deduplication, telegram, automation, knowledge-base **Prerequisites** - IMAP access (Gmail/Outlook/Custom). - Gmail: enable IMAP + App Password if using 2FA. - Notion Integration Token & Database ID (database must be shared with the integration). - PostgreSQL accessible from n8n. - (Optional) Telegram Bot Token & Chat ID.
n8n$14.99Automate SQL Queries on Google Sheets Data Using AI and PostgreSQL
This n8n workflow enables you to query structured data from Google Sheets or CSV files using AI-generated SQL, storing and processing it efficiently in PostgreSQL.
n8n$14.99Enable AI-Powered Conversational Access to Supabase/PostgreSQL Databases
This workflow allows users to interact with a Supabase/PostgreSQL database using an AI agent, facilitating dynamic SQL query generation and data analysis without manual SQL scripting.
n8n$9.99Export PostgreSQL Table Data to CSV Format
Effortlessly convert data from a PostgreSQL table into a CSV file for easy data sharing and analysis.
n8n$4.99Automate SEO Article Creation and Publishing to WordPress with GPT-4 and PostgreSQL
This workflow automates the generation and publication of SEO-optimized articles on WordPress using GPT-4 and PostgreSQL for category management. It selects the least-used category, generates content, creates a placeholder image, and publishes the post with the correct category and featured image.
n8n$24.99Automate Daily Postgres Table Backups to GitHub as CSV Files
This workflow automates the daily backup of all public Postgres tables to a GitHub repository in CSV format, ensuring your data is consistently up-to-date and version-controlled.
n8n$14.99Automate Expense Tracking and Reporting via WhatsApp with AI and PostgreSQL
Streamline your personal finance management by using WhatsApp to log expenses, powered by AI for natural language processing and PostgreSQL for data storage and reporting.
n8n$19.99Intelligent Chatbot with OpenAI, PostgreSQL Memory, and API Integration
This workflow creates an intelligent chatbot using OpenAI, integrated with PostgreSQL for memory retention and API calling capabilities, designed to enhance customer interactions via WhatsApp Business.
n8n$9.99Manage Appian Tasks with Ollama Gwen LLM and Postgres Memory
This workflow is a simple example of using n8n as an AI chat interface into Appian. It connects a local LLM, persistent memory, and API tools to demonstrate how an agent can interact with Appian tasks. What this workflow does: - **Chat interface**: Accepts user input through a webhook or chat trigger. - **Local LLM (Ollama)**: Runs on qwen2.5:7b with an 8k context window. - **Conversation memory**: Stores chat history in Postgres, keyed by sessionId. - **AI Agent node**: Handles reasoning, follows system rules (helpful assistant persona, date formatting, iteration limits), and decides when to call tools. - **Appian integration tools**: - **List tasks**: Fetches a user's tasks from Appian. - **Create task**: Submits data for a new task in Appian (title, description, hours, cost). How it works: 1. A user sends a chat message. 2. The workflow normalizes fields such as text, username, and sessionId. 3. The AI Agent processes the message using Ollama and Postgres memory. 4. If the user asks about tasks, the agent calls the Appian APIs. 5. The result, either a task list or confirmation of a new task, is returned through the webhook. Why this is useful: - Demonstrates how to build a basic Appian connector in n8n with an AI chat front end. - Shows how an LLM can decide when to call Appian APIs to list or create tasks. - Provides a pattern that can be extended with more Appian endpoints, different models, or custom system prompts.
n8n$9.99PostgreSQL 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 `Listables` and `GetableSchema` - Generates three SQL queries using `get_query_and_data` - Returns: **Product Performance** 1. High-Waist Jeans - 10 units, $1,027 revenue 2. Denim Jacket - 10 units, $783 revenue **Sales Trends** - Peak Month: January 2024 - 32 units, $2,378 - Average Monthly Units: 10-16 **Customer Insights** 1. Bob Brown - $1,520 spent 2. 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 | | Listables, 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 1. Upload both workflow files into your n8n instance: - `Build_your_own_PostgreSQL_MCP_server_No_visuals_.json` - `checkdatabase.json` 2. Set up PostgreSQL credentials (e.g., "Postgres account 3") 3. Confirm model setup: - Claude 3.5 Haiku for the main agent - DeepSeek for the subflow 4. Use the `/mcp/...` URL from the MCP Server Trigger to connect your frontend or chatbot 5. 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 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 |
n8n$14.99
More integrations
Need a custom Postgres workflow?
Our automation experts build tailored Postgres integrations for your exact stack.
Request a Custom Workflow