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 →
{
"name": "RAG AI Agent",
"nodes": [
{
"parameters": {
"model": "gpt-4o-mini",
"options": {}
},
"id": "33ff568b-7ff5-4693-b00b-d788cde46c0b",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
1060,
520
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('When chat message received').item.json.sessionId }}"
},
"id": "f7f4e28a-0d29-4eb7-978d-95df0e56a3ae",
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.2,
"position": [
1200,
520
]
},
{
"parameters": {
"model": "gpt-4o-mini",
"options": {}
},
"id": "0fe1d709-eb31-4110-830e-167e3a551eb2",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
1940,
760
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"resource": "fileFolder",
"queryString": "={{ $json.query.query }}",
"limit": 1,
"filter": {},
"options": {}
},
"id": "63cd26be-3e7e-4bc0-bb3e-4d66784e3585",
"name": "Google Drive",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
440,
780
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"value": "={{ $json.id }}",
"mode": "id"
},
"options": {
"binaryPropertyName": "data",
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
}
},
"id": "4db2b70d-4fc9-4e7c-b987-5f2258da3b16",
"name": "Get File Content",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
660,
780
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsonMode": "expressionData",
"jsonData": "={{ $json.data }}",
"options": {}
},
"id": "b0f5c545-ae2d-4a66-be57-ce554d8e615e",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"typeVersion": 1,
"position": [
1200,
1000
]
},
{
"parameters": {},
"id": "89c7d5f5-99be-4ffe-92ef-32fa53c06c1f",
"name": "Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
"typeVersion": 1,
"position": [
1200,
1180
]
},
{
"parameters": {
"operation": "text",
"options": {}
},
"id": "cf4ab541-026f-4ec2-9875-c575a5ae75d8",
"name": "Extract from File",
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
880,
780
]
},
{
"parameters": {
"model": "text-embedding-3-large",
"options": {}
},
"id": "dad0f35a-e10d-4192-b614-86e37de826ce",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1,
"position": [
1040,
1000
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"model": "text-embedding-3-large",
"options": {}
},
"id": "bf80fd4d-0f65-4683-8f44-b973bfb6bb27",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1,
"position": [
1760,
840
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "add_doc_to_vector_db",
"authentication": "headerAuth",
"responseMode": "lastNode",
"options": {}
},
"id": "2f39795b-02cd-4e0e-9229-f55526b9f28a",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
220,
780
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"name": "add_file_to_vector_db",
"description": "Use this to search for a file in Google Drive, download it, and add it to the vector DB knowledgebase for future querying.",
"workflowId": "VYQ5kVPM57CJavof",
"responsePropertyName": "metadata",
"specifyInputSchema": true,
"jsonSchemaExample": "{\n\t\"query\": \"Meeting notes from last week\"\n}"
},
"id": "4e1df3b5-e802-482c-9f35-2d36f90d66b9",
"name": "Add Google Drive File to Vector DB",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"typeVersion": 1.1,
"position": [
1560,
620
]
},
{
"parameters": {
"name": "user_documents",
"description": "Contains all the user's documents that you can check for context to answer user questions."
},
"id": "79343f67-0eec-4c8b-923c-87e731a18858",
"name": "Retrieve Documents",
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
"typeVersion": 1,
"position": [
1760,
620
]
},
{
"parameters": {
"content": "## Agent Tools for RAG",
"height": 528.85546469693,
"width": 583.4552380860637,
"color": 4
},
"id": "241c3005-9fb6-45fd-be5e-31a3eb95c64e",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
1480,
440
]
},
{
"parameters": {
"content": "## Tool to Add a Google Drive File to Vector DB",
"height": 661.3783861449286,
"width": 1290.2441524753906,
"color": 5
},
"id": "d7317244-3528-4cd8-b68e-a4c6d7521589",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
180,
700
]
},
{
"parameters": {
"content": "## RAG AI Agent with Chat Interface",
"height": 464.8027193303974,
"width": 692.7866482806627
},
"id": "2755e53b-bcfa-41af-bd23-f33122e6aad0",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
780,
220
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $('When chat message received').item.json.chatInput }}",
"options": {
"systemMessage": "You are a personal assistant who helps answer questions from a corpus of documents when you don't know the answer yourself."
}
},
"id": "018af08d-ae24-4c3a-955d-fa28de9f37b5",
"name": "RAG AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.6,
"position": [
1160,
300
]
},
{
"parameters": {
"memoryKey": "user_documents"
},
"id": "7de087ea-258b-448f-ad81-cb76a7467cfe",
"name": "In-Memory Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"typeVersion": 1,
"position": [
1660,
740
]
},
{
"parameters": {
"mode": "insert",
"memoryKey": "=user_documents"
},
"id": "dc9aecd0-3fd7-4306-9ce5-5cbde0f8e5dd",
"name": "In-Memory Vector Store Inserter",
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"typeVersion": 1,
"position": [
1120,
780
]
},
{
"parameters": {
"options": {}
},
"id": "fac880f8-9155-4f6d-bf5f-921643eac390",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
840,
300
]
}
],
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "RAG AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "RAG AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Retrieve Documents",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Google Drive": {
"main": [
[
{
"node": "Get File Content",
"type": "main",
"index": 0
}
]
]
},
"Get File Content": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "In-Memory Vector Store Inserter",
"type": "ai_document",
"index": 0
}
]
]
},
"Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "In-Memory Vector Store Inserter",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "In-Memory Vector Store Inserter",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "In-Memory Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Add Google Drive File to Vector DB": {
"ai_tool": [
[
{
"node": "RAG AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Retrieve Documents": {
"ai_tool": [
[
{
"node": "RAG AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"In-Memory Vector Store": {
"ai_vectorStore": [
[
{
"node": "Retrieve Documents",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "RAG AI Agent",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "fb0f8eba-375e-4dd4-a25f-4eb1d99e1faf",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "HuSVDGWbGX8K09N1",
"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.
googleDriveOAuth2ApihttpHeaderAuthopenAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
How this works
This workflow empowers users to build a Retrieval-Augmented Generation (RAG) AI agent that delivers accurate, context-aware responses by pulling relevant information from your documents. It is ideal for knowledge workers, researchers, or customer support teams seeking to enhance AI interactions with proprietary data without extensive coding. The key step involves loading and splitting documents from Google Drive using the Default Data Loader and Character Text Splitter, then feeding them into OpenAI's chat model for intelligent querying via a webhook trigger.
Use this workflow when you need an AI agent to reference specific files for precise answers, such as querying internal reports or FAQs stored in Google Drive. Avoid it for real-time data sources like live databases, where simpler polling integrations might suffice, or for non-document-based queries that don't benefit from RAG. Common variations include swapping Google Drive for other loaders like web scrapers or adjusting the memory buffer for longer conversation histories.
About this workflow
RAG AI Agent. Uses lmChatOpenAi, memoryBufferWindow, googleDrive, documentDefaultDataLoader. Webhook trigger; 20 nodes.
Source: https://github.com/daboi2331/ai-agents-masterclass/blob/main/9-n8n-rag-agent/n8n_Workflow_RAG_AI_Agent.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.
Bread-Meat-Delivery. Uses lmChatOpenAi, agent, httpRequest, redis. Webhook trigger; 91 nodes.
Hi! I’m Amanda, a creator of intelligent automations using n8n and Make. I’ve been building AI-powered workflows for over 2 years, always focused on usability and innovation. This one here is very spe
This workflow automates multi-channel AI-driven sales engagement for lead qualification, service information delivery, and consultation booking. It integrates WhatsApp, Facebook Messenger, Instagram D
This Workflow simulates an AI-powered phone agent with RetellAI with two main functions: 📅 Appointment Booking – It can schedule appointments directly into Google Calendar. 🧠 RAG-based Information Ret
AI Phone Agent with RetellAI. Uses lmChatOpenAi, outputParserStructured, vectorStoreQdrant, embeddingsOpenAi. Webhook trigger; 36 nodes.