Animated data flow diagram

AI Agent: Telegram PDF RAG for Instant Q&A

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

Telegram OpenAI Groq Pinecone

Overview

Unlock Instant Knowledge from Your PDFs with this AI Agent

This n8n AI Agent transforms your Telegram into a powerful document interaction hub.

Two core functions:

  1. Effortless PDF Ingestion: Send a PDF document to your configured Telegram bot. The agent automatically processes it; the Default Data Loader node ingests the PDF, using the Recursive Character Text Splitter to break it into manageable chunks. OpenAI is then used to generate embeddings for these chunks, which are subsequently stored in your Pinecone vector database. You'll get a confirmation in Telegram once your document is ready.
  2. Intelligent Q&A: Send a text message (a question) to the same Telegram bot. The agent uses this question to search your Pinecone database for relevant document snippets (via OpenAI embeddings). These snippets, along with your question, are then passed to a Groq-powered LLM (Llama 3.1 70B by default) to generate a concise, context-aware answer based on your documents.

This setup empowers you to build and query a personal or team knowledge base directly through Telegram.

Key Features & Benefits

  • Dual Functionality: Seamlessly switch between uploading new PDFs and asking questions about existing ones.
  • Telegram-Native Interface: Manage your document knowledge base and get answers without leaving Telegram.
  • AI-Powered RAG: Leverages OpenAI for embeddings and Groq (Llama 3.1 70B) for sophisticated Retrieval Augmented Generation, ensuring answers are grounded in your provided PDFs.
  • Vector Storage with Pinecone: Efficiently stores and retrieves document information for fast querying.
  • Customizable & Extensible: Built on n8n, easily adapt or extend the workflow to suit your specific needs (e.g., different LLMs, vector stores, or pre/post-processing steps).
  • Automated Document Processing: Handles PDF text extraction and chunking automatically.

Use Cases

  • Quickly querying internal company documents or SOPs uploaded as PDFs.
  • Building a personal knowledge base from research papers or e-books and interacting with it via chat.
  • Providing automated customer support by answering FAQs based on product manuals in PDF format.
  • Solopreneurs rapidly extracting insights from business reports or legal documents.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • Telegram Bot API Token.
  • OpenAI API Key (for embeddings, e.g., text-embedding-ada-002).
  • Groq API Key (for chat model, e.g., Llama 3.1 70B).
  • Pinecone API Key and environment details, with an existing index (e.g., named 'telegram' with appropriate dimensions for OpenAI embeddings).

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Telegram Setup: a. Configure the 'Telegram Trigger' node: Create a new Telegram Bot credential or select an existing one. b. Configure the 'Telegram get File' node using the same credential. c. Configure both 'Telegram Response' and 'Telegram Response about Database' nodes using the same credential.
  4. OpenAI Embeddings Setup: a. Configure the 'Embeddings OpenAI' node (this is for the document ingestion path, connected to the 'Pinecone Vector Store' node): Enter your OpenAI API Key. b. Configure the 'Embeddings' node (this is another OpenAI Embeddings node, for the Q&A path, connected to 'Pinecone Vector Store1'): Enter the same OpenAI API Key.
  5. Pinecone Vector Store Setup: a. Configure the 'Pinecone Vector Store' node (this one is in 'insert' mode, for document ingestion): Enter your Pinecone API Key, environment, and specify your Pinecone index name (the workflow defaults to 'telegram'). Ensure this index exists in your Pinecone account with the correct dimension for your OpenAI embedding model (e.g., 1536 for text-embedding-ada-002). b. Configure the 'Pinecone Vector Store1' node (this one is for Q&A retrieval): Enter the same Pinecone API Key, environment, and index name.
  6. Groq LLM Setup: a. Configure the 'Groq Chat Model' node: Enter your Groq API Key and select your desired model (default is Llama 3.1 70B).
  7. (Optional) Customization: a. Review the chunkSize and chunkOverlap in the 'Recursive Character Text Splitter' node if needed for your PDF content. The current settings are 3000 and 200, respectively.
  8. Activate the Workflow: a. Save and activate the workflow. b. To load a document: Send a PDF file to your Telegram bot. You should receive a message like "X pages saved on Pinecone". c. To ask a question: Send a text message (your question) to the bot. You'll receive an answer based on the processed documents.

Tags:

AI AgentRAGTelegramPDF AutomationDocument Q&AOpenAIGroqPineconeLLMSolopreneur ToolFounder ToolProductivityAutomation

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation