This workflow corresponds to n8n.io template #14041 — we link there as the canonical source.
This workflow follows the Agent → 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 →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "5acb77f0-cd31-4722-b7db-b33b75bfa320",
"name": "Document Upload Form",
"type": "n8n-nodes-base.formTrigger",
"position": [
-240,
368
],
"parameters": {
"options": {
"buttonLabel": "Upload Documents",
"appendAttribution": false
},
"formTitle": "Document Upload for RAG",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "Upload Documents",
"acceptFileTypes": "application/pdf,.csv,application/json"
}
]
},
"formDescription": "Upload PDF, CSV, or JSON files to add them to the knowledge base"
},
"typeVersion": 2.3
},
{
"id": "a96a28f2-2b93-4556-a44b-b9cfa5ed86ac",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"position": [
144,
368
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "pineconeIndex",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Pinecone index name__>"
},
{
"id": "id-2",
"name": "pineconeNamespace",
"type": "string",
"value": "documents"
},
{
"id": "id-3",
"name": "chunkSize",
"type": "number",
"value": 1000
},
{
"id": "id-4",
"name": "chunkOverlap",
"type": "number",
"value": 200
},
{
"id": "id-5",
"name": "topK",
"type": "number",
"value": 5
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "500d17e0-24f1-4cc3-b2fe-cf39e4b08e57",
"name": "Store Form Responses",
"type": "n8n-nodes-base.dataTable",
"position": [
560,
112
],
"parameters": {
"columns": {
"value": null,
"mappingMode": "autoMapInputData"
},
"options": {},
"dataTableId": {
"__rl": true,
"mode": "id",
"value": "form_responses"
}
},
"typeVersion": 1
},
{
"id": "46a3853d-bffb-4bac-b0d1-a91230fa18d1",
"name": "Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
656,
640
],
"parameters": {
"options": {},
"chunkSize": "={{ $('Workflow Configuration').first().json.chunkSize }}",
"chunkOverlap": "={{ $('Workflow Configuration').first().json.chunkOverlap }}"
},
"typeVersion": 1
},
{
"id": "4f386a05-c6d0-463e-acac-33abdf8b896c",
"name": "Document Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
768,
544
],
"parameters": {
"loader": "pdfLoader",
"options": {},
"dataType": "binary",
"binaryMode": "specificField",
"textSplittingMode": "custom"
},
"typeVersion": 1.1
},
{
"id": "93ec926a-7961-48cb-88da-20079aaf41a2",
"name": "OpenAI Embeddings",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
624,
1312
],
"parameters": {
"options": {}
},
"typeVersion": 1.2
},
{
"id": "33bbc928-7c05-4815-98d6-e77710401a7f",
"name": "Pinecone Insert Documents",
"type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
"position": [
496,
448
],
"parameters": {
"mode": "insert",
"options": {
"pineconeNamespace": "={{ $('Workflow Configuration').first().json.pineconeNamespace }}"
},
"pineconeIndex": {
"__rl": true,
"mode": "id",
"value": "={{ $('Workflow Configuration').first().json.pineconeIndex }}"
}
},
"typeVersion": 1.3
},
{
"id": "377b69f9-5e95-43a9-96bf-458c9a5bc6c7",
"name": "Chat Trigger",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-288,
1024
],
"parameters": {
"public": true,
"options": {
"loadPreviousSession": "memory"
},
"initialMessages": "Hi! I can answer questions about the documents you've uploaded. What would you like to know?"
},
"typeVersion": 1.4
},
{
"id": "747fa77b-15e9-41aa-8453-c53e6470a66c",
"name": "Chat Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
64,
1216
],
"parameters": {
"contextWindowLength": 10
},
"typeVersion": 1.3
},
{
"id": "f5d25ef0-f0c3-4b9d-9834-b3e821c77442",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-64,
1248
],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {},
"builtInTools": {}
},
"typeVersion": 1.3
},
{
"id": "9a8b8891-8d74-44df-8d45-458407baefe3",
"name": "RAG Chatbot Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
128,
992
],
"parameters": {
"text": "={{ $json.chatInput }}",
"options": {
"systemMessage": "You are a helpful assistant that answers questions based ONLY on the information retrieved from uploaded documents.\n\nYour task:\n1. Review the context provided from the vector store\n2. Answer the user's question using ONLY information from the retrieved documents\n3. If the retrieved documents do not contain enough information to answer confidently, respond with: \"I couldn't find that in the uploaded documents.\"\n4. Always cite which document(s) you're referencing when possible\n5. Be concise and accurate\n\nNever make up information or use knowledge outside of the provided context."
},
"promptType": "define"
},
"typeVersion": 3
},
{
"id": "e538b0af-5948-4c20-8d4d-332d5b5f0960",
"name": "Prepare Chat Log",
"type": "n8n-nodes-base.set",
"position": [
512,
992
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "userQuery",
"type": "string",
"value": "={{ $json.chatInput }}"
},
{
"id": "id-2",
"name": "botResponse",
"type": "string",
"value": "={{ $json.output }}"
},
{
"id": "id-3",
"name": "timestamp",
"type": "string",
"value": "={{ $now.toISO() }}"
},
{
"id": "id-4",
"name": "sessionId",
"type": "string",
"value": "={{ $json.sessionId }}"
},
{
"id": "id-5",
"name": "matchedFiles",
"type": "string",
"value": "={{ $json.metadata?.fileName || 'N/A' }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a4954013-c46f-4ddf-9309-a7084654defa",
"name": "Log Chat Interactions",
"type": "n8n-nodes-base.dataTable",
"position": [
720,
992
],
"parameters": {
"columns": {
"value": null,
"mappingMode": "autoMapInputData"
},
"options": {},
"dataTableId": {
"__rl": true,
"mode": "id",
"value": "chat_logs"
}
},
"typeVersion": 1
},
{
"id": "78e53642-8860-40c5-bc64-e703fd9f49d5",
"name": "Daily Summary Schedule",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-336,
1712
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 9
}
]
}
},
"typeVersion": 1.3
},
{
"id": "0c306f96-b778-41bb-9652-aa9c4367ca59",
"name": "Get Chat Logs",
"type": "n8n-nodes-base.dataTable",
"position": [
0,
1728
],
"parameters": {
"filters": {
"conditions": [
{
"keyName": "timestamp",
"keyValue": "={{ $now.minus({ days: 1 }).toISO() }}",
"condition": "gt"
}
]
},
"operation": "get",
"returnAll": true,
"dataTableId": {
"__rl": true,
"mode": "id",
"value": "chat_logs"
}
},
"typeVersion": 1
},
{
"id": "adcad995-4d1f-4afc-8bef-cbe268c6eafb",
"name": "Analyze Chat Data",
"type": "n8n-nodes-base.code",
"position": [
192,
1728
],
"parameters": {
"jsCode": "// Analyze chat logs and generate summary statistics\nconst items = $input.all();\n\n// Initialize counters\nlet totalQuestions = 0;\nlet filesReferenced = {};\nlet failedLookups = 0;\n\n// Process each chat log entry\nfor (const item of items) {\n const data = item.json;\n \n // Count total questions\n totalQuestions++;\n \n // Track files referenced (if available in the data)\n if (data.filesReferenced) {\n const files = Array.isArray(data.filesReferenced) ? data.filesReferenced : [data.filesReferenced];\n files.forEach(file => {\n filesReferenced[file] = (filesReferenced[file] || 0) + 1;\n });\n }\n \n // Count failed lookups (if no relevant documents found)\n if (data.documentsFound === 0 || data.status === 'failed' || data.noResults === true) {\n failedLookups++;\n }\n}\n\n// Sort files by reference count\nconst topFiles = Object.entries(filesReferenced)\n .sort((a, b) => b[1] - a[1])\n .slice(0, 10)\n .map(([file, count]) => ({ file, count }));\n\n// Calculate success rate\nconst successRate = totalQuestions > 0 ? ((totalQuestions - failedLookups) / totalQuestions * 100).toFixed(2) : 0;\n\n// Generate HTML email body\nconst topFilesHtml = topFiles.length > 0 \n ? topFiles.map(({ file, count }) => `<li><strong>${file}</strong>: ${count} references</li>`).join('')\n : '<li>No files referenced</li>';\n\nconst emailBody = `\n<!DOCTYPE html>\n<html>\n<head>\n <style>\n body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }\n .container { max-width: 600px; margin: 0 auto; padding: 20px; }\n .header { background-color: #4CAF50; color: white; padding: 20px; text-align: center; border-radius: 5px; }\n .stats { background-color: #f4f4f4; padding: 15px; margin: 20px 0; border-radius: 5px; }\n .stat-item { margin: 10px 0; }\n .stat-label { font-weight: bold; color: #555; }\n .stat-value { color: #4CAF50; font-size: 1.2em; }\n .success-rate { font-size: 2em; color: #4CAF50; font-weight: bold; }\n ul { padding-left: 20px; }\n .footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; font-size: 0.9em; color: #777; }\n </style>\n</head>\n<body>\n <div class=\"container\">\n <div class=\"header\">\n <h1>\ud83d\udcca Daily RAG Chatbot Summary</h1>\n <p>${new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}</p>\n </div>\n \n <div class=\"stats\">\n <div class=\"stat-item\">\n <span class=\"stat-label\">Total Questions Asked:</span>\n <span class=\"stat-value\">${totalQuestions}</span>\n </div>\n \n <div class=\"stat-item\">\n <span class=\"stat-label\">Success Rate:</span>\n <div class=\"success-rate\">${successRate}%</div>\n </div>\n \n <div class=\"stat-item\">\n <span class=\"stat-label\">Failed Lookups:</span>\n <span class=\"stat-value\">${failedLookups}</span>\n </div>\n \n <div class=\"stat-item\">\n <span class=\"stat-label\">Total Files Referenced:</span>\n <span class=\"stat-value\">${Object.keys(filesReferenced).length}</span>\n </div>\n </div>\n \n <h2>\ud83d\udcc1 Top Referenced Files</h2>\n <ul>\n ${topFilesHtml}\n </ul>\n \n <div class=\"footer\">\n <p>This is an automated summary generated by your RAG Chatbot system.</p>\n </div>\n </div>\n</body>\n</html>\n`;\n\n// Return summary statistics with email body\nreturn [{\n json: {\n totalQuestions,\n topFilesReferenced: topFiles,\n failedLookups,\n successRate: `${successRate}%`,\n totalFilesReferenced: Object.keys(filesReferenced).length,\n summaryDate: new Date().toISOString().split('T')[0],\n emailBody\n }\n}];"
},
"typeVersion": 2
},
{
"id": "592d1663-f607-4b72-8ed7-02306663f418",
"name": "Send Daily Summary Email",
"type": "n8n-nodes-base.gmail",
"position": [
464,
1728
],
"parameters": {
"sendTo": "<__PLACEHOLDER_VALUE__Your email address__>",
"message": "={{ $json.emailBody }}",
"options": {},
"subject": "=Daily RAG Chatbot Summary - {{ $now.toFormat('yyyy-MM-dd') }}"
},
"typeVersion": 2.2
},
{
"id": "0e51abc9-107d-4839-bf35-240b838cda4e",
"name": "Pinecone Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
"position": [
192,
1216
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {},
"pineconeIndex": {
"__rl": true,
"mode": "list",
"value": ""
}
},
"typeVersion": 1.3
},
{
"id": "29097054-fe5f-426b-a751-f10f84e62a27",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
432,
304
],
"parameters": {
"color": 7,
"width": 576,
"height": 448,
"content": "## Vector Database Indexing\n\nDocument chunks are converted into embeddings and stored in Pinecone.\n\nThis creates a searchable vector index that allows the chatbot to retrieve relevant document context during conversations."
},
"typeVersion": 1
},
{
"id": "b93be14c-5167-4b60-b344-7d43cddad206",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
432,
0
],
"parameters": {
"color": 7,
"width": 400,
"height": 256,
"content": "## Document Processing Pipeline\n\nUploaded files are loaded and converted into text."
},
"typeVersion": 1
},
{
"id": "1661ee8b-cc57-4767-9838-09405ad04d77",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
224
],
"parameters": {
"color": 7,
"width": 336,
"height": 304,
"content": "## Workflow Configuration\n\nDefines key settings used throughout the workflow:\nPinecone index name,namespace,chunk size, chunk overlap, retrieval depth (top-K)\n\n"
},
"typeVersion": 1
},
{
"id": "ce5be48c-5f81-4f91-95e3-ed7c051918f0",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-368,
240
],
"parameters": {
"color": 7,
"width": 336,
"height": 288,
"content": "## Document Upload Interface\n\nUsers upload PDF, CSV, or JSON files through a form."
},
"typeVersion": 1
},
{
"id": "cf312465-3ac5-4523-bbc4-512ad1af49c4",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
16,
832
],
"parameters": {
"color": 7,
"width": 448,
"height": 544,
"content": "## RAG Question Answering\n\nThe chatbot retrieves relevant document chunks from Pinecone and uses them as context for the LLM.\n\nThe assistant answers using only retrieved information from the uploaded documents."
},
"typeVersion": 1
},
{
"id": "804a9321-0120-414a-a3f3-4d9893e1e085",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
896
],
"parameters": {
"color": 7,
"width": 368,
"height": 304,
"content": "## Chat Interface\n\nUsers interact with the knowledge base through a chat interface."
},
"typeVersion": 1
},
{
"id": "9a3c83ec-7603-4c1d-97e6-707b5f01e60b",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
832
],
"parameters": {
"color": 7,
"width": 480,
"height": 336,
"content": "## Chat Logging\n\nUser queries and chatbot responses are captured with metadata such as session ID and timestamps.\n\nThis enables conversation tracking, analytics, and debugging."
},
"typeVersion": 1
},
{
"id": "37f396ac-de6e-486a-8d9e-9ba21641d65c",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-64,
1488
],
"parameters": {
"color": 7,
"width": 416,
"height": 384,
"content": "## Chat Log Analysis\n\nThe workflow retrieves chat interactions from the last 24 hours and analyzes usage patterns.\n\nMetrics include:\n\u2022 total questions asked\n\u2022 files referenced\n\u2022 failed document lookups\n\u2022 overall success rate."
},
"typeVersion": 1
},
{
"id": "68960ed9-f358-4709-94f4-42253d01e258",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-496,
1504
],
"parameters": {
"color": 7,
"width": 416,
"height": 368,
"content": "## Daily Analytics Trigger\n\nThis scheduled trigger runs every morning to generate a usage summary for the RAG chatbot."
},
"typeVersion": 1
},
{
"id": "9e0194dd-4feb-40f2-9314-eebb194ee417",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
384,
1472
],
"parameters": {
"color": 7,
"width": 368,
"height": 400,
"content": "## Daily Summary Report\n\nThe workflow generates a formatted HTML report and sends it via email."
},
"typeVersion": 1
},
{
"id": "b5163c62-dcd8-4565-afa2-3521bd6ef130",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1152,
1200
],
"parameters": {
"width": 448,
"height": 560,
"content": "## Daily RAG Chatbot Analytics\n\nThis workflow generates a daily performance report for a Retrieval-Augmented Generation (RAG) chatbot by analyzing recent chat activity stored in the system.\n\nEvery morning the workflow runs automatically and retrieves chat interactions from the last 24 hours. These logs include user questions, referenced documents, timestamps, and whether relevant documents were successfully retrieved.\n\nThe workflow then analyzes the data to calculate key metrics such as the total number of questions asked, failed document lookups, overall success rate, and the most frequently referenced files in the knowledge base.\n\nUsing these statistics, the workflow generates a formatted HTML summary report. The report highlights usage patterns and helps identify which documents are most useful to users.\n\nFinally, the report is sent via email to the configured recipient, providing a quick daily overview of chatbot activity and knowledge base performance."
},
"typeVersion": 1
}
],
"connections": {
"Chat Memory": {
"ai_memory": [
[
{
"node": "Chat Trigger",
"type": "ai_memory",
"index": 0
},
{
"node": "RAG Chatbot Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Chat Trigger": {
"main": [
[
{
"node": "RAG Chatbot Agent",
"type": "main",
"index": 0
}
]
]
},
"Get Chat Logs": {
"main": [
[
{
"node": "Analyze Chat Data",
"type": "main",
"index": 0
}
]
]
},
"Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Document Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Document Loader": {
"ai_document": [
[
{
"node": "Pinecone Insert Documents",
"type": "ai_document",
"index": 0
}
]
]
},
"Prepare Chat Log": {
"main": [
[
{
"node": "Log Chat Interactions",
"type": "main",
"index": 0
}
]
]
},
"Analyze Chat Data": {
"main": [
[
{
"node": "Send Daily Summary Email",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "RAG Chatbot Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Embeddings": {
"ai_embedding": [
[
{
"node": "Pinecone Insert Documents",
"type": "ai_embedding",
"index": 0
},
{
"node": "Pinecone Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"RAG Chatbot Agent": {
"main": [
[
{
"node": "Prepare Chat Log",
"type": "main",
"index": 0
}
]
]
},
"Document Upload Form": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"Pinecone Vector Store": {
"ai_tool": [
[
{
"node": "RAG Chatbot Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Daily Summary Schedule": {
"main": [
[
{
"node": "Get Chat Logs",
"type": "main",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "Store Form Responses",
"type": "main",
"index": 0
},
{
"node": "Pinecone Insert Documents",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow implements a complete Retrieval-Augmented Generation (RAG) knowledge assistant with built-in document ingestion, conversational AI, and automated analytics using n8n, OpenAI, and Pinecone.
Source: https://n8n.io/workflows/14041/ — 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.
Your AI workforce is ready. Are you?
This intelligent chatbot leverages cutting-edge financial APIs and AI-driven analysis to deliver comprehensive stock research reports. Get instant access to professional-grade investment analysis that
This advanced n8n workflow automates the full lead enrichment, qualification, and personalized outreach process tailored specifically for the B2B real estate sector. Integrating top platforms like Api
This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th
Automate Outreach Prospect automates finding, enriching, and messaging potential partners (like restaurants, malls, and bars) using Apify Google Maps scraping, Perplexity enrichment, OpenAI LLMs, Goog