Query your PostgreSQL data in plain English with GPT-4o-mini
Ready for 3.0What this workflow does
This AI workflow has 16 nodes and runs when a chat message arrives (plus 1 other trigger). Along the way it connects Postgres, OpenAI Chat Model, Postgres Chat Memory and Google Sheets and 1 more.
How it runs
Trigger: When a chat message arrives (plus 1 other trigger).
- Manage Table Name (Code): runs custom JavaScript code
- ⚙️ Config (Sync) (Edit Fields (Set)): sets 1 field: table_name
- Need Schema? (If): checks a condition and branches into true / false
- Truncate Table (Postgres): run a query
- Fetch Schema (Postgres): run a query
- Empty Schema (Edit Fields (Set)): sets 2 fields: columnList, conceptMap
- Fetch Google Sheet (Google Sheets): uses Google Sheets
- Format Schema (Code): runs custom JavaScript code
- Unified Analytics Agent (AI Agent): runs an AI agent, with model: OpenAI GPT-4o-mini; 2 tools (QuickChart, Execute SQL Query); memory: Chat Memory
- Insert Rows to Postgres (Postgres): uses Postgres
Services it uses
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Rarely used nodes in this template: n8n-nodes-base.quickChartTool
Nodes used (12)
- Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Postgres
n8n-nodes-base.postgres - Edit Fields (Set)
n8n-nodes-base.set - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Postgres Chat Memory
@n8n/n8n-nodes-langchain.memoryPostgresChat - Postgres Tool
n8n-nodes-base.postgresTool - Manual Trigger
n8n-nodes-base.manualTrigger - Google Sheets
n8n-nodes-base.googleSheets - Quick Chart Tool
n8n-nodes-base.quickChartTool
From the author
AI SQL Analytics Agent Chat With Any PostgreSQL Database Using Natural Language This template turns your PostgreSQL database into an AI-powered analytics assistant. Instead of exporting data or uploading huge CSV files to an LLM, this workflow lets AI query…