The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"id": "d277b81b-05fd-4733-807a-f63eb6e87742",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
960,
500
],
"parameters": {
"model": "gpt-4",
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "c56b3269-32b0-4782-ad50-74af8ee2d8a7",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
960,
320
],
"parameters": {
"agent": "sqlAgent",
"input": "={{ $json.chatInput }}",
"options": {},
"dataSource": "postgres"
},
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "8781c9fd-f6de-4a85-b05d-8f55647304f7",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
740,
320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "3c485755-0594-4a5a-b38c-440694668181",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
620,
480
],
"parameters": {
"content": "## Try me out\nClick the 'chat' button at the bottom of the canvas and paste in:\n\n_Which tables are available?_"
},
"typeVersion": 1
},
{
"id": "8f296643-7375-4974-be5d-9a4223d11e5f",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
940,
240
],
"parameters": {
"color": 7,
"width": 297,
"height": 205,
"content": "This workflow uses a Postgres DB, but you could swap it for a MySQL or SQLite one"
},
"typeVersion": 1
}
],
"connections": {
"Chat Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApipostgres
About this workflow
Chat With A Database Using Ai. Uses lmChatOpenAi, agent, chatTrigger, stickyNote. Chat trigger; 5 nodes.
Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →