Skip to content
AI Agents

Telegram RAG bot answering from uploaded knowledge base files

15 nodes 39 4 Manual trigger
Download

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. 1.A Telegram trigger listens for all updates and a Get a chat node resolves the chat from its ID.
  2. 2.The message text is sent to an AI Agent whose system message limits answers to the knowledge base, with max 10 iterations.
  3. 3.The agent calls the Retrieve documents tool to fetch the top 10 chunks from the shared vector_store_key store.
  4. 4.The agent runs on the Groq chat model and keeps context via window memory keyed by the Telegram chat ID.
  5. 5.The agent output is sent back to the same Telegram chat with attribution disabled.
  6. 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

  1. Activate the workflow, open the form URL, and upload a small PDF or CSV file.
  2. Ask a question in Telegram about the file content and confirm the reply arrives in the same chat.
  3. Ask about a topic not in the documents and verify the bot declines to answer beyond the knowledge base.
  4. Send follow-up questions to confirm chat memory retains conversation context.
  5. 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

Memory Text Splitter Document Default Data Loader Telegram Form Trigger AI Agent Lm Chat Groq Embeddings

Details

Trigger Manual trigger
Nodes 15
Apps 8
Views 39
Downloads 4

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (15)

/

Simple Memory

Memory Buffer Window

#1

Retrieve documents

Vector Store In Memory

#2

Recursive Character Text Splitter

Text Splitter Recursive Character Text Splitter

#3

Simple Vector Store

Vector Store In Memory

#4

Default Data Loader1

Document Default Data Loader

#5

Get a chat1

Set

#6

Upload your file here

Form Trigger

#7

AI Agent1

Agent

#8

Groq Chat Model

Lm Chat Groq

#9

Embeddings HuggingFace Inference

Embeddings Hugging Face Inference

#10

Reply in Telegram1

Set

#11

Telegram Message Trigger1

Set

#12

Embeddings HuggingFace Inference1

Embeddings Hugging Face Inference

#13

Sticky Note

Sticky Note

#14

Sticky Note1

Sticky Note

#15

Source and license

Sticky Note

#16
Stay in the loop

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

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime