Telegram RAG bot answering from uploaded knowledge base files
Loading workflow…
Workflow Description
This workflow links a Telegram message trigger to a Groq-powered AI Agent (llama-3.1-8b-instant) with per-chat window memory and an in-memory vector store. PDF/CSV files uploaded through a web form are split into 3000-character chunks (200 overlap), embedded with HuggingFace Inference, and indexed under the key vector_store_key. Incoming Telegram messages are passed to the agent, which uses a retrieval-as-tool node (top 10 results) restricted by a system message to answer only from the knowledge base, then replies in the same chat without attribution.
How it works
- 1.A Telegram trigger listens for all updates and a Get a chat node resolves the chat from its ID.
- 2.The message text is sent to an AI Agent whose system message limits answers to the knowledge base, with max 10 iterations.
- 3.The agent calls the Retrieve documents tool to fetch the top 10 chunks from the shared vector_store_key store.
- 4.The agent runs on the Groq chat model and keeps context via window memory keyed by the Telegram chat ID.
- 5.The agent output is sent back to the same Telegram chat with attribution disabled.
- 6.Files uploaded via the web form are loaded, split, embedded, and inserted into the in-memory vector store.
Use cases
- Internal Q&A assistant over uploaded policy PDFs or CSV reports on Telegram.
- Customer support bot restricted to product documentation without outside knowledge.
- Quick RAG prototype before moving to a persistent vector database.
Requirements
- Telegram credentials with a valid bot token for the trigger, get-chat, and send nodes.
- Groq API credential to run the llama-3.1-8b-instant model.
- HuggingFace Inference access token for both embedding nodes (insert and retrieve).
- The form trigger URL must be shared so users can upload PDF/CSV files.
- Note that the in-memory store is not persistent and is lost when executions restart.
Setup and testing in n8n
- Activate the workflow, open the form URL, and upload a small PDF or CSV file.
- Ask a question in Telegram about the file content and confirm the reply arrives in the same chat.
- Ask about a topic not in the documents and verify the bot declines to answer beyond the knowledge base.
- Send follow-up questions to confirm chat memory retains conversation context.
- Inspect the execution log to confirm the retrieval tool is called and iterations stay within 10.
Service Value
Ready-made workflow template for automation delivery and service execution.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (15)
Simple Memory
Memory Buffer Window
Retrieve documents
Vector Store In Memory
Recursive Character Text Splitter
Text Splitter Recursive Character Text Splitter
Simple Vector Store
Vector Store In Memory
Default Data Loader1
Document Default Data Loader
Get a chat1
Set
Upload your file here
Form Trigger
AI Agent1
Agent
Groq Chat Model
Lm Chat Groq
Embeddings HuggingFace Inference
Embeddings Hugging Face Inference
Reply in Telegram1
Set
Telegram Message Trigger1
Set
Embeddings HuggingFace Inference1
Embeddings Hugging Face Inference
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Source and license
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides