Skip to content

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.

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

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

  1. You send your Telegram bot a few words, such as a client name or "lease 2025".

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

  3. It searches file names and contents in your Google Drive for those words.

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

RunsThe moment it happens
Search Google Drive from a Telegram botjust nowSucceeded
Telegram · your bot3 files for "lease 2025": • Office lease 2025 signed.pdf (12 Jan) https://drive.google.com/file/d/1aB.../view • Lease renewal notes (3 Jan) https://docs.google.com/document/d/1xY.../edit • Lease 2025 budget (28 Dec) https://docs.google.com/spreadsheets/d/1Qr.../edit

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

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_google_drive_from_a_telegram_bot.pyexample
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?
Both. Google Drive's full text search covers file names and the text inside Docs, Sheets, PDFs and other files Drive has indexed. Scanned images without text are found only by name.
Can other people use my bot to search my Drive?
No. The script answers only your own chat ID, which you set once. Messages from anyone else are ignored and nothing is sent back to them.
Can it send me the file itself instead of a link?
Yes. Ask your assistant to download the top match and send it with Telegram's sendDocument. Files over 50 MB cannot be sent by a bot, so those still come back as a link.
What permissions does it need?
Drive read-only (drive.readonly); bot token. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's 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 Google Drive from a Telegram bot” from your assistant

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