← All N8N workflows
AI & researchAgentChat TriggerOpenAI Chat ModelMemory Buffer WindowPostgres Tool

Chat with Postgresql Database

Configured with Agent, Chat Trigger, OpenAI Chat Model, Memory Buffer Window, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen chat messagereceivedChat TriggerAI & modelsAI AgentAgentAI & modelsOpenAI Chat ModelOpenAI Chat ModelData storeGet Table DefinitionPostgres ToolData storeChat HistoryMemory Buffer WindowData storeExecute SQL QueryPostgres ToolData storeGet DB Schema andTables ListPostgres 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
AI AgentAI & modelsAgentSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
Get Table DefinitionData storePostgres ToolexecuteQuery
Chat HistoryData storeMemory Buffer WindowSee node parameters
Execute SQL QueryData storePostgres ToolexecuteQuery
Get DB Schema and Tables ListData 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

👨‍🎤 Setup

👨‍🎤 Setup

  1. Add your postgresql and OpenAI credentials.
  2. Click Chat button and start asking questions to your database.
  3. Activate the workflow and you can make the chat publicly available.
Sticky Note3

🛠️ Tools Used:

  1. Execute SQL Query: Used to execute any query generated by the agent.
  2. Get DB Schema and Tables List: It returns the list of all the tables with its schema name.
  3. Get Table Definition: It returns table details like column names, foreign keys and more of a particular table in a schema.
Sticky Note1

👆 You can exchange this with any other chat model of your choice.

Sticky Note2

👆 You can change how many number of messages to keep using Context Window Length option. It's 5 by default.

Chat with Postgresql Database

Chat with Postgresql Database

Purpose and structure

This folder contains the Chat with Postgresql Database workflow. Its executable nodes use agent, chatTrigger, lmChatOpenAi, memoryBufferWindow, 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/1848_Postgrestool_Stickynote_Automation_Triggered.json MIT; preserve source notices.

More in AI & research