Skip to content

The moment it happens

Search your Gmail by messaging a Telegram bot

Ask your Telegram bot for an email in plain words and get the best matches back in the chat.

Runs
The moment it happens
Apps
Gmail, Telegram
AI
Yes, uses the built-in AI allowance
Access
Telegram bot token; Gmail gmail.readonly

Send this to your assistant

Create a ClickRuntime automation: when I message my Telegram bot a request, turn it into a Gmail search and reply with the top matches.

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 site manager spends the day away from his laptop. A supplier calls asking about a quote sent last month, and finding it on his phone means opening Gmail, guessing search terms and scrolling through results with a thumb.

Typing what he remembers to a Telegram bot, such as the quote from Northwind about steel in September, gets him the matching emails in seconds. He can answer the call without going back to the office.

What you get out of it

  • Find emails in plain words

    You describe what you need as you would to a colleague. The bot works out the search for you.

  • Fast answers on the move

    Results come back in the chat you already use on your phone, with sender, date and subject.

  • No search syntax to remember

    Dates, senders and attachments are turned into the right search without you typing special terms.

  • Only you can use it

    The bot answers your own chat only, so nobody else can search your inbox through it.

How it works

What happens, step by step

  1. It starts when you send a message to your Telegram bot.

  2. It checks the message came from your own chat and ignores anyone else.

  3. AI turns your request into a Gmail search.

  4. ClickRuntime finds the top matches in your Gmail and replies in the chat with sender, date and subject.

Before it runs live

  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
  • Connect Telegram
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Search your Gmail by messaging a Telegram botjust nowSucceeded
Telegram · Mail searchSearch: from:northwind.com steel quote after:2026/09/01. Tue, 9 Sep 2026 | Northwind Metals | Quote 4471: steel beams

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 Gmail 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.
search_gmail_from_telegram.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http, ai

MY_CHAT_ID = 123456789

@on_event
def handle(event):
    msg = event.event.get("message", {})
    if msg.get("chat", {}).get("id") != MY_CHAT_ID or not msg.get("text"):
        return {"ignored": True}
    query = ai.generate(f"Turn this request into a single Gmail search query. Reply with the query only.\n{msg['text']}",
                        max_output_tokens=60).text.strip()
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    ids = gmail.users().messages().list(userId="me", q=query, maxResults=5).execute().get("messages", [])
    lines = []
    for m in ids:
        full = gmail.users().messages().get(userId="me", id=m["id"], format="metadata", metadataHeaders=["From", "Date", "Subject"]).execute()
        h = {x["name"]: x["value"] for x in full["payload"]["headers"]}
        lines.append(f"{h.get('Date', '')[:16]} | {h.get('From')} | {h.get('Subject')}")
    text = f"Search: {query}\n" + ("\n".join(lines) or "No matches.")
    http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/sendMessage",
              json={"chat_id": MY_CHAT_ID, "text": text})
    return {"results": len(lines)}

FAQ

Common questions

What can I ask for?
Anything you would search for in Gmail: emails from a person or company, about a topic, within a date range or with attachments. For example, invoices from Acme last month.
How many results does it send?
The top five matches, each with sender, date, subject and the first line. You can ask for more in a follow-up message.
Can other people message my bot?
The bot only replies to your own Telegram chat. Messages from anyone else are ignored.
What permissions does it need?
Telegram bot token; Gmail gmail.readonly. 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 “Search your Gmail by messaging a Telegram bot” from your assistant

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