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.
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
Someone sends your Telegram bot a question.
ClickRuntime searches your Supabase documents table for the passages most related to it.
AI writes an answer using only those passages.
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
Build your own
Need it to work differently?
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
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?
What if the answer isn't in the documents?
How long can replies be?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Run a Telegram assistant that remembers each user
Your Telegram bot replies with AI and remembers each user's recent messages, stored in your Supabase tables, so conversations stay in context.
See how it worksAdd and list Supabase records from Telegram commands
You type /add, /list or /delete to your Telegram bot and the matching rows in your Supabase table are created, shown or removed.
See how it worksCheck form sign-ups, save them to Supabase and ping Telegram
Each customer your form sends is checked, saved to Supabase unless they already exist, and you get a Telegram message either way.
See how it worksKeep exploring
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.