๐Ÿ“– Chat with your PDF documents using PageIndex vectorless RAG via Telegram

โšก 388 views ยท ๐Ÿ“– Internal Wiki & Knowledge Base

Description

Build a Vectorless PDF Knowledge Bot on Telegram Using PageIndex RAG

๐Ÿ‘ค Who Is This For?

This template is built for developers, researchers, and automation builders who want to create a document Q&A system โ€” without the complexity of vector databases, embeddings, or chunking pipelines.

Itโ€™s perfect for:

โ“ What Problem Does This Solve?

Traditional RAG systems require converting text into vectors, storing them in a vector database, and relying on semantic similarity to retrieve relevant chunks. This approach has known weaknesses:

PageIndex solves this differently. Instead of vectors, it builds a hierarchical tree index (like a Table of Contents) from your PDF using an LLM. At query time, the LLM reasons over that tree โ€” identifies the most relevant sections, retrieves only those, and generates a precise, cited answer.

No embeddings. No vector DB. No chunking.

โšก What This Workflow Does

This n8n template delivers a fully working Telegram-based RAG bot with two independent flows in a single workflow:

๐Ÿ“„ Flow 1 โ†’ PDF Knowledge Upload (Run Once per Document) Send a PDF file to your Telegram bot. The workflow downloads it and uploads it to PageIndex cloud, where the tree index is built automatically.

๐Ÿ’ฌ Flow 2 โ†’ Q&A Chat (Runs Every Time) Send any question as a text message to the same Telegram bot. The workflow fetches all your indexed documents, sends the question to PageIndexโ€™s LLM reasoning engine, and delivers a cited answer back to your Telegram chat.

๐Ÿ”„ How It Works

Flow 1 - PDF Upload

  1. Receive PDF Document - Telegram Trigger listens for messages containing a file. Send any PDF to the bot to start indexing.
  2. Download PDF File - The bot downloads the binary PDF from Telegramโ€™s file storage using the file_id.
  3. Index PDF on PageIndex - The PDF is uploaded to PageIndex cloud via POST /doc/. PageIndex builds a hierarchical tree index (TOC with LLM-generated summaries per section). Returns a doc_id. No vectors are created.

Flow 2 - Q&A

  1. Receive User Question - Telegram Trigger listens for text messages. Any message triggers the Q&A flow.
  2. Fetch All Indexed Documents - Calls GET /docs on PageIndex to retrieve all previously uploaded documents.
  3. Extract Document IDs - Maps the documents list into a clean array of doc_id strings.
  4. LLM Reasoning over Document Tree - Sends the userโ€™s question + all doc_ids to PageIndex POST /chat/completions. PageIndexโ€™s LLM traverses the tree, identifies the relevant nodes, retrieves the raw text, and generates an answer with page citations.
  5. Send Answer to User The answer is delivered back to the exact Telegram user who asked, using their chat_id.

๐Ÿ› ๏ธ Setup Instructions

Step 1 - Create a Telegram Bot

  1. Open Telegram and message @BotFather
  2. Send /newbot and follow the prompts
  3. Copy the Bot Token provided
  4. In n8n, add a new Telegram credential and paste the token

Step 2 - Get Your PageIndex API Key

  1. Visit dash.pageindex.ai and create a free account
  2. Go to API Keys and generate a new key
  3. In the workflow, replace YOUR_PAGEINDEX_API_KEY in these three nodes:
    • โ˜๏ธ Index PDF on PageIndex
    • ๐Ÿ“š Fetch All Indexed Documents
    • ๐Ÿง  LLM Reasoning over Document Tree

Step 3 - Connect Telegram Credentials

Both Telegram Trigger nodes and the Telegram send node use the same credential. Set your Telegram API credentials once and n8n will apply them across all nodes automatically.

Step 4 - Activate the Workflow

  1. Click Activate in n8n
  2. Send a PDF file to your Telegram bot โ†’ it gets indexed
  3. Send any text question โ†’ get an LLM-reasoned answer back

๐Ÿ“‹ Required Credentials

ServiceWhere to GetUsed In
Telegram Bot Token@BotFather on TelegramAll Telegram nodes
PageIndex API KeyAPI Key From DashboardUpload + Chat nodes

๐Ÿ’ก How to Customize

๐Ÿ“ฆ About PageIndex

PageIndex is an open-source vectorless RAG framework by VectifyAI. It powers the Mafin 2.5 financial assistant which achieved 98.7% accuracy on FinanceBench - significantly outperforming GPT-4o (~31%) on document-intensive tasks.

๐Ÿ”ง Technical Notes

๐Ÿค Need Help?

Feel free to reach out via the n8n Community Forum or check out more automation templates on AppStoneLab Technologies.

๐Ÿ”— Nodes Used

HTTP Request, Telegram, Telegram Trigger

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup