Skip to content

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.

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 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

  1. When you send a message to your Telegram bot, ClickRuntime checks that it came from your account and loads your last few messages.

  2. AI decides whether answering needs current information from the web.

  3. If it does, ClickRuntime searches Google through SerpApi and passes the top results along.

  4. 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

RunsThe moment it happens
A Telegram assistant that searches the web when it needs tojust nowSucceeded
Telegram · AssistantNorthwind Print on Mill Street is open Sunday 10:00 to 16:00. Want me to draft the order email?

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 SerpApi 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.
personal_assistant_bot_with_web_search.pyexample
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?
The last ten messages in the chat, yours and its own. Older messages drop off so replies stay focused.
How does it decide to search?
AI looks at each message and decides whether the answer depends on recent or local facts, such as news, prices or opening hours. If so, it searches Google first and uses the results.
Can I clear the conversation?
Yes. Send /reset and the bot forgets the recent history and starts fresh.
What permissions does it need?
SerpApi key; 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 “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.