This workflow corresponds to n8n.io template #11238 — we link there as the canonical source.
This workflow follows the Agent → OpenAI Embeddings 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": "R0H2VtXiwntWQFgT",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "RAG Buyer Workflow",
"tags": [],
"nodes": [
{
"id": "101e791a-aa76-4fc0-9d6c-5e1de26f401b",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-448,
32
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "6973ece8-4835-4c38-ba94-4dd71dc89c22",
"name": "Set 'Text'",
"type": "n8n-nodes-base.set",
"position": [
112,
32
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234",
"name": "text",
"type": "string",
"value": "={{ $json.message.text }}"
},
{
"id": "f5c168de-4e80-4e0e-a2e2-7161eba7ddb4",
"name": "chat_ID",
"type": "string",
"value": "={{ $json.message.chat.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "1e2849ca-6579-4955-86d0-26b017644f0c",
"name": "Download Voice File",
"type": "n8n-nodes-base.telegram",
"position": [
64,
-160
],
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "2eaeee5e-2c4d-48f4-b7df-f08a8e1f8b50",
"name": "Transcribe Audio",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
208,
-160
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "transcribe"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.6
},
{
"id": "cc05d303-217b-4628-9e13-3f9c766a9735",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
-176,
32
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice.file_id }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "c6b94515-1390-4c4f-ad94-f3f4f7fa2ea8",
"name": "Response",
"type": "n8n-nodes-base.telegram",
"position": [
768,
-80
],
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "190140a1-e79a-47e9-9c0b-3634739eba4a",
"name": "AI Agent1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
400,
0
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemMessage": "=Role & Behavior:\n\nYou are a friendly, professional support agent for a men\u2019s clothing store who can understand english. Dont provide support about anything else. Reply in the same language the customer is speaking or writing in.\n\nAlways respond with empathy, clarity, and patience.\n\nKeep responses clear, accurate, and precise based on your knowledge base and user's query. Dont make up your own answers.\n\nResponsibilities\n\nCustomer Support\n\nUse the RAG tool to fetch the most accurate and up-to-date information.\n\nProvide price, brand, product info & key features of product based on the customer requests.\n\nIf no exact answer is found, be honest and suggest alternatives or next steps.\n\nTone & Communication:\n\nAlways acknowledge customer concerns politely.\n\nKeep explanations simple and easy to understand.\n\nMaintain a supportive and professional tone in every message.\n\nOrder Handling:\n\nYou are responsible for taking customer orders.\n\nTo record an order, you must collect all four details:\n\n1. Name\n2. Phone Number\n3. Address\n4. Category of Product\n\nDo not record the order until all four details are provided and you have them in your memory.\n\nOnce all details are collected, record the order using the Google Sheet tool."
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "073c3999-6863-4ff1-bc27-e202b1425817",
"name": "Answer questions with a vector store1",
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
"position": [
704,
304
],
"parameters": {
"name": "mens_clothing_info",
"description": "Use this tool to answer every questions by the user regarding men's clothing store."
},
"typeVersion": 1
},
{
"id": "ecd39fca-e517-402a-9c3d-58f37e9aeb25",
"name": "Pinecone Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
"position": [
608,
432
],
"parameters": {
"options": {
"pineconeNamespace": "mens-collection"
},
"pineconeIndex": {
"__rl": true,
"mode": "list",
"value": "mens-collection",
"cachedResultName": "mens-collection"
}
},
"credentials": {
"pineconeApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "e9e31ca3-139e-4349-917d-b1f775757db4",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
752,
544
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "53526095-5d9a-489d-ace3-8a2c8f4b7186",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
224,
336
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-nano",
"cachedResultName": "gpt-4.1-nano"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "ddd139ef-d700-422e-af70-c197dc48ebe9",
"name": "OpenAI Chat Model4",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
928,
432
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-nano",
"cachedResultName": "gpt-4.1-nano"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "a1f3e17f-5a41-4b09-bbd3-3d6ca27b614e",
"name": "Append row in sheet in Google Sheets",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
1200,
144
],
"parameters": {
"columns": {
"value": {
"Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Name', ``, 'string') }}",
"Address": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Address', ``, 'string') }}",
"Category": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Category', ``, 'string') }}",
"Phone number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone_number', ``, 'string') }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Phone number",
"type": "string",
"display": true,
"required": false,
"displayName": "Phone number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Address",
"type": "string",
"display": true,
"required": false,
"displayName": "Address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Category",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Category",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ptg4mT5V2SbE0E_99_a5fxDOBVbpoudOKp7d5wR4KGg/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Ptg4mT5V2SbE0E_99_a5fxDOBVbpoudOKp7d5wR4KGg",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ptg4mT5V2SbE0E_99_a5fxDOBVbpoudOKp7d5wR4KGg/edit?usp=drivesdk",
"cachedResultName": "men's buyers"
},
"descriptionType": "manual",
"toolDescription": "Use this tool to record name, phone number, address and category of products of buyers of men's clothing store"
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.7
},
{
"id": "050029c8-e0a8-4022-846b-462b27a4c5fb",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
384,
336
],
"parameters": {
"sessionKey": "={{ $json.chat_ID }}",
"sessionIdType": "customKey",
"contextWindowLength": 8
},
"typeVersion": 1.3
},
{
"id": "e080c2de-8b80-4500-b21a-88156956f00a",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
-64
],
"parameters": {
"color": 4,
"width": 256,
"height": 256,
"content": "## Capturing Telegram Message \n"
},
"typeVersion": 1
},
{
"id": "4cfc35d9-2b3d-47e9-a6a6-ac4d7779c876",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-256,
-64
],
"parameters": {
"color": 5,
"width": 256,
"height": 256,
"content": "## Text/Voice Message Router\n"
},
"typeVersion": 1
},
{
"id": "3dee79ed-fe11-468c-bb49-f29a66b2dc0d",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
16,
-256
],
"parameters": {
"color": 7,
"width": 336,
"height": 256,
"content": "## Voice Message Processing\nProcesses the voice message to extract the queries"
},
"typeVersion": 1
},
{
"id": "2bb50900-46ef-4060-a2ab-4b8853ad4023",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
368,
-96
],
"parameters": {
"color": 5,
"width": 304,
"height": 240,
"content": "## RAG and Order Taking Agent\n"
},
"typeVersion": 1
},
{
"id": "0e5ab26c-5b3d-4e72-9aa2-dd7c2ac0e02b",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
176,
192
],
"parameters": {
"color": 7,
"width": 336,
"height": 272,
"content": "## Agent's Brain\nAgent uses these components to think and keep converstation in memory"
},
"typeVersion": 1
},
{
"id": "d0bc7779-143b-4e14-968a-6b22b6bda9a9",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
576,
192
],
"parameters": {
"color": 7,
"width": 496,
"height": 496,
"content": "## Agent's Store Knowledge Base\nDescription: Retrives store data from the existing knowledge base. "
},
"typeVersion": 1
},
{
"id": "ce19747c-b00c-4e1c-98d0-83b11506ce52",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1104,
64
],
"parameters": {
"color": 3,
"width": 256,
"height": 256,
"content": "## Order Registry"
},
"typeVersion": 1
},
{
"id": "6332ac42-f9e3-43a5-ab30-b42c49575f27",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
-144
],
"parameters": {
"color": 6,
"width": 256,
"height": 240,
"content": "## Bot Response Point"
},
"typeVersion": 1
},
{
"id": "6f5650cc-5e8f-4290-b894-baf0a5a27268",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-960,
-352
],
"parameters": {
"width": 400,
"height": 848,
"content": "# Overview\n## How it works:\n* Captures all incoming text and voice messages through a Telegram Trigger.\n* Detects message type using a Switch node and routes text and voice notes to the correct processing path.\n* Transcribes voice messages using OpenAI and extracts clean message content with a Set node.\n* Uses an AI Agent (GPT-4.1-nano) to generate friendly, accurate replies while maintaining conversation context with an 8-message memory window.\n* Searches your product catalog and information through a Pinecone-powered RAG system to provide prices, features, and other details with high accuracy.\n* Automatically collects customer order details and records complete orders into Google Sheets.\n* Sends final responses and confirmations back to customers through Telegram.\n\n## Setup setps:\n* Import the supplied JSON into your n8n instance.\n* Create a Telegram bot via @BotFather and add its API token in n8n.\n* Add required credentials: Telegram API, OpenAI API, Pinecone, and Google Sheets OAuth2.\n* Set up your Pinecone index, namespace, and upload your store data.\n* Prepare a Google Sheet with columns: Name, Phone number, Address, Category.\n* Update the Google Sheets node with your document ID.\n* Customize the AI Agent\u2019s system message to match your store voice and product categories.\n* Test using text and voice messages, then activate the workflow for continuous operation."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "f122a859-929f-4f61-bdcb-564c09ab1329",
"connections": {
"Switch": {
"main": [
[
{
"node": "Download Voice File",
"type": "main",
"index": 0
}
],
[
{
"node": "Set 'Text'",
"type": "main",
"index": 0
}
]
]
},
"AI Agent1": {
"main": [
[
{
"node": "Response",
"type": "main",
"index": 0
}
]
]
},
"Set 'Text'": {
"main": [
[
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent1",
"type": "ai_memory",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Transcribe Audio": {
"main": [
[
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Pinecone Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"OpenAI Chat Model4": {
"ai_languageModel": [
[
{
"node": "Answer questions with a vector store1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Download Voice File": {
"main": [
[
{
"node": "Transcribe Audio",
"type": "main",
"index": 0
}
]
]
},
"Pinecone Vector Store": {
"ai_vectorStore": [
[
{
"node": "Answer questions with a vector store1",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"Append row in sheet in Google Sheets": {
"ai_tool": [
[
{
"node": "AI Agent1",
"type": "ai_tool",
"index": 0
}
]
]
},
"Answer questions with a vector store1": {
"ai_tool": [
[
{
"node": "AI Agent1",
"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.
googleSheetsOAuth2ApiopenAiApipineconeApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow is built for e-commerce businesses, retail store owners, and entrepreneurs who want to provide intelligent customer support and seamless order taking through Telegram. If you're tired of manually answering product questions, taking orders through scattered…
Source: https://n8n.io/workflows/11238/ — 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 workflow implements an advanced AI automation agent (OpenClaw Agent) that interacts with users through Telegram and integrates multiple AI models, external tools, and cloud services to automate c
Your AI workforce is ready. Are you?
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
Who is this for? This workflow is ideal for HR teams, startups, and enterprises that want to handle employee interactions through WhatsApp and automate responses using LLM (OpenAI) and intelligent rou