File Gmail attachments into Box and ping Slack

By General Input

Auto-sort inbound email attachments into the right Box folder by sender, share a link, and notify your team in Slack every 15 minutes.

Integrations

  • Gmail
  • Box
  • Slack

Type

Agentic Task

Categories

  • Operations
  • Personal Productivity

Build me an agent workflow that auto-files Gmail attachments into the right Box folder and posts a notification to Slack.

Trigger: cron, every 15 minutes.

Each run, the agent should:

1) Use Gmail's List Messages with a query like `has:attachment newer_than:1h -in:sent -from:me` to find recent inbound messages that have attachments. Use Get a Message (format=full) to load each one so it can read headers, the parts tree, and attachment IDs.

2) For every attachment on each qualifying message, pull the bytes with Gmail's Get Attachment (the response is base64url-encoded; decode before uploading).

3) For each attachment, find the destination Box folder using Box Search Content. Match on the sender's company name (from the From display name) and the sender's email domain. If a folder already exists, file the attachment inside it. If nothing matches, create a new folder with Box Create Folder named after the sender's domain (or the configured top-level parent's root).

4) Upload the file with Box Upload File into that folder. Then call Box Add Shared Link to File to generate a shareable URL for the uploaded file.

5) Post a single Slack message per email using Slack Send a Message to the configured channel. The message should include the sender (name plus email), the email subject, the file name(s), and the Box shared link(s). If multiple files came in on one message, group them in one Slack post rather than spamming the channel.

Filtering rules the agent must apply before uploading anything:

- Skip auto-replies (Auto-Submitted header is anything other than `no`, or subject starts with `Auto:` / `Out of Office`).

- Skip calendar invites (parts with content type `text/calendar` or `application/ics`, and `.ics` attachments).

- Skip inline signature images: anything under ~20KB whose Content-Disposition is `inline` or that has a `Content-ID` referenced from the HTML body.

- Skip any message whose Gmail message ID has already been processed (de-dupe by storing processed message IDs so the next 15-minute run never re-files the same email).

Configuration the user should be able to set when they connect the workflow:

- The Slack channel ID to notify.

- An optional top-level Box parent folder ID where all sender folders live (default: Box root, `0`).

- An optional allowlist of Gmail labels to scope to (e.g. only mail tagged `Clients`).

- An optional minimum attachment size and an optional allowed-extensions list.

Be resilient: if Box returns a name-conflict on upload, append a short timestamp to the filename and retry. If Box rate-limits (429), respect Retry-After. If a single message fails, log it and continue with the rest of the run rather than aborting the whole batch.

Operations to use: gmail.List Messages, gmail.Get a Message, gmail.Get Attachment, box.Search Content, box.Create Folder, box.Upload File, box.Add Shared Link to File, slack.Send a Message.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredChat quality review board for LiveChat support leadsChase the paperwork every new client and vendor still owesFile Gmail attachments into storage with names you can findWin back no-show and cancelled appointments every morningLive Loop returns analytics with product-level drill-downNewsletter pre-flight and approval board for Mailjet sendsTurn a prospect spreadsheet into personalized sequence enrollmentsMailjet email delivery lookup console for support teams