AI SQL Agent Chat Querying a Postgres Database
Loading workflow…
Workflow Description
A chat-driven workflow where a Chat Trigger passes the user's chatInput to an AI Agent configured as an sqlAgent with a Postgres data source. An OpenAI Chat Model node supplies gpt-4 as the language model, enabling natural-language questions to be answered as SQL queries against the connected database.
How it works
- 1.Chat Trigger receives the user's message from the chat panel.
- 2.The message text (chatInput) is passed as the agent's input.
- 3.The AI Agent runs in sqlAgent mode with Postgres set as its data source.
- 4.The OpenAI Chat Model node (gpt-4) connects to the agent as its language model.
Use cases
- Ask which tables exist in a Postgres database via plain language.
- Let non-technical users explore database contents through chat.
Requirements
- A valid OpenAI API credential in n8n with access to gpt-4.
- A configured Postgres credential attached to the agent's data source.
- n8n instance with LangChain nodes (chat trigger, agent, LM) installed.
Setup and testing in n8n
- Open the workflow in n8n and click the chat button at the bottom of the canvas.
- Paste a question such as 'Which tables are available?'
- Verify the agent responds after OpenAI and Postgres connections resolve.
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (5)
OpenAI Chat Model
OpenAI
AI Agent
Agent
Chat Trigger
Chat Trigger
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Source and license
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides