This workflow follows the Agent → Chainllm 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": "AI-Powered Email Automation with RAG",
"nodes": [
{
"parameters": {
"options": {}
},
"id": "cc5db377-8467-45bc-8daa-6336d64e7c00",
"name": "Email Trigger (IMAP)",
"type": "n8n-nodes-base.emailReadImap",
"position": [
-660,
1100
],
"typeVersion": 2
},
{
"parameters": {
"html": "={{ $json.textHtml }}",
"options": {}
},
"id": "75068e43-5b13-410e-9af6-9088ee2d55ba",
"name": "Markdown",
"type": "n8n-nodes-base.markdown",
"position": [
-440,
1100
],
"typeVersion": 1
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "deepseek/deepseek-r1:free",
"cachedResultName": "deepseek/deepseek-r1:free"
},
"options": {}
},
"id": "8e2a49ec-65f2-4eb7-b2d2-cca3b6ef85b0",
"name": "DeepSeek R1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-240,
1280
],
"typeVersion": 1.2
},
{
"parameters": {
"fromEmail": "={{ $('Email Trigger (IMAP)').item.json.to }}",
"toEmail": "={{ $('Email Trigger (IMAP)').item.json.from }}",
"subject": "=Re: {{ $('Email Trigger (IMAP)').item.json.subject }}",
"html": "={{ $json.text }}",
"options": {}
},
"id": "a602e7db-9d44-44f4-8d1c-907954f15ec0",
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"position": [
280,
1460
],
"typeVersion": 2.1
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolName": "company_knowladge_base",
"toolDescription": "Extracts information regarding the request made.",
"qdrantCollection": {
"__rl": true,
"mode": "id",
"value": "=COLLECTION"
},
"includeDocumentMetadata": false,
"options": {}
},
"id": "aef98cc2-3230-4a32-a4a2-a6522ba81169",
"name": "Qdrant Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
-540,
1720
],
"typeVersion": 1
},
{
"parameters": {
"options": {}
},
"id": "c72c56d1-a58d-4748-9ee2-ea12ef343f35",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
-560,
1880
],
"typeVersion": 1.2
},
{
"parameters": {
"inputText": "=You must classify the following email::\n\n{{ $json.response.text }}",
"categories": {
"categories": [
{
"category": "Company info request",
"description": "Company info request"
}
]
},
"options": {
"multiClass": false,
"fallback": "other",
"systemPromptTemplate": "Please classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json.\n",
"enableAutoFixing": true
}
},
"id": "db3f2474-4ab7-4c76-8d7e-bde92c15d950",
"name": "Email Classifier",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
140,
1100
],
"typeVersion": 1
},
{
"parameters": {
"operationMode": "nodeInputBinary",
"options": {
"binaryDataKey": "={{ $json.data }}",
"summarizationMethodAndPrompts": {
"values": {
"combineMapPrompt": "=Write a concise summary of the following in max 100 words:\n\n\"{{ $json.data }}\"\n",
"prompt": "=Write a concise summary of the following in max 100 words:\n\n\"{{ $json.data }}\"\n\nDo not enter the total number of words used."
}
}
}
},
"id": "4f2fa4f9-45df-4920-88e1-5c264aeeeef0",
"name": "Email Summarization Chain",
"type": "@n8n/n8n-nodes-langchain.chainSummarization",
"position": [
-220,
1100
],
"typeVersion": 2
},
{
"parameters": {
"promptType": "define",
"text": "=Write the text to reply to the following email:\n\n{{ $json.response.text }}",
"options": {
"systemMessage": "You are an expert at answering emails. You need to answer them professionally based on the information you have. This is a business email. Be concise and never exceed 100 words."
}
},
"id": "38fbffc2-aa9f-4057-93a6-20e52ec3e96c",
"name": "Write email",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-660,
1460
],
"typeVersion": 1.7
},
{
"parameters": {
"promptType": "define",
"text": "=Review at the following email:\n\n{{ $json.output }}",
"hasOutputParser": true,
"messages": {
"messageValues": [
{
"message": "=If you are an expert in reviewing emails before sending them. You need to review and structure them in such a way that you can send them. It must be in HTML format and you can insert (if you think it is appropriate) only HTML characters such as <br>, <b>, <i>, <p> where necessary.\n\nNon superare le 100 parole."
}
]
}
},
"id": "51edf641-416a-4620-a6ea-7f935505fcd8",
"name": "Review email",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
-180,
1460
],
"typeVersion": 1.5
},
{
"parameters": {},
"id": "ebd9376d-692c-4ff5-b7e9-4ce8404ff28a",
"name": "When clicking \u2018Test workflow\u2019",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-720,
140
],
"typeVersion": 1
},
{
"parameters": {
"method": "POST",
"url": "https://QDRANTURL/collections/COLLECTION",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"filter\": {}\n}",
"options": {}
},
"id": "68d77284-69e7-4ae8-b9b4-9e567c1ca72d",
"name": "Create collection",
"type": "n8n-nodes-base.httpRequest",
"position": [
-420,
0
],
"typeVersion": 4.2
},
{
"parameters": {
"method": "POST",
"url": "https://QDRANTURL/collections/COLLECTION/points/delete",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"filter\": {}\n}",
"options": {}
},
"id": "3c12cf7a-fd7d-415d-856e-57be426a0254",
"name": "Refresh collection",
"type": "n8n-nodes-base.httpRequest",
"position": [
-420,
260
],
"typeVersion": 4.2
},
{
"parameters": {
"resource": "fileFolder",
"filter": {
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "id",
"value": "=test-whatsapp"
}
},
"options": {}
},
"id": "3f499f2c-63d0-43e5-b2b7-40e025b89eea",
"name": "Get folder",
"type": "n8n-nodes-base.googleDrive",
"position": [
-200,
260
],
"typeVersion": 3
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
}
},
"id": "f2507cb4-016b-43c4-8574-8aa92ca0c4b8",
"name": "Download Files",
"type": "n8n-nodes-base.googleDrive",
"position": [
20,
260
],
"typeVersion": 3
},
{
"parameters": {
"dataType": "binary",
"options": {}
},
"id": "03810908-9ed7-4fe9-9b92-6e85c2b5f4de",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
400,
460
],
"typeVersion": 1
},
{
"parameters": {
"chunkSize": 300,
"chunkOverlap": 30
},
"id": "a92e9147-c912-4256-9577-1a55b7d8beed",
"name": "Token Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterTokenSplitter",
"position": [
380,
620
],
"typeVersion": 1
},
{
"parameters": {
"content": "# STEP 1\n\n## Create Qdrant Collection\nChange:\n- QDRANTURL\n- COLLECTION",
"height": 220,
"width": 880,
"color": 6
},
"id": "b7d64094-99ca-433e-9c5e-3606d35d9bb0",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
-60
],
"typeVersion": 1
},
{
"parameters": {
"mode": "insert",
"qdrantCollection": {
"__rl": true,
"mode": "id",
"value": "=COLLECTION"
},
"options": {}
},
"id": "f5cc5210-aa33-448c-a232-88f6eea79c24",
"name": "Qdrant Vector Store1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
260,
260
],
"typeVersion": 1
},
{
"parameters": {
"options": {}
},
"id": "ea39ce08-f89e-4d96-aad7-fa4deac1153a",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
280,
500
],
"typeVersion": 1.1
},
{
"parameters": {
"content": "# STEP 2\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",
"height": 400,
"width": 620,
"color": 4
},
"id": "4b7f10b6-b791-4afd-91f1-a6e0789fdbc4",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-440,
200
],
"typeVersion": 1
},
{
"parameters": {},
"id": "93555c1f-5a41-4a98-8786-2659b6bf5f8a",
"name": "Do nothing",
"type": "n8n-nodes-base.noOp",
"position": [
600,
1120
],
"typeVersion": 1
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"id": "893873bd-57a6-4e67-8fee-372f34b6b363",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-740,
1700
],
"typeVersion": 1.2
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "deepseek/deepseek-r1:free",
"cachedResultName": "deepseek/deepseek-r1:free"
},
"options": {}
},
"id": "a8dc0b16-96a1-4a2a-bcd4-65271fc2c08c",
"name": "DeepSeek",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-180,
1660
],
"typeVersion": 1.2
},
{
"parameters": {
"content": "# STEP 3 - MAIN FLOW\n\n- Transform the email into Markdown format for optimal reading by the LLM model\n- Email Summarization through DeepSeek R1 (any model can be used)\n- I classify the email in such a way as to continue only with emails regarding general information about the company. In this way I can respond independently through the information obtained from the vector database\n- I create a chain where I entrust the review of the email to a high-performance model designed for this purpose\n- I send the response email\n\n\n",
"height": 240,
"width": 1620
},
"id": "e7ddc91d-247b-463d-9777-1f163f4f0b93",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-760,
800
],
"typeVersion": 1
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"id": "25200395-cdf7-4e7c-acac-3c19e1868cda",
"name": "OpenAI 4-o-mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
140,
1280
],
"typeVersion": 1.2
}
],
"connections": {
"OpenAI": {
"ai_languageModel": [
[
{
"node": "Write email",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"DeepSeek": {
"ai_languageModel": [
[
{
"node": "Review email",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Markdown": {
"main": [
[
{
"node": "Email Summarization Chain",
"type": "main",
"index": 0
}
]
]
},
"Get folder": {
"main": [
[
{
"node": "Download Files",
"type": "main",
"index": 0
}
]
]
},
"DeepSeek R1": {
"ai_languageModel": [
[
{
"node": "Email Summarization Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Write email": {
"main": [
[
{
"node": "Review email",
"type": "main",
"index": 0
}
]
]
},
"Review email": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
},
"Download Files": {
"main": [
[
{
"node": "Qdrant Vector Store1",
"type": "main",
"index": 0
}
]
]
},
"Token Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"OpenAI 4-o-mini": {
"ai_languageModel": [
[
{
"node": "Email Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Email Classifier": {
"main": [
[
{
"node": "Write email",
"type": "main",
"index": 0
}
],
[
{
"node": "Do nothing",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Refresh collection": {
"main": [
[
{
"node": "Get folder",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Qdrant Vector Store1",
"type": "ai_document",
"index": 0
}
]
]
},
"Qdrant Vector Store": {
"ai_tool": [
[
{
"node": "Write email",
"type": "ai_tool",
"index": 0
}
]
]
},
"Email Trigger (IMAP)": {
"main": [
[
{
"node": "Markdown",
"type": "main",
"index": 0
}
]
]
},
"Email Summarization Chain": {
"main": [
[
{
"node": "Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"When clicking \u2018Test workflow\u2019": {
"main": [
[
{
"node": "Create collection",
"type": "main",
"index": 0
},
{
"node": "Refresh collection",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "37ddeef9-b7d0-40dc-938d-a1374f778657",
"id": "pYdl1ZLByQKg17lD",
"tags": []
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
AI-Powered Email Automation with RAG. Uses emailReadImap, lmChatOpenAi, emailSend, vectorStoreQdrant. Event-driven trigger; 26 nodes.
Source: https://github.com/rakshitha0902/AI-Powered-Email-Automation-with-RAG/blob/a2e4c0d80906d4189441304f8ee0222c72e635bb/AI_Powered_Email_Automation_with_RAG.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.
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 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
Chat with docs - 5minAI New version. Uses httpRequest, documentDefaultDataLoader, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi. Event-driven trigger; 62 nodes.