The moment it happens
Search Google Drive from a Telegram bot
Send your bot a few words and get back links to the matching files in your Google Drive, newest first.
- Runs
- The moment it happens
- Apps
- Google Drive, Telegram
- AI
- Not needed
- Access
- Drive read-only (drive.readonly); bot token
Send this to your assistant
Create a ClickRuntime automation: when I send my Telegram bot a message like "invoice March", search my Google Drive for files matching those words and reply with the five best matches as links. Only answer messages from my own chat.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
You are away from your laptop and someone asks for last year's contract or a quote you sent. The Google Drive app works, but finding the right file on a phone means opening the app, typing in a small search box and scrolling through near matches.
With this automation your Telegram bot becomes a search box for your Drive. You send a few words, ClickRuntime runs the search with your Google connection and replies with the best matches, each with a date and a link you can forward straight on.
It suits freelancers, small business owners and anyone who lives in Telegram and keeps their files in Google Drive.
What you get out of it
Find files in the chat you already have open
No app switching. You ask in Telegram and the answer arrives in the same place you are talking to the person who needs the file.
Links you can forward
Each result is a Drive link, so you can forward the message to a client or colleague who already has access.
Searches inside documents
A word you remember from the body of a document is enough. You do not need the exact file name.
Only you can use it
The bot answers your chat and nobody else, so a public bot name does not expose your files.
Easy to extend
Ask your assistant to limit results to one folder, filter by file type, or send the top file as a document.
How it works
What happens, step by step
You send your Telegram bot a few words, such as a client name or "lease 2025".
ClickRuntime checks the message came from your own chat and ignores anyone else.
It searches file names and contents in your Google Drive for those words.
The bot replies with up to five matching files, each with its last modified date and a link that opens it.
Before it runs live
- Connect Google Drive
- 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
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Google Drive 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
OWNER = 123456789
def tg(method, **params):
r = http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/{method}", json=params)
r.raise_for_status()
return r.json()["result"]
@on_event
def handle(event):
msg = (event.json or {}).get("message", {})
chat, words = msg.get("chat", {}).get("id"), (msg.get("text") or "").strip()
if chat != OWNER or not words or words.startswith("/"):
return {"skipped": True}
drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
q = " and ".join(f"fullText contains '{w.replace(chr(39), '')}'" for w in words.split()[:5]) + " and trashed = false"
files = drive.files().list(q=q, orderBy="modifiedTime desc", pageSize=5,
fields="files(name,modifiedTime,webViewLink)").execute().get("files", [])
if not files:
tg("sendMessage", chat_id=chat, text=f"No files found for \"{words}\".")
return {"found": 0}
lines = [f"• {f['name']} ({f['modifiedTime'][:10]})\n{f['webViewLink']}" for f in files]
tg("sendMessage", chat_id=chat, text=f"{len(files)} files for \"{words}\":\n" + "\n".join(lines), disable_web_page_preview=True)
return {"found": len(files)}
FAQ
Common questions
Does it search inside documents or only file names?
Can other people use my bot to search my Drive?
Can it send me the file itself instead of a link?
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
Save files and photos sent to Telegram in Drive
Anything sent to your Telegram bot is filed in Drive in a folder for each sender and date, and the bot replies with the link.
See how it worksSave Telegram group messages to Google Drive daily
Your bot collects the messages in a Telegram group through the day and saves them as one dated text file in Google Drive each night.
See how it worksTranscribe voice notes sent to Telegram and save them to Drive
Send a voice note or audio file to your Telegram bot and get the text and a summary back, with both saved to your Transcripts folder.
See how it worksKeep exploring
Set up “Search Google Drive from a Telegram bot” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.