Auto-save Telegram files to Google Drive by sender

By General Input

Every 15 minutes, tuck away every file people send you on Telegram into a tidy Google Drive folder named after who sent it.

Integrations

  • Telegram Secretary Bot
  • Google Drive

Type

Deterministic Code

Categories

  • Personal Productivity
  • Operations

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.

Related prompts

Explore more prompts
Ad creative studio with a pre-approved variant libraryFilter every signed Ironclad contract and brief it on demandArtwork desk for the Notion posts still missing an imageWebinar promo desk: find Zoom sessions missing artworkTurn Google Drive scripts into narrated audio, line by lineWork your Shopify catalog until every product has a clipTurn a campaign brief into a storyboard your team can animateKeep your brand's AI characters consistent across campaignsPitch deck studio: reps pick the slides before every meetingAgency reporting board that builds each client's Slides deck