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.
Automate AI Chat Logs Transfer from Postgres to Google Sheets
This n8n workflow automates the retrieval of AI agent chat logs from a Postgres database and exports them to Google Sheets, creating a new sheet for each session. Ideal for teams needing to review and analyze chat logs collaboratively.
n8n$14.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.99Automate Meetup Registration and Live Giveaway with PostgreSQL
This n8n workflow streamlines the registration process for meetup participants and facilitates live giveaway winner selection, integrating seamlessly with a PostgreSQL database.
n8n$9.99Automate CSV Import to PostgreSQL from Local Filesystem
This workflow automates the process of importing CSV files from your local filesystem into a PostgreSQL database, streamlining data management for self-hosted users.
n8n$4.99Email Assistant: Convert Natural Language to SQL Queries with Phi4-mini and PostgreSQL
# Who is this for? **Humans** and **Robots** alike. This workflow can be used as a **Chat trigger**, as well as a **Workflow trigger**. It will take a natural language request, and then generate a `SQL` query. The resulting `query` parameter will contain the query, and a `sqloutput` parameter will contain the results of executing such a query. ## What's the use case? This template is most useful paired with other workflows that extract e-mail information and store it in a structured Postgres table, and use LLMs to understand inquiries about information contained in an e-mail inbox and formulate questions that need answering. Plus, the prompt can be easily adapted to formulate SQL queries over any kind of structured database. ## Privacy and Economics As an LLM provider, I'm using **Ollama** locally, as I consider my e-mail extremely sensitive information. As a model, [`phi4-mini`](https://ollama.com/library/phi4-mini) does an excellent job balancing quality and efficiency. ## Setup Upon running for the first time, this workflow will **automatically** trigger a sub-section to read all tables and extract their schema into a local file. Then, either by **chatting** with the workflow in n8n's interface or by using it as a **sub-workflow**, you will get a `query` and a `sqloutput` response. ## Customizations If you want to work with just one particular table yet keep edits at bay, append a condition to the `List all tables in a database` step, like so: ```sql WHERE table_schema=public AND table_name=my_emails_table_name ``` To repurpose this workflow to work with any other data corpus in a structured database, inspect the `AI Agent` **user** and **system** prompts and edit them accordingly.
n8n$14.99Automate Customer Reservations with WhatsApp and PostgreSQL
Streamline customer reservation management by capturing booking details via WhatsApp and storing them in a PostgreSQL database, reducing manual entry and errors.
n8n$19.99Generate & Test SQL Code with GP/OpenRouter AI and PostgreSQL Sandbox
This is the core AI agent used for [isra36.com](https://isra36.com). Don't trust complex AI-generated SQL queries without double-checking them in a safe environment. That's where isra36 comes in. It automatically creates a test environment with the necessary data, generates code for your task, runs it to double-check for correctness, and handles errors if necessary. If you enable auto-fixing, isra36 will detect and fix issues on its own. If not, it will ask for your permission before making changes during debugging. In the end, you get thoroughly verified code along with full details about the environment it ran in. ## Setup It is an embedded chat for the website, but you can pin input data and run it on your own n8n instance. ### Input data 1. `sessionId`: uuid_v4. **Required** to handle ongoing conversations and to create table names (used as a prefix). 2. `threadId`: string | nullable. If `aiProvider` is **openai**, conversation history is managed on OpenAI's side. This is not needed in the first request—it will start a new conversation. For ongoing conversations, you must provide this value. You can get it from the `OpenAIMainBrain` node output after the first run. If you want to start a new conversation, just leave it as `null`. 3. `apiKey`: string. Your API key for the selected `aiProvider`. 4. `aiProvider`: string. Currently supported values: **openai**, **openrouter**. 5. `model`: string. The AI model key (e.g., `gpt-4.1`, `o3-mini`, or any supported model key from OpenRouter). 6. `autoErrorFixing`: boolean. If `true`, it will automatically fix errors encountered when running code in the environment. If `false`, it will ask for your permission before attempting a fix. 7. `chatInput`: string. The user's prompt or message. 8. `currentDbSchemaWithData`: string. A JSON representation of the database schema with sample data. Used to inform the AI about the current database structure during an ongoing conversation. Please use the `[]` value in the first request. Example string for filled db structure: `{users:[{id:1,name:John Doe,email:john.d@example.com},{id:2,name:Jane Smith,email:jane.s@example.com}],products:[{product_id:101,product_name:Laptop,price:999.99}]}` Make sure to fill in your credentials: 1. Your OpenAI or OpenRouter API key. 2. Access to a local PostgreSQL database for test execution. You can view your generated tables using your preferred PostgreSQL GUI. We recommend **DBeaver**. Alternatively, you can activate the **Deactivated DB Visualization** nodes below. To use them, connect each to the most recent successful **Set** node and manually adjust the output. However, the easiest and most efficient method is to use a GUI. ## Workflow Explanation 1. We store all input values in the `localVariables` node. Please use this node to *get* the necessary data. 2. `OpenAI` has a built-in assistant that manages chat history on their side. For OpenRouter, we handle chat history locally. That's why we use separate nodes like `ifOpenAi` and `isOpenAi`. Note that `if` logic can also be used *inside* nodes. 3. The `AutoErrorFixing` loop will run only a limited number of times, as defined by the `isMaxAutoErrorReached` node. This prevents infinite loops. 4. The `Execute_AI_result` node connects to the PostgreSQL test database used to execute queries. ## Guidance on customization This setup is built for **PostgreSQL**, but it can be adapted to any **programming language**, and the logic can be extended to any **programming framework**. To customize the logic for other programming languages: 1. Change the `instruction` parameter in the `localVariables` node. 2. Replace the `Execute_AI_result` PostgreSQL node with another executable node. For example, you can use the HTTP Request node. 3. Update the `GenerateErrorPrompt` node's `prompt` parameter to generate code specific to your target language or framework. *Any workflows built on top of this must credit the original author and be released under an open-source license.*
n8n$24.99Automate Excel Data Import to PostgreSQL Table
Effortlessly read data from an Excel file and insert it into a PostgreSQL table, streamlining data management processes.
n8n$3.99Chat-Based Financial Analysis of P&L and Balance Sheets with GPT-4 & PostgreSQL
## Who's it for This workflow is designed for **finance teams**, **accountants**, and **data analysts** who want to interact with financial data from **two PostgreSQL databases** - one containing **Profit & Loss** data and another containing **Balance Sheet** data - using natural language chat. It's perfect for those who need **quick, AI-powered insights** with the correct database automatically selected based on the question. --- ## How it works / What it does 1. **Chat Trigger** - Starts the workflow when a chat message is received. 2. **AI Agent** - Processes the user's question and decides: - **Profit & Loss DB** – If the question is about revenue, costs, expenses, or profit. - **Balance Sheet DB** – If the question is about assets, liabilities, or equity. 3. **PostgreSQL Query Nodes** - - **P_L_Reports** queries the `financial_agent_pl_reports` table. - **Balance_Sheets** queries the `financial_agent_balancesheets` table. 4. **AI Model (OpenAI)** - Uses `gpt-4.1-nano` to interpret results and provide an easy-to-read answer. 5. **Memory Buffer** - Keeps recent conversation context for a smoother chat experience. 6. **Table Output** - Always formats the results as a **clean, readable table** with two decimal precision. --- ## How to set up 1. **Prepare Your Databases** - Feed your Profit & Loss and Balance Sheet data into **PostgreSQL**. - Ensure the correct table structures are used: - **financial_agent_pl_reports** – P&L data. - **financial_agent_balancesheets** – Balance Sheet data. 2. **Configure the PostgreSQL Nodes** - Add connection credentials for both databases. - Link **P_L_Reports** and **Balance_Sheets** nodes to the correct tables. 3. **Set Up the AI Agent** - Paste the provided **system message** into the AI Agent node (already configured in your workflow). 4. **Connect the Nodes** - Ensure **Chat Trigger → AI Agent → DB Nodes → AI Model** connections match your workflow. 5. **Deploy** - Save and activate the workflow. - Start sending finance-related queries to test. --- ## Requirements - **n8n** (latest version recommended) - **PostgreSQL databases** with: - `financial_agent_pl_reports` table (P&L data). - `financial_agent_balancesheets` table (Balance Sheet data). - **OpenAI API credentials** with access to `gpt-4.1-nano`. - **Active Webhook/Chat Trigger** for receiving queries. --- ## How to customize - **Expand AI Instructions** - Add more rules in the system message for different data sources or formatting styles. - **Change AI Model** - Switch to a different OpenAI model for faster or more accurate results. - **Add More Databases** - Connect extra financial datasets, e.g., cash flow, sales analytics. - **Enhance Table Styling** - Use Markdown or HTML formatting for richer outputs. - **Refine Query Logic** - Modify filtering logic to better match your reporting needs.
n8n$4.99Create a Humorous Telegram Bot with AI and Postgres
Build a witty Telegram bot using n8n, OpenRouter, and Postgres to deliver jokes, motivational quotes, and playful roasts. This workflow tracks user interactions and provides statistics and leaderboards.
n8n$14.99Automate WhatsApp FAQ Responses with PostgreSQL Integration
Streamline your customer support by automating FAQ responses on WhatsApp using a PostgreSQL database to manage your Q&A content.
n8n$19.99Automate PostgreSQL Queries and Visualizations with AI-Driven Insights
Leverage AI to query your PostgreSQL database, generate visual insights, and update records seamlessly. This workflow integrates natural language processing to provide multi-KPI insights and auto-generated charts.
n8n$14.99Interactive AI Chat with Google Search Console Data via OpenAI and Postgres
This workflow enables interactive communication with your Google Search Console data using an AI agent powered by OpenAI and Postgres. It facilitates natural language queries and retrieves data in a user-friendly chat interface.
n8n$14.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.99Automate GLPI Knowledge Base RAG Pipeline with Google Gemini and PostgreSQL
This workflow automates the creation of a Retrieval-Augmented Generation (RAG) pipeline using GLPI Knowledge Base content. It streamlines data retrieval, transformation, and vector storage, enhancing the efficiency of building AI-powered support agents.
n8n$9.99Automate PostgreSQL & MySQL Management on Linux Servers
This n8n workflow automates the installation, configuration, and management of PostgreSQL and MySQL databases on Linux servers, enabling efficient setup, creation, and deletion of databases with user access in just 10 seconds.
n8n$9.99Chat-Based P&L & Balance Sheet Analysis with GPT-4 & PostgreSQL
Enables natural language chat for financial insights from P&L and Balance Sheet PostgreSQL databases, with AI automatically selecting the right DB and formatting results as tables.
n8n$19.99Personalized Birthday AI Companion with GPT-4 & PostgreSQL
Build a fun AI agent that acts as a birthday companion, tracking preferences, cat adventures in the multiverse, and conversation history via webhook, GPT-4, and PostgreSQL.
n8n$19.99Email to Notion KB: IMAP, Postgres Dedup & Telegram Alert
Automates capturing unseen emails via IMAP, cleans and normalizes content, deduplicates via Postgres, stores in Notion database, and sends Telegram alerts. Ideal for knowledge base building without duplicates.
n8n$14.99Postgres: Create Table and Insert Sample Data
This workflow demonstrates creating a PostgreSQL table and inserting data using n8n's Postgres nodes. Ideal for quick database initialization in automations.
n8n$8.99Import CSV Files from Filesystem to PostgreSQL
Automates reading CSV files from your server's filesystem and importing data into an existing PostgreSQL database table.
n8n$9.99Automate Postgres Database Interactions with Chatbot Integration
This workflow, titled '1144PostgresCodeAutomationTriggered', is designed to facilitate seamless interactions between chatbot interfaces and Postgres databases. By automating the creation of tables and dynamically handling data input, it significan...
n8n$19.29Store WhatsApp/Slack Chat Data in Supabase PostgreSQL
Captures user chat data from WhatsApp or Slack and stores it securely in Supabase PostgreSQL. Perfect for chatbots requiring persistent data storage with easy setup guide.
n8n$12.99
More integrations
Custom AI Systems & Services
Our team of experienced AI builders will help build custom AI systems, workflows, and solutions.
Request Custom Work