TeleBot_KnowledgeHub
Transform your Telegram channel into an interactive knowledge hub by automating responses to user queries with AI. This n8n workflow connects Telegram directly to advanced AI models, allowing you to upload documents via a form trigger which are then processed by a Recursive Character Text Splitter and stored in a Simple Vector Store using HuggingFace Inference for embeddings. When a user sends a message to your Telegram bot, the Telegram Message Trigger activates, fetching the chat details and feeding the query to an AI Agent powered by a Groq Chat Model. This agent leverages a Simple Memory and retrieves relevant information from your stored documents to formulate an intelligent, context-aware reply, which is then sent back to the user through Telegram. This setup is ideal for businesses offering customer support, educators managing Q&A for students, or communities providing information to members, significantly reducing manual effort in answering repetitive questions and ensuring consistent, accurate information delivery. It saves countless hours of human intervention, provides instant support, and enhances user engagement by making information readily accessible 24/7.
Workflow JSON
{"nodes": [{"parameters": {"sessionIdType": "customKey", "sessionKey": "={{ $('Telegram Message Trigger1').item.json.message.chat.id }}"}, "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow", "typeVersion": 1.3, "position": [-2576, -384], "id": "2ac4d2dd-945d-4462-bb22-d2df7c5a05fa", "name": "Simple Memory"}, {"parameters": {"mode": "retrieve-as-tool", "toolDescription": "Use this tool to retrieve any information required.", "memoryKey": {"__rl": true, "value": "vector_store_key", "mode": "list", "cachedResultName": "vector_store_key"}, "topK": 10}, "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory", "typeVersion": 1.3, "position": [-2432, -352], "id": "759cc820-fb4e-4dfc-8c67-a7db3a47df18", "name": "Retrieve documents"}, {"parameters": {"chunkSize": 3000, "chunkOverlap": 200, "options": {}}, "id": "a3ca8f55-b216-435d-a723-7d7e5da647b4", "name": "Recursive Character Text Splitter", "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter", "position": [-3488, -208], "typeVersion": 1}, {"parameters": {"mode": "insert", "memoryKey": {"__rl": true, "mode": "list", "value": "vector_store_key"}}, "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory", "typeVersion": 1.3, "position": [-3440, -560], "id": "7c32d920-7831-45a2-aef3-b51489aae91a", "name": "Simple Vector Store"}, {"parameters": {"options": {}}, "id": "315e4265-2020-4e83-b747-ee667cf4bdaf", "name": "Default Data Loader1", "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader", "position": [-3472, -352], "typeVersion": 1}, {"parameters": {"resource": "chat", "chatId": "={{ $json.message.chat.id }}"}, "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [-2832, -576], "id": "01da1111-472a-4278-9076-b5e54e9cc2c8", "name": "Get a chat1", "webhookId": "e0769871-efe3-49da-81a5-2f88a6fdd33f", "credentials": {"telegramApi": {"id": "", "name": "[Your telegramApi]"}}}, {"parameters": {"formTitle": "Upload your data to test RAG", "formFields": {"values": [{"fieldLabel": "Upload your file(s)", "fieldType": "file", "acceptFileTypes": ".pdf, .csv"}]}, "options": {}}, "type": "n8n-nodes-base.formTrigger", "typeVersion": 2.2, "position": [-3696, -560], "id": "ccae11fa-63fd-416e-ab91-d1721d388b4d", "name": "Upload your file here", "webhookId": "82848bc4-5ea2-4e5a-8bb6-3c09b94a8c5d"}, {"parameters": {"promptType": "define", "text": "={{ $('Telegram Message Trigger1').item.json.message.text }}", "options": {"systemMessage": "=You are an helplful AI Assistant Provide answers to user query based only on knowledgebase.Do Not provide any edectra knowledge apart from knowledgebase", "maxIterations": 10}}, "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 2.2, "position": [-2672, -576], "id": "a8ed394d-cf4f-4aa5-bdbe-1f893dc34782", "name": "AI Agent1"}, {"parameters": {"model": "llama-3.1-8b-instant", "options": {}}, "type": "@n8n/n8n-nodes-langchain.lmChatGroq", "typeVersion": 1, "position": [-2672, -384], "id": "a3ddcc9d-1528-4b2a-8a5d-2257f764da47", "name": "Groq Chat Model", "credentials": {"groqApi": {"id": "", "name": "[Your groqApi]"}}}, {"parameters": {"options": {}}, "type": "@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference", "typeVersion": 1, "position": [-3648, -336], "id": "314aecad-e499-48e0-8e36-0282a2c22895", "name": "Embeddings HuggingFace Inference", "credentials": {"huggingFaceApi": {"id": "", "name": "[Your huggingFaceApi]"}}}, {"parameters": {"chatId": "={{ $('Telegram Message Trigger1').item.json.message.chat.id }}", "text": "={{ $json.output }}", "additionalFields": {"appendAttribution": false}}, "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [-2352, -576], "id": "5aa1edba-e5d5-4383-8150-60b56cb7f2e4", "name": "Reply in Telegram1", "webhookId": "b96b7a41-9806-455f-b72e-00aa638eda71", "credentials": {"telegramApi": {"id": "", "name": "[Your telegramApi]"}}}, {"parameters": {"updates": ["*"], "additionalFields": {"download": false}}, "id": "9d4e56d0-e7fd-4f5e-bba6-cdc207accfa7", "name": "Telegram Message Trigger1", "type": "n8n-nodes-base.telegramTrigger", "typeVersion": 1.2, "position": [-2992, -576], "webhookId": "55acc711-c248-4ac9-b6cd-e295c2d33f4b", "credentials": {"telegramApi": {"id": "", "name": "[Your telegramApi]"}}}, {"parameters": {"options": {}}, "type": "@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference", "typeVersion": 1, "position": [-2432, -176], "id": "d006eda4-cbd6-439f-9878-fd065ce2b7bf", "name": "Embeddings HuggingFace Inference1", "credentials": {"huggingFaceApi": {"id": "", "name": "[Your huggingFaceApi]"}}}, {"parameters": {"content": "", "height": 656, "width": 912}, "type": "n8n-nodes-base.stickyNote", "position": [-4032, -672], "typeVersion": 1, "id": "e8facbae-ec41-492a-b3e0-c267fb6b941c", "name": "Sticky Note"}, {"parameters": {"content": "", "height": 656, "width": 912}, "type": "n8n-nodes-base.stickyNote", "position": [-3008, -672], "typeVersion": 1, "id": "987e71c5-a8f5-4a22-894e-5dec4a4c3722", "name": "Sticky Note1"}], "connections": {"Simple Memory": {"ai_memory": [[{"node": "AI Agent1", "type": "ai_memory", "index": 0}]]}, "Retrieve documents": {"ai_tool": [[{"node": "AI Agent1", "type": "ai_tool", "index": 0}]]}, "Recursive Character Text Splitter": {"ai_textSplitter": [[{"node": "Default Data Loader1", "type": "ai_textSplitter", "index": 0}]]}, "Default Data Loader1": {"ai_document": [[{"node": "Simple Vector Store", "type": "ai_document", "index": 0}]]}, "Get a chat1": {"main": [[{"node": "AI Agent1", "type": "main", "index": 0}]]}, "Upload your file here": {"main": [[{"node": "Simple Vector Store", "type": "main", "index": 0}]]}, "AI Agent1": {"main": [[{"node": "Reply in Telegram1", "type": "main", "index": 0}]]}, "Groq Chat Model": {"ai_languageModel": [[{"node": "AI Agent1", "type": "ai_languageModel", "index": 0}]]}, "Embeddings HuggingFace Inference": {"ai_embedding": [[{"node": "Simple Vector Store", "type": "ai_embedding", "index": 0}]]}, "Telegram Message Trigger1": {"main": [[{"node": "Get a chat1", "type": "main", "index": 0}]]}, "Embeddings HuggingFace Inference1": {"ai_embedding": [[{"node": "Retrieve documents", "type": "ai_embedding", "index": 0}]]}}, "pinData": {}, "meta": {"templateId": "voice_assistant_agent_with_telegram", "templateCredsSetupCompleted": true, "instanceId": "4223d451d431f37003ec5182bb9d912b844ad3ae10017bc814f4557fca8b9a12"}}How to Import This Workflow
- 1Copy the workflow JSON above using the Copy Workflow JSON button.
- 2Open your n8n instance and go to Workflows.
- 3Click Import from JSON and paste the copied workflow.
Don't have an n8n instance? Start your free trial at n8nautomation.cloud
Related Templates
Telegram AI multi-format chatbot
Automate a multi-format AI chatbot on Telegram, allowing users to interact via text or voice. This workflow connects Telegram for user input and replies with OpenAI for AI processing and voice-to-text conversion. It's ideal for customer support, content generation, or interactive learning platforms. This saves significant time and effort in managing diverse user interactions.
Post New YouTube Videos to X
Automatically share your latest YouTube video content on X (formerly Twitter) with this powerful n8n workflow. This automation regularly checks your YouTube channel for new uploads, then leverages OpenAI's ChatGPT to craft engaging X posts, and finally publishes them directly to your X account. Content creators, businesses, and marketers can use this to maintain a consistent social media presence, ensuring their audience on X is immediately notified of new video releases without manual intervention. This workflow eliminates the need to constantly monitor your YouTube channel and manually compose social media updates, saving significant time and effort while boosting content visibility and audience engagement.
Discord AI bot
Automate the intelligent routing of incoming user requests from a webhook to the appropriate Discord department with this powerful workflow. This n8n workflow leverages OpenAI's advanced natural language processing to analyze user input, then directs the request to either the User Success Dept, IT Dept, or Helpdesk Discord channel based on the identified category. Imagine a customer submitting a query through a web form; this workflow instantly understands their need and posts it in the relevant team's Discord channel, eliminating manual triage and ensuring faster response times. This solution is ideal for businesses and support teams looking to streamline their customer service operations, reduce response delays, and improve internal communication by automatically categorizing and distributing inquiries, saving significant time and effort in managing support tickets.