Skip to content

The moment it happens

Answer questions in Telegram from your own documents

People ask your Telegram bot a question and get an answer drawn from the documents stored in your Supabase table.

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

Send this to your assistant

Create a ClickRuntime automation: when someone messages my Telegram bot, search my Supabase documents table for the most relevant passages and reply with an answer based only on them.

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 training provider has handbooks, policies and course notes that students keep asking about. Staff answer the same questions in chat every day, and students waiting for a reply after hours get nothing.

A Telegram bot that searches your own documents and answers from them gives people a quick, sourced answer at any hour, and frees staff for the questions that need a person.

What you get out of it

  • Answers at any hour

    Students, customers or staff get a reply in seconds, evenings and weekends included.

  • Grounded in your material

    Replies use only the passages found in your documents, not general knowledge.

  • Fewer repeat questions for staff

    Common questions are handled by the bot; people step in for the rest.

  • Your documents stay in your database

    The knowledge lives in your own Supabase project.

How it works

What happens, step by step

  1. Someone sends your Telegram bot a question.

  2. ClickRuntime searches your Supabase documents table for the passages most related to it.

  3. AI writes an answer using only those passages.

  4. The bot replies in the same chat, splitting long answers into several messages.

Before it runs live

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

What you get

RunsThe moment it happens
Answer questions in Telegram from your own documentsjust nowSucceeded
Telegram · Northwind Help botRefunds are available within 14 days of the course start date. Email the office with your booking number.

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 Supabase 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_from_your_documents.pyexample
from clickruntime import on_event, credentials, http, ai
SUPABASE = "https://your-project.supabase.co/rest/v1"

def sb(method, path, **kw):
    key = credentials.secret("SUPABASE_KEY")
    r = http.request(method, f"{SUPABASE}/{path}", **kw, headers={"apikey": key, "Authorization": f"Bearer {key}", "Prefer": "return=representation,resolution=merge-duplicates"})
    return r.raise_for_status() or (r.json() if r.content else None)

def tg(method, **params):
    return http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/{method}", json=params).json()

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    question, chat = msg.get("text"), msg.get("chat", {}).get("id")
    if not question or question.startswith("/start"):
        return {"skipped": True}
    docs = sb("POST", "rpc/match_documents", json={"query_text": question, "match_count": 5})
    context = "\n---\n".join(d["content"][:1500] for d in docs)
    answer = ai.generate(f"Answer using only these passages. If they don't contain the answer, say you don't know and suggest contacting the team.\n"
                         f"{context}\n\nQuestion: {question}", max_output_tokens=600).text
    for i in range(0, len(answer), 4000):
        tg("sendMessage", chat_id=chat, text=answer[i:i + 4000], reply_to_message_id=msg["message_id"] if i == 0 else None)
    return {"chat": chat, "passages": len(docs)}

FAQ

Common questions

What do I need in Supabase?
A documents table with text chunks and a search function, such as a pgvector match function, already set up. Tell your AI assistant its name.
What if the answer isn't in the documents?
The bot says it doesn't know and suggests contacting a person, instead of guessing.
How long can replies be?
Telegram allows about 4,000 characters per message; longer answers are split into several messages.
What permissions does it need?
Supabase read; bot token. 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 “Answer questions in Telegram from your own documents” from your assistant

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