The moment it happens
A Telegram assistant that searches the web when it needs to
Chat with your own assistant on Telegram that remembers the conversation and looks things up online when a question needs current information.
- Runs
- The moment it happens
- Apps
- SerpApi, Telegram
- AI
- Yes, uses the built-in AI allowance
- Access
- SerpApi key; bot token
Send this to your assistant
Create a ClickRuntime automation: make my Telegram bot answer my messages with AI. When a question needs current information, search Google with SerpApi first, and remember my last few messages.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A freelance designer uses an AI chat tool all day for small things: rewording an email, converting measurements, checking the opening hours of a print shop. The chat tool is in a browser tab on the laptop, which is no help when they are out, and it does not know today's news or prices.
This automation puts a personal assistant in Telegram. It keeps the last few messages so follow-up questions make sense, and decides on each message whether it needs a web search. Rewording a sentence is answered straight away; "is the Northwind print shop open on Sunday?" triggers a search first.
What you get out of it
An assistant in the app you already use
Telegram is already on your phone and laptop. The assistant is one chat away wherever you are, with no new app to install.
Searches only when it helps
Most messages do not need the web, so the bot answers them directly. Searching only for questions about current facts keeps replies fast and uses fewer SerpApi searches.
Follow-ups that make sense
Because it remembers your last few messages, you can say "make it shorter" or "what about Saturday?" without repeating yourself. It feels like a conversation, not a series of separate lookups.
Yours alone
The bot only answers your Telegram account, and the short history it keeps is cleared as new messages arrive. Nothing is shared with anyone else.
How it works
What happens, step by step
When you send a message to your Telegram bot, ClickRuntime checks that it came from your account and loads your last few messages.
AI decides whether answering needs current information from the web.
If it does, ClickRuntime searches Google through SerpApi and passes the top results along.
AI writes the reply using the conversation and any search results, and the bot sends it back to you and saves it to the recent history.
Before it runs live
- Connect SerpApi
- 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 SerpApi and Telegram steps into one automation
Under the hood
The code that runs this automation
from clickruntime import on_event, credentials, http, state, ai
OWNER_CHAT_ID = 123456789
@on_event
def handle(event):
msg = (event.json or {}).get("message") or {}
text = msg.get("text", "").strip()
if msg.get("chat", {}).get("id") != OWNER_CHAT_ID or not text:
return {"ignored": True}
if text == "/reset":
state.set("history", [])
reply = "Starting fresh."
else:
history = state.get("history") or []
query = ai.generate(f"Message: {text}\nIf answering needs current web information, reply with a Google search query. Otherwise reply NONE.", max_output_tokens=30).text.strip()
found = ""
if query != "NONE":
res = http.get("https://serpapi.com/search", params={"engine": "google", "q": query, "api_key": credentials.secret("SERPAPI_API_KEY")}).json()
found = "\n".join(f"- {r['title']}: {r.get('snippet', '')}" for r in res.get("organic_results", [])[:5])
chat = "\n".join(f"{h['who']}: {h['text']}" for h in history)
reply = ai.generate(f"{chat}\nme: {text}\n\nSearch results:\n{found or 'none'}", system="You are a concise personal assistant.", max_output_tokens=400).text.strip()
state.set("history", (history + [{"who": "me", "text": text}, {"who": "assistant", "text": reply}])[-10:])
http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/sendMessage", json={"chat_id": OWNER_CHAT_ID, "text": reply})
return {"ok": True}FAQ
Common questions
How many messages does it remember?
How does it decide to search?
Can I clear the conversation?
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
Send a topic to Telegram and get researched social posts
Message your bot a topic and get back a LinkedIn post and a post for X, written from what is being said about it on the web right now.
See how it worksAsk a Telegram bot and get answers with sources
Ask your bot any question and get a short answer based on live Google results, with the links it used.
See how it worksFind promo codes for a shop from Telegram
Send a shop name to your bot and get a list of current discount codes found on the web, with what each one claims to offer.
See how it worksKeep exploring
Set up “A Telegram assistant that searches the web when it needs to” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.
