Chat with PostgreSQL Database

n8n AI Data Management Business Intelligence

Contributed by Sabrina Ramonov 🍄. From the community directory at agents.sabrina.dev, republished with permission and full credit.

Who is this template for?

This workflow template is designed for any professionals seeking relevant data from a database using natural language.

How it works

Each time a user asks a question using the n8n chat interface, the workflow runs.

Then the message is processed by the AI Agent using relevant tools - Execute SQL Query, Get DB Schema and Tables List, and Get Table Definition, if required. The agent uses these tools to form and run SQL queries that are necessary to answer the questions.

Once the AI Agent has the data, it uses it to form an answer and returns it to the user.

Set up instructions

Complete the Set up credentials step when you first open the workflow. You'll need PostgreSQL credentials and an OpenAI API key.

Tools used: OpenAI, AI Agent

Download the workflow template (JSON)

Original tutorial

Want this running in your business? KOBA42 builds and operates automations like this one.