AutomationFlowsAI & RAG › RAG Chat Agent with Postgres and OpenAI

RAG Chat Agent with Postgres and OpenAI

Original n8n title: RAG Chat Agent

RAG Chat Agent. Uses chatTrigger, postgres, openAi. Chat trigger; 3 nodes.

Chat trigger trigger★☆☆☆☆ complexityAI-powered3 nodesChat TriggerPostgresOpenAI
AI & RAG Trigger: Chat trigger Nodes: 3 Complexity: ★☆☆☆☆ AI nodes: yes Added:

This workflow follows the Chat Trigger → OpenAI recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "RAG Chat Agent",
  "nodes": [
    {
      "parameters": {},
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT chunk_text, metadata FROM article_chunks ORDER BY embedding <=> (SELECT embedding FROM article_chunks LIMIT 1) LIMIT 5"
      },
      "name": "Vector Search",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "content": "You are an AI news assistant. Answer based on the provided context. Cite sources with URLs.\n\nContext: {{$json.context}}\n\nQuestion: {{$json.chatInput}}"
            }
          ]
        }
      },
      "name": "OpenAI Chat",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [
        750,
        300
      ]
    }
  ],
  "connections": {
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "Vector Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vector Search": {
      "main": [
        [
          {
            "node": "OpenAI Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

RAG Chat Agent. Uses chatTrigger, postgres, openAi. Chat trigger; 3 nodes.

Source: https://github.com/statnyk/ai-digest-rag/blob/f331ffcc6cc959966718c37e9241e5faec038e62/n8n-workflows/rag-chat-agent.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This is the core AI agent used for queryverify.com.

Chat Trigger, Memory Buffer Window, Postgres +4
AI & RAG

HDW Lead Geländewagen. Uses chatTrigger, lmChatOpenAi, memoryBufferWindow, outputParserStructured. Chat trigger; 92 nodes.

Chat Trigger, OpenAI Chat, Memory Buffer Window +5
AI & RAG

Who’s it for Creators who want to create faceless videos automatically, while keeping human oversight and quality control.

Read Write File, Agent, OpenAI Chat +7
AI & RAG

The Best Linkedin Posting System. Uses httpRequest, lmChatOpenAi, agent, chatTrigger. Chat trigger; 49 nodes.

HTTP Request, OpenAI Chat, Agent +8
AI & RAG

Community Node Disclaimer: This workflow uses KlickTipp community nodes.

Chat Trigger, OpenAI Chat, Memory Buffer Window +6