Olmec Dynamics
H
·7 min read

How to Route Gmail Attachments to Google Drive Folders by Label Using Make.com

Route Gmail attachments to the right Google Drive folder by label using Make.com, with deterministic filenames, dedupe in Sheets, and Slack alerts.

Introduction

If attachments keep landing in one messy Google Drive folder, your team ends up doing the same manual cleanup every day, download, rename, then drag files into the right place. It also creates duplicates when you test filters, recover from errors, or re-run a scenario.

This guide shows how to automate Gmail attachment routing into multiple Google Drive folders using Make.com, with deterministic filenames and a simple Google Sheets audit log. By the end, you will know how to wire the trigger, iterate attachments, build safe filenames, route by Gmail label, and keep the workflow idempotent.

What You'll Need

  • Make.com account (paid plan is typically recommended for production runs)
  • Gmail account connected in Make.com, with permission to watch emails and read attachments
  • Google Drive connected in Make.com, with permission to upload into your target folders
  • Google Sheets for dedupe and logging
  • Slack connection, optional but recommended for “something failed” alerts
  • Two or more Gmail labels that represent routing rules, for example To-Drive - Invoices and To-Drive - Contracts

If you want broader patterns for Cross-Platform Automation, start with Cross-Platform Automation (XPA).

How It Works (The Logic)

Your scenario follows this logic:

Gmail new email with attachments (scoped by a label you control) → List email attachments and mediaIterator per attachmentPick destination folder based on the email’s labelRename deterministicallyUpload to Google DriveLog to Google Sheets and dedupe by email id + attachment nameSlack only on errors.

Step-by-Step Setup

1) Create your routing labels in Gmail

Create at least two labels in Gmail:

  • To-Drive - Invoices
  • To-Drive - Contracts

Then create Gmail filters that apply these labels to inbound messages. This matters because routing becomes an inbox-level decision, not a brittle guess based on attachment names.

2) Create a Google Sheets log for dedupe

Make a spreadsheet with a tab called Processed_attachments and columns like:

  • gmail_message_id
  • attachment_name_original
  • drive_file_id
  • drive_file_url
  • drive_file_name
  • destination_folder
  • status
  • processed_at

This sheet is your idempotency layer.

3) Build the Make.com scenario skeleton

In Make.com, create a new scenario and add these modules in this order:

  1. Gmail trigger: Watch emails (filter to only process messages you want, typically by a label such as To-Drive - Inbox or multiple label rules)
  2. Gmail action: List email attachments and media (so you can access each attachment cleanly)
  3. Iterator: iterate over the attachments array
  4. Google Sheets action: Search rows (dedupe check)
  5. Router / Filter: continue only if not already processed
  6. Tools / Formatter: build deterministic filename
  7. Google Drive: Upload a file (using the selected destination folder + renamed file)
  8. Google Sheets: Add a row (log success)
  9. Error handler path: Slack alert

The important detail is that you iterate attachments only after Make has enumerated them for the current email bundle.

4) Dedupe before you upload (so retries do not create duplicates)

In the Google Sheets search rows step, use a dedupe key based on:

  • gmail_message_id and attachment_name_original

If your Make.com Sheets module only searches one field at a time, do this in two moves:

  • Search by gmail_message_id
  • Filter inside the scenario for attachment_name_original

On the “already processed” branch, stop and skip upload.

5) Create deterministic filenames that won’t break Drive

Add a Tools/Formatter step to build a safe filename.

A practical template:

  • YYYYMMDD_fromSubjectRef_attachmentName

Implementation details you should enforce:

  • Sanitize the email subject and attachment name (replace characters Drive or filesystems dislike)
  • Preserve the original extension from the attachment name
  • Add uniqueness if collisions are possible, for example include a short message id suffix or attachment index

If you also generate PDFs from Google Docs templates, the same naming discipline keeps storage tidy. See how to generate a PDF from a Google Docs template using Make.com and Gmail.

6) Route by Gmail label to the correct Google Drive folder

Add a Router right before the Google Drive upload.

In each branch set:

  • destination_folder to the correct Drive folder

For a simple setup, use label-based routing:

  • If the email has To-Drive - Invoices, upload to /Incoming/Invoices/
  • If the email has To-Drive - Contracts, upload to /Incoming/Contracts/

For scaling, you can replace label branches with a lookup table in a sheet, but start simple.

7) Upload each attachment to Drive

In Google Drive: Upload a file, map:

  • File content: the attachment binary from the Iterator
  • File name: your deterministic filename variable
  • Folder: destination_folder from your routing branch

Common gotcha: make sure you are using the current attachment binary from the Iterator, not a binary from the trigger bundle.

8) Log success to Google Sheets

After a successful upload, add a row to Processed_attachments:

  • gmail_message_id from the Gmail trigger
  • attachment_name_original from the Iterator
  • drive_file_id, drive_file_url, drive_file_name from the Drive upload output
  • destination_folder from the routing branch
  • status = success
  • processed_at = now()

9) Slack alerts only on failures

Create an Error handler in Make and connect it to Slack “Post a message”.

Send the basics:

  • Gmail message id
  • Attachment original name
  • Intended Drive folder
  • The Make error summary

Do not post for every success, it will dilute the signal.

10) Test like an ops person

Test checklist:

  • Send one email with 2 attachments and label it To-Drive - Invoices
  • Confirm both files land in the invoices folder with safe filenames
  • Re-send the same email (or re-run on the same message) and confirm Sheets dedupe prevents duplicates
  • Temporarily break Drive permissions to trigger the error handler and confirm Slack fires

Real-World Business Scenario

A finance team receives invoices and supplier statements by email. Their Gmail filters already tag invoices, but before automation, someone manually downloaded attachments, renamed them, and filed them into the right Drive folder.

With this Make.com setup, each invoice attachment lands directly into /Incoming/Invoices/2026/06/ with deterministic filenames. When audit time arrives, the Processed_attachments sheet answers “do we have it in Drive?” without searching across folders.

If you want the single-folder version of this, you can adapt the pattern from how to automatically save Gmail attachments to Google Drive and rename using Make.com.

Common Variations

  1. Multiple labels on the same message

If a single message has multiple routing labels, decide whether you route to the first match, highest priority, or upload to multiple subfolders.

  1. Skip rule by sender domain

Add a filter before the dedupe step so only specific senders (like invoices@ domains) are processed.

  1. Add downstream notifications

After Drive upload, notify Slack only for certain destinations (for example Contracts) or write another row into a “Deliverables” sheet that your team already uses.

Keeping your Drive archive clean with XPA

You built a simple Cross-Platform Automation (XPA) that watches Gmail for attachments, iterates each one, routes files to the correct Google Drive folder based on Gmail labels, renames safely, and logs outcomes to Google Sheets with dedupe. This is the part that makes the system reliable when retries and errors happen.

Olmec Dynamics builds and maintains Gmail-to-Drive XPAs like this for teams that want fewer manual steps and better operational traceability. If you want help tailoring the label filters, folder paths, and filename rules to your inbox, you can see what we do here.