Auto-save Telegram files to Google Drive by sender
Every 15 minutes, tuck away every file people send you on Telegram into a tidy Google Drive folder named after who sent it.
Build me a deterministic code workflow that archives every file someone sends me on Telegram into a Google Drive folder organized by sender. This is a fixed pipeline, not an agent making decisions.
Trigger: cron, every 15 minutes.
Steps, in order:
1. Call telegram-secretary Receive Updates to pull the newest updates. Persist the highest update_id so the next run advances the offset and does not reprocess anything.
2. Keep only business_message updates whose message contains an attachment: document, photo, video, audio, or voice. Skip stickers, plain text, and edits.
3. For each attachment on each qualifying message, call telegram-secretary Get File Download Link with the file_id to resolve a downloadable URL. For photos, use the largest size variant.
4. Ensure a root Telegram Inbox folder exists at the top of my Drive. Then, for each sender, ensure a subfolder exists under Telegram Inbox named after the sender's display name (first_name plus last_name, falling back to username, falling back to their user id). Use google-drive Create Folder when a folder is missing. Cache folder ids within the run so we do not create duplicates.
5. Download the file from the resolved URL and upload it into the sender's folder. Use google-drive Upload File (Multipart) for files under 5MB and google-drive Upload File (Resumable) for anything 5MB or larger. Preserve the original filename when Telegram gives us one; fall back to a sensible default per media type (photo.jpg, video.mp4, voice.ogg, audio.mp3). Append an ISO timestamp before the extension so repeated filenames never collide.
6. After a successful upload, call telegram-secretary Send Message as User to reply in the same chat with the text got it, saved. Use the business_connection_id from the incoming update so the reply is sent as the account owner, not as the bot.
Notes for the implementation: every action above maps to a documented operation, so the whole thing is a fixed pipeline of known nodes with structured inputs. If a message has multiple attachments (media group), upload each one and only send a single got it, saved reply per message. If any single attachment upload fails, log it and continue with the rest so one bad file does not block the batch.
Additional information
What does this prompt do?
- Watches your personal Telegram for new messages with attachments (documents, photos, videos, audio notes, voice memos).
- Saves each file into Google Drive under a top-level Telegram Inbox folder, in a subfolder named after the sender.
- Preserves the original filename and stamps it with a timestamp so nothing ever overwrites an older copy.
- Replies in the same chat with a quick got it, saved so the sender knows the file made it through.
What do I need to use this?
- A Telegram account with the Secretary Bot connected (see our Telegram Secretary setup guide).
- A Google account you use with Google Drive, connected with permission to create folders and upload files.
- A little bit of free Drive space to hold whatever people send you.
How can I customize it?
- Change how often it runs. Every 15 minutes is a good default, but you can move it up to hourly or down to every few minutes.
- Point it at a different root folder in Drive, or nest it inside a shared drive your team already uses.
- Skip certain attachment types, for example ignore voice notes if you only care about documents and photos.
- Turn off the auto-reply, or change the wording of the confirmation message.
Frequently asked questions
Does this work on my personal Telegram, or only a bot channel?
What kinds of files does it save?
What happens if the same person sends me two files with the same name?
Where do the folders end up in my Drive?
Will senders know their file was archived?
Related templates
Stop hunting for that file someone sent you on Telegram.
Connect Telegram and Google Drive once, and Geni quietly files every attachment into the right folder, every 15 minutes.