This workflow follows the Chainllm → Chat Trigger recipe pattern — see all workflows that pair these two integrations.
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 →
{
"createdAt": "2025-02-02T15:48:49.139Z",
"updatedAt": "2025-02-10T12:45:27.037Z",
"id": "zrMOR7Bph0Qrt5Dl",
"name": "Siscad DB AI",
"active": false,
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
-1600,
-440
],
"id": "f9aaa3bc-d856-4f4d-9482-871ad97d249c",
"name": "When chat message received"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "757c1e74-7caa-40f9-ae01-aa7838367742",
"name": "tables",
"value": "['v_members', 'v_plans', 'v_cities', 'v_regions']",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-1400,
-680
],
"id": "9f84bb57-da53-44ad-b298-d0142d48ef6b",
"name": "Edit Fields"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
-1200,
-480
],
"id": "4994d636-1500-4ba2-970b-b4111f37b935",
"name": "Google Gemini Chat Model",
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "{{ $json.text }}",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.5,
"position": [
-860,
-680
],
"id": "b1b040b3-9055-463b-98e1-8f82fc3343f8",
"name": "EXECUTE QUERY EXTRACT SCHEMA",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "return {\n schema: JSON.stringify($('EXECUTE QUERY EXTRACT SCHEMA').all())\n}"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-640,
-680
],
"id": "98848bef-4b6b-48aa-a12e-74d60b06d764",
"name": "PREPARE SCHEMA DBS"
},
{
"parameters": {
"modelName": "models/gemini-1.0-pro-001",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
-420,
-500
],
"id": "c7bef772-6e8a-44de-8d51-600aa2d783de",
"name": "Google Gemini Chat Model1",
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "{{ $json.result }}",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.5,
"position": [
160,
-680
],
"id": "b39e20ea-0c6a-4429-958a-3b4dd0a8ac19",
"name": "EXECUTE QUERY TO EXTRACT INFORMATION",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const query = $input.first().json.text // Certifique-se de que 'query' \u00e9 o nome do campo de entrada\nconst match = query.match(/```sql\\n([\\s\\S]*?)\\n```/);\nreturn [{ json: { result: match ? match[1].trim() : query.trim() } }];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-60,
-680
],
"id": "fcc30638-db7b-4543-b849-9da3757bdf41",
"name": "Code"
},
{
"parameters": {
"promptType": "define",
"text": "=Dado as tabelas a seguir, preciso que voc\u00ea altere a query para utilizada para extrair o schema do banco somente para as tabelas informadas.\n\nTABELAS\n{{ $json.tables }}\n\n### QUERY A SER ALTERADA\nSELECT table_name, column_name, data_type \nFROM information_schema.columns \nWHERE table_schema = 'public' \nAND table_name in () \nORDER BY table_name, ordinal_position;\n\n### O QUE FAZER\n1. RETORNAR APENAS A QUERY FINAL\n2. GARANTIR QUE O RETORNO VAI SER EXECUTADO PELO DB COM SUCESSO\n\n### O QUE N\u00c3O FAZER\n1. INCLUIR EXPLICA\u00c7\u00c3O OU OPINI\u00c3O\n2. N\u00c3O INCLUIR EM BLOCO DE C\u00d3DIGO COMO POR EXEMPLO \"```sql\"\n"
},
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.5,
"position": [
-1220,
-680
],
"id": "1a1e6340-82fe-40cb-8c91-8c6436db7db8",
"name": "EXTRACT SCHEMA DBS"
},
{
"parameters": {
"promptType": "define",
"text": "={{ $('When chat message received').last().json.chatInput }}",
"messages": {
"messageValues": [
{
"message": "=Voc\u00ea agora \u00e9 um DBA experiente em montar queries para extrair as informa\u00e7\u00f5es do banco solicitadas pelo usu\u00e1rio.\n\nPreciso que voc\u00ea analise a solicita\u00e7\u00e3o do usu\u00e1rio e utilizando o schema predefinido elabore a query para extrair as informa\u00e7\u00f5es desejadas.\n\n### SCHEMA DISPON\u00cdVEL\n{{ $json.schema }}\n\n### O QUE VOC\u00ca DEVE FAZER\n1. RETORNAR APENAS A QUERY FINAL;\n2. GARANTIR QUE O RETORNO VAI SER EXECUTADO PELO DB COM SUCESSO;\n3. SEMPRE UTILIZE ILIKE PARA OS CAMPOS VARCHAR, CHAR, STRING, TEXT;\n4. Remova TODOS e quaisquer caracteres antes e depois da query, deixando apenas o c\u00f3digo SQL puro como no exemplo abaixo:\n\"SELECT COUNT(*) AS total FROM table_name;\"\n\n### CONSIDERAC\u00d4ES PARA A CRIACAO DE UMA SQL CORRETA:\n1. SITUACAO DOS SOCIOS:\n 1.1. S\u00f3cios ativos equivale status_id = '2';\n 1.2. S\u00f3cios inativos equivale status_id = '1';\n\n2. INFORMACOES:\n 2.1 TODAS AS INFORMACOES ESTAO CONTIDAS NA TABELA INFORMADA;\n\n3. PLANOS DOS SOCIOS:\n 3.1 Plano especial equivale plan_id = '1';\n 3.2 Plano normal equivale plan_id = '2';\n 3.3 Plano inss equivale plan_id = '3';\n 3.4 Plano contribuinte equivale plan_id = '4';\n 3.5 Plano ipe equivale plan_id = '5';\n\n4. RELACAO ENTRE TABELAS:\n 4.1 Utilizar os nomes dos campos originais das tabelas quando possivel;\n 4.2 NAO DEVERA SER REALIZADA NENHUM RELACIONAMENTO COM OUTRAS TABELAS;\n"
}
]
}
},
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.5,
"position": [
-440,
-680
],
"id": "a65584b8-1a69-44ff-a300-305912092f4d",
"name": "GENERATE QUERY TO EXTRACT DBS"
}
],
"connections": {
"When chat message received": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "EXTRACT SCHEMA DBS",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "EXTRACT SCHEMA DBS",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"EXECUTE QUERY EXTRACT SCHEMA": {
"main": [
[
{
"node": "PREPARE SCHEMA DBS",
"type": "main",
"index": 0
}
]
]
},
"PREPARE SCHEMA DBS": {
"main": [
[
{
"node": "GENERATE QUERY TO EXTRACT DBS",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model1": {
"ai_languageModel": [
[
{
"node": "GENERATE QUERY TO EXTRACT DBS",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "EXECUTE QUERY TO EXTRACT INFORMATION",
"type": "main",
"index": 0
}
]
]
},
"EXECUTE QUERY TO EXTRACT INFORMATION": {
"main": [
[]
]
},
"EXTRACT SCHEMA DBS": {
"main": [
[
{
"node": "EXECUTE QUERY EXTRACT SCHEMA",
"type": "main",
"index": 0
}
]
]
},
"GENERATE QUERY TO EXTRACT DBS": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"meta": {
"templateCredsSetupCompleted": true
},
"versionId": "bcb0b7df-d0bc-4d86-ad7a-9ae39de5c605",
"triggerCount": 0,
"tags": []
}
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.
googlePalmApipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Siscad DB AI. Uses chatTrigger, lmChatGoogleGemini, postgres, chainLlm. Chat trigger; 10 nodes.
Source: https://github.com/ManusAafc/n8n/blob/33594463d360d5fda53843f65e53a80f29c53857/backup/zrMOR7Bph0Qrt5Dl.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Siscad DB AI Memory Buffer. Uses chatTrigger, lmChatGoogleGemini, postgres, chainLlm. Chat trigger; 15 nodes.
The original LLM Council concept was introduced by Andrej Karpathy and published as an open-source repository demonstrating multi-model consensus and ranking. This workflow is my adaptation of that or
Perform comprehensive research on a user's query by dynamically generating search terms, querying the web using Google Search (by Gemini) , reflecting on the results to identify knowledge gaps, and it
AI Comprehensive Research on User's Query (reproduction of gemini-fullstack-langgraph-quickstart). Uses lmChatGoogleGemini, outputParserStructured, chainLlm, redis. Chat trigger; 37 nodes.
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.