Every 10 minutes
File email attachments in Drive and get a summary on Telegram
PDFs and images you receive by email are saved in Drive, and you get a short summary with the link on Telegram.
- Runs
- Every 10 minutes
- Apps
- Google Drive, Telegram
- AI
- Yes, uses the built-in AI allowance
- Access
- Drive write; Telegram bot token
Send this to your assistant
Create a ClickRuntime automation: when an email with a PDF or image arrives, save the file to Drive, summarise it and send me the summary and link on Telegram.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A property manager receives contracts, inspection reports and photos from tenants and contractors by email all day. Reading each attachment at a desk is not realistic, so documents wait until the evening and urgent ones are spotted late.
This automation saves every PDF or image attachment to a Drive folder and sends you a short summary on Telegram with the link. You know what arrived and whether it needs attention without opening your inbox.
What you get out of it
Know what a document says before you open it
A two-line summary tells you whether an attachment is routine or urgent, so you can decide on the spot.
Attachments filed as they arrive
Every file is stored in one Drive folder, so you are not searching old emails to find last month's report.
Updates reach you on the move
Telegram messages are easy to read between site visits, where a full inbox is not.
Each attachment handled once
Attachments are saved and summarised a single time, so your chat and folder stay free of duplicates.
How it works
What happens, step by step
Every few minutes ClickRuntime checks your Gmail for new emails with PDF or image attachments.
Emails it has already handled are skipped.
Each attachment is saved in your chosen Drive folder.
AI writes a short summary, and you get it on Telegram with a link to the file.
Before it runs live
- Connect Google Drive
- Connect Telegram
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 Google Drive and Telegram steps into one automation
Under the hood
The code that runs this automation
import base64
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from googleapiclient.http import MediaInMemoryUpload
from clickruntime import on_trigger, credentials, http, ai, state, report_fetched
FOLDER_ID, CHAT_ID = "your-drive-folder-id", "your-telegram-chat-id"
@on_trigger
def run(event):
creds = Credentials(credentials.connection("google", "work"))
gmail = build("gmail", "v1", credentials=creds, cache_discovery=False)
seen = set(state.get("seen") or [])
msgs = [m for m in gmail.users().messages().list(userId="me", q="has:attachment (filename:pdf OR filename:jpg OR filename:png) newer_than:1d")
.execute().get("messages", []) if m["id"] not in seen]
report_fetched(len(msgs))
if not msgs:
return {"files": 0}
drive, token = build("drive", "v3", credentials=creds, cache_discovery=False), credentials.secret("TELEGRAM_BOT_TOKEN")
for m in msgs:
msg = gmail.users().messages().get(userId="me", id=m["id"]).execute()
for p in [p for p in msg["payload"].get("parts", []) if p.get("filename")]:
data = gmail.users().messages().attachments().get(userId="me", messageId=m["id"], id=p["body"]["attachmentId"]).execute()["data"]
f = drive.files().create(body={"name": p["filename"], "parents": [FOLDER_ID]}, fields="id,webViewLink",
media_body=MediaInMemoryUpload(base64.urlsafe_b64decode(data), mimetype=p["mimeType"])).execute()
summary = ai.generate(f"Summarise in two lines what this attachment is, given the email:\n{msg['snippet']}\nFile: {p['filename']}",
max_output_tokens=120).text
http.post(f"https://api.telegram.org/bot{token}/sendMessage", json={"chat_id": CHAT_ID, "text": f"📎 {p['filename']}\n{summary}\n{f['webViewLink']}"})
seen.add(m["id"])
state.set("seen", list(seen)[-1000:])
return {"emails": len(msgs)}FAQ
Common questions
Which attachments are included?
Where are the files saved?
How long is the summary?
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
Publish videos dropped into a Drive folder and get the links on Telegram
Drop a video into your Drive To post folder and it is captioned, published through your posting service, and the links arrive on Telegram.
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 worksGenerate images from Telegram messages and keep them in Drive
Describe an image to your Telegram bot and it sends back the picture and saves a copy in your Drive AI images folder.
See how it worksKeep exploring
Set up “File email attachments in Drive and get a summary on Telegram” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.