This workflow corresponds to n8n.io template #5086 — we link there as the canonical source.
This workflow follows the Agent → Emailsend 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": "obE4a3B9M3SO2GcU",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "AI-Based Tour Itineraries via Email Using OpenAI & Pinecone Vector Search",
"tags": [
{
"id": "oKGIn6U0wpeHShTN",
"name": "working flow",
"createdAt": "2025-06-02T06:27:44.762Z",
"updatedAt": "2025-06-02T06:27:44.762Z"
}
],
"nodes": [
{
"id": "2949338a-7179-427c-98b9-3d7ef5cf3514",
"name": "Email Trigger (IMAP)",
"type": "n8n-nodes-base.emailReadImap",
"position": [
-180,
40
],
"parameters": {
"options": {}
},
"credentials": {
"imap": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "770f23de-8874-4a60-9480-0317d04ece42",
"name": "OpenRouter Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
-20,
220
],
"parameters": {
"options": {}
},
"credentials": {
"openRouterApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "ec10363a-a7f2-49ab-a319-de5f990fa1e5",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
560,
240
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "f8387804-8f95-4815-baa6-735f779def0e",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
720,
240
],
"parameters": {
"sessionKey": "={{ $json.ID }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "d1204780-86dc-430a-ae5f-47ec57a5d9dd",
"name": "Answer questions with a vector store",
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
"position": [
860,
220
],
"parameters": {
"description": "#Role#\nYou are an expert Tour Packaging Agent who has more than 15 years experience in travel agencies and experience in building amazing tour packages for customers.\n\n##Instructions##\nYou look into the pinecone vector database and from the packages created previously, you recreate best suitable packages for the customers and help respond back.\n\nYou always reply with politeness and friendly messages with few emojis. \n"
},
"typeVersion": 1.1
},
{
"id": "947eca6f-7d67-4d7d-8559-b113fc0c21ac",
"name": "Pinecone Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
"position": [
680,
400
],
"parameters": {
"options": {},
"pineconeIndex": {
"__rl": true,
"mode": "list",
"value": "package1536",
"cachedResultName": "package1536"
}
},
"credentials": {
"pineconeApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "495038af-b6a3-40d4-8fc5-9ec2ba4215a8",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
680,
560
],
"parameters": {
"model": "text-embedding-ada-002",
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "2480d0a9-1fcd-411e-aa34-e09890276c79",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1020,
440
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "6aa856e9-7627-4781-8b8b-7bc5efa6025e",
"name": "Tour Recommendation AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
620,
20
],
"parameters": {
"text": "={{ $json.EmailContent }}",
"options": {
"systemMessage": "You are an experienced tours and Packages travel agent who build tour packages for customers as per the request you receive. \nYour source for tours is from the pinecone vector databse, and you smartly analyse and combine the tours and activities and recommend to the customers with 3 different options. "
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "4f951769-a677-45c1-ac0d-5f22addbfccd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
-80
],
"parameters": {
"color": 4,
"width": 440,
"height": 820,
"content": "## Steps\n1. Connect to your Email using the Email Trigger (IMAP) - that reads for any incoming emails from customers. \n\n2. Text Classfier: to classify the type of emails - first time package request, follow-up email or other email and route accordingly\n\n3. Code: Extract the email content and standardise to JSON format \n\n return {\n ID: email.attributes.uid,\n Date: emailDate,\n Subject: emailSubject,\n EmailContent: emailContent,\n SenderEmail: senderEmail,\n SenderName: senderName,\n }\n\n4. Tour Recomendation AI Agent: Give appropiate System Prompt and the references to the Tools available. \n\n5. OpenaAI Model: ChatGPT-4o\n\n6. Simple memory - upto 5 context window length\n\n7. Answer Quetions with Vector Store: Add specific role and instructions to extract the tour packages from the pinecone database. \n\n8. Send Email: Construct the Email response back to the customer with the packages. \n"
},
"typeVersion": 1
},
{
"id": "5584d738-87e5-47ce-9f7b-d84c13346e5d",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
-80
],
"parameters": {
"width": 1500,
"height": 820,
"content": "## Email Workflow"
},
"typeVersion": 1
},
{
"id": "fae16194-7b96-466e-aa05-3277e9737a78",
"name": "Format email content",
"type": "n8n-nodes-base.code",
"position": [
400,
20
],
"parameters": {
"jsCode": "const emails = $input.all().map((item) => item.json);\n\nconst extractedData = emails.map((email) => {\n const emailContent = email.textPlain;\n const emailSubject = email.subject;\n const emailDate = email.date;\n const senderEmail = email.from;\n const senderName = email.from.split(\"@\")[0];// Assuming the name is the part before the '@' in the email\n\n return {\n ID: email.attributes.uid,\n Date: emailDate,\n Subject: emailSubject,\n EmailContent: emailContent,\n SenderEmail: senderEmail,\n SenderName: senderName,\n\n };\n});\n\nreturn extractedData;"
},
"typeVersion": 2
},
{
"id": "2ba1cecd-4296-4e36-a142-46c87dd4f602",
"name": "Route Workflow by Email Type",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
20,
40
],
"parameters": {
"options": {
"multiClass": false
},
"inputText": "={{ $json.textPlain }}",
"categories": {
"categories": [
{
"category": "New Request",
"description": "This is the request for Tour Package email. First email in the thread "
},
{
"category": "Followup Email",
"description": "Email that has change requests to the origin request. "
},
{
"category": "Other Email",
"description": "Any other eamil that is not related to tour packages requests. "
}
]
}
},
"typeVersion": 1
},
{
"id": "c0aae4c5-cf73-4d57-89d0-01df717af9cc",
"name": "Package Response Email",
"type": "n8n-nodes-base.emailSend",
"position": [
1020,
20
],
"parameters": {
"text": "={{ $json.output }}",
"options": {},
"subject": "={{ $('Format email content').item.json.Subject }}",
"toEmail": "={{ $('Email Trigger (IMAP)').item.json.from }}",
"fromEmail": "email",
"emailFormat": "text"
},
"credentials": {
"smtp": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "e89f71f2-10bd-4f6b-ba50-682f23428492",
"connections": {
"Simple Memory": {
"ai_memory": [
[
{
"node": "Tour Recommendation AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Tour Recommendation AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Pinecone Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Answer questions with a vector store",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Email Trigger (IMAP)": {
"main": [
[
{
"node": "Route Workflow by Email Type",
"type": "main",
"index": 0
}
]
]
},
"Format email content": {
"main": [
[
{
"node": "Tour Recommendation AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenRouter Chat Model": {
"ai_languageModel": [
[
{
"node": "Route Workflow by Email Type",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Pinecone Vector Store": {
"ai_vectorStore": [
[
{
"node": "Answer questions with a vector store",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"Route Workflow by Email Type": {
"main": [
[
{
"node": "Format email content",
"type": "main",
"index": 0
}
],
[]
]
},
"Tour Recommendation AI Agent": {
"main": [
[
{
"node": "Package Response",
"type": "main",
"index": 0
}
]
]
},
"Answer questions with a vector store": {
"ai_tool": [
[
{
"node": "Tour Recommendation AI Agent",
"type": "ai_tool",
"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.
imapopenAiApiopenRouterApipineconeApismtp
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automates the process of handling new tour package requests received via email, analyzes the request, and provides personalized tour package recommendations using AI and a vector database. It’s designed to streamline customer interactions and deliver quick,…
Source: https://n8n.io/workflows/5086/ — 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.
Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.
This workflow automates patient communication for medical clinics using the WhatsApp Business API. It supports appointment booking, rescheduling, service inquiries, follow-ups, and document submission
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
This workflow automates customer support across multiple channels (Email, Live Chat, WhatsApp, Slack, Discord) using AI-powered responses enhanced with Retrieval Augmented Generation (RAG) and your pr
BambooHR AI-Powered Company Policies and Benefits Chatbot. Uses manualTrigger, documentDefaultDataLoader, embeddingsOpenAi, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 50 nodes.