{
  "name": "Chat with your PDF documents using PageIndex vectorless RAG via Telegram",
  "nodes": [
    {
      "id": "cb4bce05-a6d3-40a6-8611-d1b5f9ecde1b",
      "name": "Sticky Note - Summary",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4224,
        2016
      ],
      "parameters": {
        "width": 608,
        "height": 576,
        "content": "##  🧠 Workflow Summary\n\n**PageIndex Vectorless RAG Bot**\n\n\nThis workflow builds a vectorless RAG system using [PageIndex](https://pageindex.ai) — no embeddings, no vector database. PageIndex builds a "
      }
    },
    {
      "id": "669aff95-ffe9-499d-97d0-5f9d3a02054f",
      "name": "Sticky Note - Flow 1 Header",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4848,
        2016
      ],
      "parameters": {
        "width": 856,
        "height": 96,
        "content": "## 📄 Flow 1 -> PDF Knowledge Upload\nRun this flow by sending a PDF file to the Telegram bot. The PDF is downloaded and indexed on PageIndex cloud. Run once per document."
      }
    },
    {
      "id": "e5526cd9-4df7-48a8-8098-77fb89f4188f",
      "name": "Sticky Note - Receive PDF",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4848,
        2128
      ],
      "parameters": {
        "width": 258,
        "height": 472,
        "content": "### 📎 Receive PDF Document\n**Purpose:** Entry point for PDF upload flow. Listens for incoming Telegram messages that contain a file/document.\n\n**Input:** Telegram message with a PDF attachment\n**Outpu"
      }
    },
    {
      "id": "ebbd31aa-c73c-4489-ac06-563ed1107fd4",
      "name": "Sticky Note - Download PDF",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5120,
        2128
      ],
      "parameters": {
        "width": 274,
        "height": 472,
        "content": "### ⬇️ Download PDF File\n**Purpose:** Downloads the PDF binary from Telegram's file storage using the `file_id`.\n\n**Input:** `message.document.file_id` from Telegram Trigger\n**Output:** Binary PDF fil"
      }
    },
    {
      "id": "2a06e5cd-e74d-4ab1-a82a-a21b2ac9b1b0",
      "name": "Sticky Note - Index PDF",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5408,
        2128
      ],
      "parameters": {
        "width": 290,
        "height": 472,
        "content": "### ☁️ Index PDF on PageIndex\n**Purpose:** Uploads the PDF to PageIndex cloud. PageIndex builds a hierarchical tree index (TOC) using LLM - no vectors.\n\n**Input:** Binary PDF data\n**Output:** `doc_id`"
      }
    },
    {
      "id": "57988369-c99a-4be1-b8c6-a8e80749f56d",
      "name": "Receive PDF Document",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        4928,
        2432
      ]
    },
    {
      "id": "35a146e0-cba2-4e9a-a766-821f5becea38",
      "name": "Download PDF File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5216,
        2432
      ]
    },
    {
      "id": "140249e8-c6f3-4e70-a6b7-e32dd3023320",
      "name": "Index PDF on PageIndex",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5504,
        2432
      ]
    },
    {
      "id": "04057de2-5fec-45fb-8824-68a204192fd4",
      "name": "Sticky Note - Flow 2 Header",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4224,
        2624
      ],
      "parameters": {
        "width": 1466,
        "height": 80,
        "content": "## 💬 Flow 2 -> Q&A Chat\nRun this flow by sending any text message to the Telegram bot. It fetches all indexed docs, sends the question to PageIndex LLM reasoning, and returns a cited answer to the sam"
      }
    },
    {
      "id": "64697575-d379-4f4d-8d3e-2666019ebd6d",
      "name": "Sticky Note - Receive Question",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4224,
        2720
      ],
      "parameters": {
        "width": 290,
        "height": 519,
        "content": "### 💬 Receive User Question\n**Purpose:** Entry point for Q&A flow. Listens for text messages sent to the Telegram bot.\n\n**Input:** Telegram text message from user\n**Output:** `message.text` (the quest"
      }
    },
    {
      "id": "622fbf87-1349-4de5-82ba-27fdf02e49d8",
      "name": "Sticky Note - Fetch Docs",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4528,
        2720
      ],
      "parameters": {
        "width": 258,
        "height": 519,
        "content": "### 📚 Fetch All Indexed Documents\n**Purpose:** Retrieves the list of all documents already indexed in your PageIndex account.\n\n**Input:** PageIndex API key (header)\n**Output:** Array of document objec"
      }
    },
    {
      "id": "6fb9f267-cb04-4155-82f8-9eae020cefdb",
      "name": "Sticky Note - Extract IDs",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4800,
        2720
      ],
      "parameters": {
        "width": 258,
        "height": 519,
        "content": "### 🔑 Extract Document IDs\n**Purpose:** Maps the documents array into a clean array of `doc_id` strings for use in the chat API.\n\n**Input:** `documents` array from PageIndex\n**Output:** `doc_ids` arra"
      }
    },
    {
      "id": "534a8b8e-f17c-4042-a2ac-d2ed8706bb4d",
      "name": "Sticky Note - LLM Reasoning",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5072,
        2720
      ],
      "parameters": {
        "width": 338,
        "height": 519,
        "content": "### 🧠 LLM Reasoning over Document Tree\n**Purpose:** Core RAG step. Sends the user question + all doc_ids to PageIndex. The LLM reasons over the hierarchical tree index to find and retrieve the most re"
      }
    },
    {
      "id": "f4cc58b5-26fd-4096-bef2-785a5f294d90",
      "name": "Sticky Note - Send Answer",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5424,
        2720
      ],
      "parameters": {
        "width": 274,
        "height": 519,
        "content": "### 📤 Send Answer to User\n**Purpose:** Delivers the LLM-generated answer back to the user on Telegram.\n\n**Input:** `choices[0].message.content` from PageIndex response\n**Output:** Text message sent to"
      }
    },
    {
      "id": "369a3577-6c59-4d02-a551-a6cab6308a20",
      "name": "Receive User Question",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        4320,
        3040
      ]
    },
    {
      "id": "22cab621-7b73-465f-81e1-8531cb3fcfcc",
      "name": "Fetch All Indexed Documents",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4608,
        3040
      ]
    },
    {
      "id": "e320a50f-32a7-4bcc-a9c6-d9e09192652d",
      "name": "Extract Document IDs",
      "type": "n8n-nodes-base.set",
      "position": [
        4880,
        3040
      ]
    },
    {
      "id": "b697c98a-4b45-446b-8a72-0765b411e305",
      "name": "LLM Reasoning over Document Tree",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5200,
        3040
      ]
    },
    {
      "id": "9632028b-74b7-46f2-897b-7b22ed91de11",
      "name": "Send Answer to User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5504,
        3040
      ]
    }
  ],
  "connections": {
    "Download PDF File": {
      "main": [
        [
          {
            "node": "Index PDF on PageIndex",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Document IDs": {
      "main": [
        [
          {
            "node": "LLM Reasoning over Document Tree",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive PDF Document": {
      "main": [
        [
          {
            "node": "Download PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive User Question": {
      "main": [
        [
          {
            "node": "Fetch All Indexed Documents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Index PDF on PageIndex": {
      "main": [
        []
      ]
    },
    "Fetch All Indexed Documents": {
      "main": [
        [
          {
            "node": "Extract Document IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LLM Reasoning over Document Tree": {
      "main": [
        [
          {
            "node": "Send Answer to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}