Skip to content

The moment it happens

Ask a Telegram bot questions about your documents

Send a PDF to your bot and it is added to your library; ask a question and you get an answer drawn from those documents.

Runs
The moment it happens
Apps
Pinecone, Telegram
AI
Yes, uses the built-in AI allowance
Access
Telegram bot token; Pinecone read+write

Send this to your assistant

Create a ClickRuntime automation: when I send a PDF to my Telegram bot, add it to my Pinecone index. When I ask a question, answer from those documents and say which file the answer came from.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A small property management company keeps its tenancy agreements, building rules and contractor contracts as PDFs in a shared drive. When a tenant or a site manager asks something like "who pays for boiler repairs at Elm Court?", someone has to find the right file and read through twenty pages. The answer is usually in there, but finding it takes longer than the question deserves.

With a Telegram bot connected to a Pinecone index, staff send each PDF to the bot once. After that anyone on the team can ask a question in plain words, from their phone, and get an answer taken from the documents along with the file it came from.

What you get out of it

  • Answers in seconds, not page by page

    The bot finds the passages that match the question and answers from them. Staff stop scrolling through long PDFs for a single clause, and simple questions stop interrupting the one person who knows where everything is.

  • Works from the phone people already carry

    Site managers and field staff are rarely at a desk. Telegram is on their phone, so they can check a contract detail while standing in the building it covers.

  • Every answer names its source

    Each reply says which document the answer came from. People can open the file to check the wording before quoting it to a tenant or a supplier.

  • Adding a document is one message

    Send a new PDF and it is searchable a moment later. The library grows as the business does, without anyone maintaining a separate wiki.

  • Answers stay inside your documents

    The bot is told to answer only from what it finds in your index and to say when it does not know. That keeps it from guessing on questions where a wrong answer costs money.

How it works

What happens, step by step

  1. When you send your Telegram bot a PDF, ClickRuntime downloads it, splits the text into short passages and stores them in your Pinecone index with the file name.

  2. When you send a question instead, it searches the index for the passages closest in meaning to what you asked.

  3. AI writes a short answer using only those passages and notes which file they came from.

  4. The answer is sent back to you in the same Telegram chat, usually within a few seconds.

Before it runs live

  • Connect Pinecone
  • Connect Telegram
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Ask a Telegram bot questions about your documentsjust nowSucceeded
Telegram · Docs botBoiler repairs at Elm Court are the landlord's responsibility unless caused by tenant misuse (Northwind tenancy agreement, clause 7.2).

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Pinecone and Telegram steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
telegram_bot_that_answers_questions_about_your_documents.pyexample
import io
from pypdf import PdfReader
from clickruntime import on_event, credentials, http, ai

def embed(texts):
    r = http.post("https://api.pinecone.io/embed", headers={"Api-Key": credentials.secret("PINECONE_API_KEY"), "X-Pinecone-API-Version": "2025-01"},
                  json={"model": "multilingual-e5-large", "inputs": [{"text": t} for t in texts]})
    return [e["values"] for e in r.json()["data"]]

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    tg = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
    index = credentials.secret("PINECONE_HOST")
    pc = {"Api-Key": credentials.secret("PINECONE_API_KEY")}
    if msg.get("document"):
        path = http.get(f"{tg}/getFile", params={"file_id": msg["document"]["file_id"]}).json()["result"]["file_path"]
        pdf = http.get(f"https://api.telegram.org/file/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/{path}").content
        text = " ".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(pdf)).pages)
        chunks = [text[i:i + 1000] for i in range(0, len(text), 1000)][:90]
        name = msg["document"].get("file_name", "document")
        vectors = [{"id": f"{msg['document']['file_unique_id']}-{i}", "values": v, "metadata": {"text": c, "file": name}} for i, (c, v) in enumerate(zip(chunks, embed(chunks)))]
        http.post(f"https://{index}/vectors/upsert", headers=pc, json={"vectors": vectors})
        reply = f"Added {name} ({len(chunks)} passages)."
    else:
        matches = http.post(f"https://{index}/query", headers=pc, json={"vector": embed([msg.get("text", "")])[0], "topK": 5, "includeMetadata": True}).json()["matches"]
        context = "\n\n".join(f"[{m['metadata']['file']}] {m['metadata']['text']}" for m in matches)
        reply = ai.generate(f"Question: {msg.get('text')}\n\nPassages:\n{context}", system="Answer only from the passages and name the file. If they do not contain the answer, say so.", max_output_tokens=400).text
    http.post(f"{tg}/sendMessage", json={"chat_id": msg["chat"]["id"], "text": reply})
    return {"ok": True}

FAQ

Common questions

Which files can I send?
PDFs with selectable text work best, such as contracts, manuals and policies exported from Word or Google Docs. Scanned images without a text layer cannot be read until they are run through text recognition.
How long can a document be?
Long documents are fine. The bot splits each file into short passages before storing it, so a hundred-page manual is searchable in the same way as a two-page letter.
What happens if the answer is not in my documents?
The bot says it could not find the answer in your files rather than making one up. You can then send the missing document and ask again.
What permissions does it need?
Telegram bot token; Pinecone read+write. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Ask a Telegram bot questions about your documents” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.