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.
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
It starts when you send a message to your Telegram bot.
It checks the message came from your own chat and ignores anyone else.
AI turns your request into a Gmail search.
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
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 Gmail and Telegram steps into one automation
Under the hood
The code that runs this automation
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?
How many results does it send?
Can other people message my bot?
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
Reply to emails with a Telegram voice note
Answer an email by recording a quick voice note on Telegram, and a polished written reply goes out in the original thread.
See how it worksSort your inbox with AI and get urgent emails on Telegram
New emails are labelled and newsletters archived for you, and only the urgent ones reach your phone as a Telegram message.
See how it worksGet a morning newsletter digest on Telegram
Yesterday's newsletters arrive as one short digest on Telegram at 7am, as text or a voice message.
See how it worksKeep exploring
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.