← All N8N workflows
AI & researchAgentChat TriggerOpenAI Chat ModelPostgres Tool

AI Agent to chat with Supabase/PostgreSQL DB

Configured with Agent, Chat Trigger, OpenAI Chat Model, Postgres Tool. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen chat messagereceivedChat TriggerAI & modelsOpenAI Chat ModelOpenAI Chat ModelData storeDB SchemaPostgres ToolData storeGet table definitionPostgres ToolAI & modelsAI AgentAgentData storeRun SQL QueryPostgres Tool

Node categories in this workflow

  • Trigger
  • AI & models
  • Data store

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
When chat message receivedTriggerChat TriggerSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
DB SchemaData storePostgres ToolexecuteQuery
Get table definitionData storePostgres ToolexecuteQuery
AI AgentAI & modelsAgentSee node parameters
Run SQL QueryData storePostgres ToolexecuteQuery

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • openAiApi
  • postgres

Workflow notes

Sticky Note3

Replace password and username for Supabase

Set up steps

Set up steps

Preparation

  1. Create Accounts:
    • N8N: For workflow automation.
    • Supabase: For database hosting and management.
    • OpenAI: For building the conversational AI agent.
  2. Configure Database Connection:
    • Set up a PostgreSQL database in Supabase.
    • Use appropriate credentials (username, password, host, and database name) in your workflow.

N8N Workflow

AI agent with tools:

  1. Code Tool:
    • Execute SQL queries based on user input.
  2. Database Schema Tool:
    • Retrieve a list of all tables in the database.
    • Use a predefined SQL query to fetch table definitions, including column names, types, and references.
  3. Table Definition:
    • Retrieve a list of columns with types for one table.
AI Agent to chat with Supabase/PostgreSQL DB

AI Agent to chat with Supabase/PostgreSQL DB

Made by Mark Shcherbakov from community 5minAI

Accessing and analyzing database data often requires SQL expertise or dedicated reports, which can be time-consuming. This workflow empowers users to interact with a database conversationally through an AI-powered agent. It dynamically generates SQL queries based on user requests, streamlining data retrieval and analysis.

This workflow integrates OpenAI with a Supabase database, enabling users to interact with their data via an AI agent. The agent can:

  • Retrieve records from the database.
  • Extract and analyze JSON data stored in tables.
  • Provide summaries, aggregations, or specific data points based on user queries.
... or watch set up video [20 min]

... or watch set up video [20 min]

Sticky Note

Finetune the prompt of assistant

AI Agent to chat with Supabase/PostgreSQL DB

AI Agent to chat with Supabase/PostgreSQL DB

Purpose and structure

This folder contains the AI Agent to chat with Supabase/PostgreSQL DB workflow. Its executable nodes use agent, chatTrigger, lmChatOpenAi, postgresTool. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

When chat message received

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Postgrestool/0656_Postgrestool_Stickynote_Send_Triggered.json MIT; preserve source notices.

More in AI & research