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 →
{
"name": "2. Chat Query Pipeline",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "chat",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-chat",
"name": "Webhook - Chat Query",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
],
"notes": "Receives chat queries from Next.js frontend"
},
{
"parameters": {
"values": {
"string": [
{
"name": "question",
"value": "={{ $json.body.question }}"
},
{
"name": "timestamp",
"value": "={{ $json.body.timestamp || $now.toISO() }}"
}
]
}
},
"id": "extract-question",
"name": "Extract Question",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
460,
300
],
"notes": "Prepares the query for the RAG service"
},
{
"parameters": {
"url": "=http://host.docker.internal:5001/query",
"method": "POST",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "question",
"value": "={{ $json.question }}"
}
]
},
"options": {
"timeout": 300000
}
},
"id": "call-rag-query",
"name": "Call RAG Service - Query",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
680,
300
],
"notes": "Queries the RAG system for an answer"
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.status }}",
"value2": "success"
}
]
}
},
"id": "check-query-success",
"name": "Check Query Success",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
900,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "answer",
"value": "={{ $json.answer }}"
},
{
"name": "response",
"value": "={{ $json.answer }}"
},
{
"name": "status",
"value": "success"
},
{
"name": "timestamp",
"value": "={{ $now.toISO() }}"
}
],
"object": [
{
"name": "sources",
"value": "={{ $json.sources }}"
}
]
}
},
"id": "format-success-response",
"name": "Format Success Response",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
1120,
200
],
"notes": "Formats the successful response with sources as array"
},
{
"parameters": {
"values": {
"string": [
{
"name": "answer",
"value": "Sorry, I couldn't process that query. Please try again."
},
{
"name": "response",
"value": "Sorry, I couldn't process that query. Please try again."
},
{
"name": "error",
"value": "={{ $json.answer || 'Unknown error' }}"
},
{
"name": "status",
"value": "error"
}
],
"object": [
{
"name": "sources",
"value": "=[]"
}
]
}
},
"id": "format-error-response",
"name": "Format Error Response",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
1120,
400
],
"notes": "Handles errors gracefully"
},
{
"parameters": {
"respondWith": "json"
},
"id": "respond-to-frontend",
"name": "Respond to Frontend",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1340,
300
],
"notes": "Sends response back to Next.js - empty body auto-sends $json"
}
],
"connections": {
"Webhook - Chat Query": {
"main": [
[
{
"node": "Extract Question",
"type": "main",
"index": 0
}
]
]
},
"Extract Question": {
"main": [
[
{
"node": "Call RAG Service - Query",
"type": "main",
"index": 0
}
]
]
},
"Call RAG Service - Query": {
"main": [
[
{
"node": "Check Query Success",
"type": "main",
"index": 0
}
]
]
},
"Check Query Success": {
"main": [
[
{
"node": "Format Success Response",
"type": "main",
"index": 0
}
],
[
{
"node": "Format Error Response",
"type": "main",
"index": 0
}
]
]
},
"Format Success Response": {
"main": [
[
{
"node": "Respond to Frontend",
"type": "main",
"index": 0
}
]
]
},
"Format Error Response": {
"main": [
[
{
"node": "Respond to Frontend",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "2",
"id": "2",
"tags": []
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
2. Chat Query Pipeline. Uses httpRequest. Webhook trigger; 7 nodes.
Source: https://github.com/omarbakr2020/langraph-docs-ai-agent/blob/e35fb7549f2b00c806fbcb9556b1f94d459396f5/n8n-workflows/2-chat-query.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.
Jigsaw API key for image processing, I use this as a gatekeeper/second pair of eyes. LINK to their website https://jigsawstack.com/ SECOND A postgress DATABASE (I use Supabase) LlamaCloud for the pars
Onsite Photos to Jobs (SMS Agent). Uses dataTable, twilio, httpRequest, airtable. Webhook trigger; 62 nodes.
W1 - IN WhatsApp Adapter (Secure + Fast ACK). Uses postgres, redis, httpRequest. Webhook trigger; 50 nodes.
W1 - IN WhatsApp Adapter (Secure + Fast ACK). Uses postgres, redis, httpRequest. Webhook trigger; 48 nodes.