Chat with Postgresql Database

👨‍🎤 Setup 1. Add your postgresql and OpenAI credentials. 2. Click Chat button and start asking questions to your database. 3. Activate the workflow and you can make the chat publicly available.

Workflow Structure (7 nodes)
100%
Langchain.chat Trigger
When chat message received
Langchain.agent
AI Agent
Langchain.lm Chat Open Ai
OpenAI Chat Model
Langchain.memory Buffer Window
Chat History
Postgres Tool
Execute SQL Query
Postgres Tool
Get DB Schema and Tables List
Postgres Tool
Get Table Definition
Node Types:
trigger
default
action
Requires credentials

Prerequisites

Required Credentials (2)

OpenAI

Used by: OpenAI Chat Model

Docs

Postgres

Used by: Get Table Definition, Execute SQL Query +1 more

Docs

Complexity

Moderate

Some experience helpful. Multiple integrations or logic.

Setup time: ~25 min
Score: 27/100

When to Use This Workflow

Real-time Response

React instantly when events happen - new orders, form submissions, or API calls.

Zero delay between trigger and action for time-sensitive workflows.

Time Savings

Replace repetitive manual tasks with reliable automation.

Reclaim hours every week for higher-value work.

Error Reduction

Eliminate human error from routine processes with consistent automation.

Improve accuracy and reliability across your workflows.

workflow.json
{
  "id": "eOUewYsEzJmQixI6",
  "meta": {
    "instanceId": "77c4feba8f41570ef06dc76ece9a6ded0f0d44f7f1477a64c2d71a8508c11faa",
    "templateCredsSetupCompleted": true
  },
  "name": "Chat with Postgresql Database",
  "tags": [],
  "nodes": [
    {
      "id": "6501a54f-a68c-452d-b353-d7e871ca3780",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -300,
        -80
      ],
      "webhookId": "cf1de04f-3e38-426c-89f0-3bdb110a5dcf",
      "parameters": {
        "options": {}
...

Workflow Details

Nodes
11
Trigger
Event
Source
awesome
Added
Dec 4, 2025

Need Help?

Check out the official n8n documentation for detailed guides.

Related Workflows

MongoDB Agent

AI Agent powered by OpenAI and MongoDB This flow is designed to work as an AI autonomous agent that can get chat message...

Lmchatopenai
Mongodbtool
Memorybufferwindow
Chat
8 nodesEvent
Curated

Generate SQL queries from schema only - AI-powered

Run this part only once This section: loads a list of all tables from the database hosted on [db4free](https://db4free....

Lmchatopenai
Memorybufferwindow
Mysql
Readwritefile
29 nodesEvent
Curated

SQL agent with memory

Run this part only once This section: downloads the example zip file from https://www.sqlitetutorial.net/sqlite-sample-...

Memorybufferwindow
Lmchatopenai
Http-request
Compression
13 nodesEvent
Curated

Chat with GitHub OpenAPI Specification using RAG (Pinecone and OpenAI)

Indexing content in the vector database This part of the workflow is responsible for extracting content, generating embe...

Http-request
Vectorstorepinecone
Documentdefaultdataloader
Textsplitterrecursivecharactertextsplitter
17 nodesEvent
Curated

Build a Tax Code Assistant with Qdrant, Mistral.ai and OpenAI

Step 1. Download the Tax Code PDF [Read more about handling Zip Files](https://docs.n8n.io/integrations/builtin/core-nod...

Embeddingsmistralcloud
Documentdefaultdataloader
Textsplitterrecursivecharactertextsplitter
Http-request
38 nodesEvent
Curated

Building RAG Chatbot for Movie Recommendations with Qdrant and Open AI

Tool, calling Qdrant's recommendation API based on user's request, transformed by AI agent

Github
Embeddingsopenai
Documentdefaultdataloader
Textsplittertokensplitter
27 nodesEvent
Curated