AI Agents

Intelligent Chat Interface for PostgreSQL Database Queries

11 nodes 359 144 Automatic trigger
Download

Workflow Description

An AI-powered agent that processes natural language questions through a chat interface and executes SQL queries against a PostgreSQL database, maintaining conversation history to provide contextually aware responses and results.

How it works

  1. 1.Receive user messages through the chat trigger interface
  2. 2.Process queries using an OpenAI agent that understands context and previous conversation history
  3. 3.Generate and execute SQL queries on the PostgreSQL database
  4. 4.Return results to the user in a natural and readable format

Use cases

  • Enable non-technical users to query databases through conversational language instead of writing SQL
  • Build an intelligent assistant that understands complex questions and retrieves relevant data automatically

Requirements

  • Active OpenAI API account with access to GPT chat models
  • Connected PostgreSQL database with proper credentials and schema

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 359
Downloads 144

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