AI Agents

Chat with PostgreSQL database

11 nodes 223 142 Automatic trigger
Download

Workflow Description

An automation template that enables intelligent conversations with a PostgreSQL database using an AI agent powered by OpenAI. It maintains chat history and responds to queries based on live database data, delivering context-aware answers.

How it works

  1. 1.Receive user message through the chat trigger
  2. 2.Process the message using an AI agent with OpenAI language model
  3. 3.Query the PostgreSQL database and retrieve relevant data
  4. 4.Store conversation history in the memory buffer
  5. 5.Send the intelligent response back to the user

Use cases

  • Answer customer inquiries about data stored in your database
  • Generate instant reports from sales, inventory, or analytics tables
  • Provide automated customer support using a knowledge base stored in PostgreSQL

Requirements

  • Active PostgreSQL database with remote access configured
  • OpenAI API key
  • Reliable internet connection

Service Value

Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.

Apps Used

Chat Trigger AI Agent OpenAI Postgres Memory

Details

Trigger Automatic trigger
Nodes 11
Apps 5
Views 223
Downloads 142

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (11)

/

When chat message received

Chat Trigger

#1

AI Agent

Agent

#2

OpenAI Chat Model

OpenAI

#3

Get Table Definition

Postgres Tool

#4

Sticky Note

Sticky Note

#5

Chat History

Memory Buffer Window

#6

Sticky Note3

Sticky Note

#7

Sticky Note1

Sticky Note

#8

Sticky Note2

Sticky Note

#9

Execute SQL Query

Postgres Tool

#10

Get DB Schema and Tables List

Postgres Tool

#11