This workflow corresponds to n8n.io template #5023 — we link there as the canonical source.
This workflow follows the Chainretrievalqa → Retrievervectorstore 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 →
{
"id": "OAvKQCYsly0DTlci",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Complete RAG System with Automatic Source Citations Using Qdrant",
"tags": [],
"nodes": [
{
"id": "65d3e882-ef84-4b3b-88b0-bb69bbe6886f",
"name": "When clicking \u2018Test workflow\u2019",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-400,
220
],
"parameters": {},
"typeVersion": 1
},
{
"id": "db531b5a-588a-4982-aa00-e565d6f5610b",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
940,
480
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "5a1606d8-d851-4fb1-a18a-a45f5de3adf2",
"name": "Default Data Loader1",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1080,
480
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "file_id",
"value": "={{ $('Get file').item.json.id }}"
},
{
"name": "file_name",
"value": "={{ $('Get file').item.json.name }}"
}
]
}
},
"dataType": "binary",
"binaryMode": "specificField"
},
"typeVersion": 1
},
{
"id": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
"name": "Qdrant Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
1000,
240
],
"parameters": {
"mode": "insert",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "db1f5e71-28ef-427e-8911-275ddea4e44f",
"name": "Create collection",
"type": "n8n-nodes-base.httpRequest",
"position": [
-180,
-140
],
"parameters": {
"url": "http://QDRANTURL/collections/COLLECTION",
"method": "PUT",
"options": {},
"jsonBody": "{\n \"vectors\": {\n \"size\": 1536,\n \"distance\": \"Cosine\" \n },\n \"shard_number\": 1, \n \"replication_factor\": 1, \n \"write_consistency_factor\": 1 \n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "e0936863-4ece-429c-bf32-49f75b5c8bf0",
"name": "Recursive Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
1060,
660
],
"parameters": {
"options": {},
"chunkSize": 500,
"chunkOverlap": 50
},
"typeVersion": 1
},
{
"id": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
420,
220
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
1380,
240
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "22aacdc0-8ec5-42e2-b9a0-fb9e5a4aa23c",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-460,
1080
],
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "1e132fba-00a5-414a-8f37-f34645f668ff",
"name": "Question and Answer Chain",
"type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
"position": [
120,
1280
],
"parameters": {
"options": {}
},
"typeVersion": 1.5
},
{
"id": "badee75e-bca7-49e4-9095-c098cb7adcab",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
0,
1500
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-flash"
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "ad8cec62-ce1d-4e58-8e40-9a7a9f4f93c7",
"name": "Vector Store Retriever",
"type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
"position": [
160,
1500
],
"parameters": {
"topK": 5
},
"typeVersion": 1
},
{
"id": "0c7d1804-4525-4117-a19d-f2d59195fd47",
"name": "Qdrant Vector Store1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
40,
1680
],
"parameters": {
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "6cfe7e8a-e593-4e4e-a0be-3379dd85c748",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
20,
1880
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "d9aa08b5-ed04-4506-9a2e-f994d4694f48",
"name": "Embeddings OpenAI4",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
100,
1140
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "d0d32470-b1df-40ec-aac1-32e4c9cf2e4e",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"position": [
640,
1140
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.1
},
{
"id": "2edbca72-220e-45a6-8295-830d58611549",
"name": "Aggregate",
"type": "n8n-nodes-base.aggregate",
"position": [
460,
940
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "document.metadata.file_id"
},
{
"fieldToAggregate": "document.metadata.file_name"
}
]
}
},
"typeVersion": 1
},
{
"id": "8d116bc2-73d8-4349-8b4e-8dc0aef7cfa3",
"name": "Clear collection",
"type": "n8n-nodes-base.httpRequest",
"position": [
-140,
220
],
"parameters": {
"url": "http:/YOUR_AWS_SECRET_KEY_HERE/delete",
"method": "POST",
"options": {},
"jsonBody": "{\n \"filter\": {}\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "0d4d3bab-2370-4ced-8f5d-2977d360f72b",
"name": "Get folder",
"type": "n8n-nodes-base.googleDrive",
"position": [
120,
220
],
"parameters": {
"filter": {
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1RO5ByPhq2yvYLmbapTNC_kKdU5lZd4W5",
"cachedResultUrl": "https://drive.google.com/drive/folders/1RO5ByPhq2yvYLmbapTNC_kKdU5lZd4W5",
"cachedResultName": "Test Negozio"
}
},
"options": {},
"resource": "fileFolder"
},
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 3
},
{
"id": "e81ee92f-db50-4c62-aac7-7bc03e63cc1a",
"name": "Get file",
"type": "n8n-nodes-base.googleDrive",
"position": [
700,
240
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 3
},
{
"id": "c9bdc00a-ca8c-4457-8720-e6dce07e6b22",
"name": "chatInput",
"type": "n8n-nodes-base.set",
"position": [
-200,
1080
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "282b9bed-e5fd-4edb-95d5-682bcc08e070",
"name": "chatInput",
"type": "string",
"value": "={{ $json.chatInput }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "b65ca747-e738-4b7a-ae02-83840ce0a460",
"name": "Retrive sources",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
140,
940
],
"parameters": {
"mode": "load",
"topK": 5,
"prompt": "={{ $json.chatInput }}",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "265e2613-0155-4585-8d5c-fcda26975585",
"name": "Output",
"type": "n8n-nodes-base.set",
"position": [
1060,
1140
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b296c92b-d9ee-4322-b972-d1069d01feb8",
"name": "output",
"type": "string",
"value": "={{ $('Question and Answer Chain').item.json.response }}\n\nSources: {{ (JSON.stringify($json.unique_file_names)) }},"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "9407fcaf-d90a-46bd-9b1f-b0493a0357c1",
"name": "Response",
"type": "n8n-nodes-base.code",
"position": [
880,
1140
],
"parameters": {
"jsCode": "const item = $input.item.json;\n\n// Creiamo Set per rimuovere duplicati\nconst uniqueFileIds = Array.from(new Set(item.file_id));\nconst uniqueFileNames = Array.from(new Set(item.file_name));\n\n// Ritorniamo un item con i valori univoci\nreturn [\n {\n json: {\n unique_file_ids: uniqueFileIds,\n unique_file_names: uniqueFileNames\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "0b8a715f-36eb-49fd-895e-e8e76fdbb0c1",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
-520
],
"parameters": {
"width": 840,
"height": 220,
"content": "## Complete RAG System with Automatic Source Citations Using Qdrant\n\nThis workflow implements a **Retrieval-Augmented Generation (RAG)** system that:\n\n* Stores vectorized documents in **Qdrant**,\n* Retrieves relevant content based on user input,\n* Generates AI answers using **Google Gemini**,\n* Automatically **cites the document sources** (from Google Drive).\n"
},
"typeVersion": 1
},
{
"id": "3220c323-a3d6-4855-ad05-2aaf8761771e",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-200
],
"parameters": {
"color": 6,
"width": 880,
"height": 220,
"content": "# STEP 1\n\n## Create Qdrant Collection\nChange:\n- QDRANTURL\n- COLLECTION"
},
"typeVersion": 1
},
{
"id": "738835a3-888b-426e-a897-8ddc630b85bf",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
120
],
"parameters": {
"color": 4,
"width": 620,
"height": 520,
"content": "# STEP 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Documents vectorization with Qdrant and Google Drive\nChange:\n- QDRANTURL\n- COLLECTION"
},
"typeVersion": 1
},
{
"id": "70205511-2c4a-4f2f-8f68-97e3ede28851",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
620
],
"parameters": {
"color": 4,
"width": 520,
"height": 420,
"content": "Set as metadata:\n- FILE_ID from Google Drive\n- FILE_NAME from Google Drive\n\n```\n{\n \"source\": \"blob\",\n \"blobType\": \"text/plain\",\n \"loc\": {\n \"lines\": {\n \"from\": 1,\n \"to\": 15\n }\n },\n \"file_id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"file_name\": \"FAQ\"\n}\n```\n\n\n"
},
"typeVersion": 1
},
{
"id": "921497ff-1beb-4bd1-aecd-81b68c5a0357",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
1400
],
"parameters": {
"color": 3,
"width": 520,
"height": 200,
"content": "The final output is:\n\n\nRESPONSE\n\nSources: [\"FILENAME 1\", \"FILENAME 2\",...]\n\n"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "33d05a21-33dd-422a-ba58-3eafffc7d50a",
"connections": {
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Response",
"type": "main",
"index": 0
}
]
]
},
"Get file": {
"main": [
[
{
"node": "Qdrant Vector Store",
"type": "main",
"index": 0
}
]
]
},
"Response": {
"main": [
[
{
"node": "Output",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"chatInput": {
"main": [
[
{
"node": "Question and Answer Chain",
"type": "main",
"index": 0
},
{
"node": "Retrive sources",
"type": "main",
"index": 0
}
]
]
},
"Get folder": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Get file",
"type": "main",
"index": 0
}
]
]
},
"Retrive sources": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Clear collection": {
"main": [
[
{
"node": "Get folder",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI4": {
"ai_embedding": [
[
{
"node": "Retrive sources",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Qdrant Vector Store": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader1": {
"ai_document": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Qdrant Vector Store1": {
"ai_vectorStore": [
[
{
"node": "Vector Store Retriever",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"Vector Store Retriever": {
"ai_retriever": [
[
{
"node": "Question and Answer Chain",
"type": "ai_retriever",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Question and Answer Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Question and Answer Chain": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "chatInput",
"type": "main",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader1",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"When clicking \u2018Test workflow\u2019": {
"main": [
[
{
"node": "Clear collection",
"type": "main",
"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.
googleDriveOAuth2ApigooglePalmApihttpHeaderAuthopenAiApiqdrantApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow implements a Retrieval-Augmented Generation (RAG) system that:
Source: https://n8n.io/workflows/5023/ — 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.
Api Schema Extractor. Uses manualTrigger, httpRequest, splitOut, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 88 nodes.
Wait Splitout. Uses manualTrigger, httpRequest, splitOut, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 88 nodes.
This workflow automates the process of discovering and extracting APIs from various services, followed by generating custom schemas. It works in three distinct stages: research, extraction, and schema
This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build a multi-functional AI assistant on Telegram. It seamlessly integrates AI-powered voice interactions, an
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