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
Automate Gmail to Drive with n8n

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

Learn how to Build this Workflow with AI:

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

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.


Automate Gmail to Drive with n8n

Visit through Desktop to Interact with the Workflow.

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.
Author
Written By
Ritu Sanjali

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.