Skip to content

The moment it happens

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.

Runs
The moment it happens
Apps
Google Drive, Telegram
AI
Not needed
Access
Telegram bot token; Drive write

Send this to your assistant

Create a ClickRuntime automation: when a file or photo is sent to my Telegram bot, save it to Drive in a folder per sender and date and reply with the link.

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 property maintenance company has workers sending photos of finished jobs, receipts and meter readings through Telegram all day. The office then saves each one by hand, or more often does not, and the photo needed for a client dispute three months later is lost in a chat.

This automation files every photo and document sent to the company bot in Drive, organised by who sent it and when, so nothing is lost and anything can be found later.

What you get out of it

  • Nothing gets lost in chat history

    Every photo and file is saved to Drive the moment it is sent, so it survives phone changes and deleted chats.

  • Organised without effort

    Folders by sender and date mean you can find last Tuesday's photos from one worker in a few clicks.

  • Proof when you need it

    Job photos and receipts are stored with their date, which settles questions from clients and accountants.

  • Senders know it worked

    The bot replies with a Drive link, so the sender can see the file was saved and share the link if needed.

How it works

What happens, step by step

  1. Someone sends a photo or file to your Telegram bot.

  2. ClickRuntime downloads the file from Telegram.

  3. It finds the folder for that sender and today's date in Drive, and creates it if it does not exist yet.

  4. It saves the file there and replies in Telegram with the link.

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
Save files and photos sent to Telegram in Drivejust nowSucceeded
Telegram · Files botSaved to Drive › alex › 2026-11-03: northwind-boiler-after.jpg

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.
telegram_files_and_photos_saved_to_drive.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from datetime import date
from googleapiclient.http import MediaInMemoryUpload
from clickruntime import on_event, credentials, http

ROOT = "your-telegram-uploads-folder-id"

def folder(drive, name, parent):
    q = f"name='{name}' and '{parent}' in parents and mimeType='application/vnd.google-apps.folder' and trashed=false"
    found = drive.files().list(q=q, fields="files(id)").execute()["files"]
    return found[0]["id"] if found else drive.files().create(body={"name": name, "parents": [parent],
           "mimeType": "application/vnd.google-apps.folder"}, fields="id").execute()["id"]

@on_event
def handle(event):
    m = (event.json or {}).get("message", {})
    item = m.get("document") or (m.get("photo") or [None])[-1]
    if not item:
        return {"skipped": True}
    tg = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
    path = http.get(f"{tg}/getFile", params={"file_id": item["file_id"]}).json()["result"]["file_path"]
    data = http.get(f"https://api.telegram.org/file/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/{path}").content
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    sender = m["from"].get("username") or m["from"]["first_name"]
    parent = folder(drive, date.today().isoformat(), folder(drive, sender, ROOT))
    f = drive.files().create(body={"name": item.get("file_name", path.split("/")[-1]), "parents": [parent]},
                             media_body=MediaInMemoryUpload(data), fields="webViewLink").execute()
    http.post(f"{tg}/sendMessage", json={"chat_id": m["chat"]["id"], "text": f"Saved: {f['webViewLink']}"})
    return {"saved": True}

FAQ

Common questions

What kinds of files are saved?
Photos, documents, videos and voice messages. Photos are saved at the highest resolution Telegram provides.
Can I limit who can send files to the bot?
Yes. You can list the Telegram users allowed to use it, and files from anyone else are ignored.
Is there a size limit?
Telegram bots can download files up to 20 MB. Larger files need to be shared another way, such as a direct Drive upload.
What permissions does it need?
Telegram bot token; Drive write. 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 “Save files and photos sent to Telegram in Drive” from your assistant

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