Automate Gmail Attachments to Google Drive Folders with n8n

This workflow automates saving Gmail email attachments into organized Google Drive folders based on company and date. It eliminates manual download and sorting by creating folders dynamically and uploading files seamlessly.
gmailTrigger
googleSheets
googleDrive
+6
Workflow Identifier: 2104
NODES in Use: gmailTrigger, googleSheets, googleDrive, gmail, function, if, set, splitInBatches, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow watches a Gmail inbox for new emails with a specific label and attachments.

It then checks if the sender is on an approved list in a Google Sheet.

If approved, it organizes the invoice files in Google Drive into folders by company and year/month.

It downloads each attachment and uploads it with a timestamp in the right folder on Google Drive.

Who should use this workflow

Any small business or freelancer who gets many invoice emails.

This helps avoid manual downloading and copying files.

It is made for people who want a tidy folder system without extra work.

Tools and services used

  • Gmail: To watch for labeled invoice emails.
  • Google Sheets: To keep a whitelist of allowed email senders and company names.
  • Google Drive: To create and find folders and to save invoice files.
  • n8n: To run and connect all the services in a workflow.

How the workflow works (Input → Process → Output)

Inputs

  • New email with a special Gmail label and attachments.
  • Whitelist data from Google Sheets to check senders.
  • Existing folder structure or root folder ID in Google Drive.

Processing Steps

  • Trigger watches Gmail every 15 minutes for labeled emails.
  • Check if sender’s email matches whitelist in Sheets.
  • Search Drive for a folder named after company; create if missing.
  • Extract year and month from the email date for folder naming.
  • Search or create a year/month folder inside the company folder.
  • Download full email details including attachments.
  • Split attachments into separate items for upload.
  • Upload each file to the Drive folder with a timestamp prefix.
  • Add file properties like sender and email date to the uploaded files.

Output

  • Invoices reliably saved into company and date folders in Google Drive.
  • Files named with timestamps to avoid overwrites.
  • Easy tracking of sender and received date via file properties.

Beginner step-by-step: How to use this workflow in n8n

Importing the workflow

  1. Download the workflow file by clicking the Download button on this page.
  2. Open the n8n editor where you want to use this workflow.
  3. Click Import from File and select the downloaded workflow JSON file.

Configuring credentials and settings

  1. Add your Gmail OAuth credentials to the Gmail Trigger and Gmail nodes.
  2. Add Google Drive OAuth credentials to all Drive nodes.
  3. Add Google Sheets OAuth credentials to the Sheets node reading the whitelist.
  4. Update folder IDs for the main “Invoices” folder in Google Drive nodes if needed.
  5. Check that the Google Sheet ID and sheet name match your whitelist sheet.
  6. Confirm your Gmail label name matches the label set in Gmail Trigger.

Testing and activating

  1. Manually run the workflow on a test email with attachment labeled properly.
  2. Verify the invoice files appear in Drive folders correctly with proper names and metadata.
  3. After confirming all works, activate the workflow to run automatically on schedule.
  4. If using self-host n8n, make sure the server is always running.

Customization ideas

  • Change Gmail label to filter receipts, contracts, or other documents.
  • Adjust date format in the Set node to create different folder naming, e.g., “YYYY-MM-DD”.
  • Add a Slack notification node after uploads to alert teams of new invoices.
  • Expand Google Sheets whitelist with more company info and use it in Drive file properties.
  • Use Gmail filters to auto-label invoices so manual tagging is not needed.

Common issues and fixes

No emails trigger the workflow

Cause: Emails not labeled or label name mismatch in Gmail Trigger.

Fix: Ensure Gmail filter applies label correctly and poll interval is 5-15 minutes.

Google Sheets lookup empty

Cause: Wrong Sheet ID, wrong tab, or column names do not match whitelist.

Fix: Verify Sheet ID, sheet name, and column headers exactly match your whitelist file.

Folders not created in Drive

Cause: Wrong root folder ID or lacking permissions in Google Drive OAuth.

Fix: Check Drive node settings and confirm the “Invoices” folder ID is correct with proper access.

Summary of benefits

✓ Save time by automating invoice file downloads from Gmail.

✓ Avoid manual file misplacement and lost invoices.

✓ Keep Google Drive invoice files organized by company and date.

→ Get traceable, timestamped invoice files with sender info in Drive.

→ Run workflow automatically on schedule; no manual work after setup.


Frequently Asked Questions

The workflow stops and does not save attachments from emails with senders not listed in the whitelist sheet.
The workflow adds a timestamp prefix to each uploaded file name to keep each file unique in Google Drive.
Yes, the workflow searches for company and month folders and creates them if they are missing.
Add OAuth credentials for Gmail, Google Sheets, and Google Drive nodes. Update folder IDs, Gmail labels, and Google Sheets IDs as needed.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free