n8n

How to Automate Gmail Invoices to Google Drive by Company and Month?

Collect invoice emails from Gmail and save their attachments into Google Drive, sorted by company and by month. Only approved senders from a Google Sheets whitelist are processed, so your storage stays clean and organized. Ideal for finance and operations teams that need fast and tidy record keeping.

A Gmail trigger checks a label every 15 minutes and pulls new messages. A Google Sheets lookup matches the sender email to a company name and ignores anything not on the list. The flow then checks Google Drive for a company folder and creates it if missing. It builds a YYYY/MM folder from the email date, searches for that folder, and creates it when needed. Attachments are downloaded, split into individual files, renamed with a timestamp, and uploaded in batches to the month folder.

You will need Gmail, Google Drive, and Google Sheets connected in n8n. Set up a Gmail label and filter for invoice or receipt emails, copy the whitelist sheet, and pick a parent Drive folder for storage. Expect large time savings and fewer filing mistakes. Great for vendor bills, receipts, and monthly statements.

What are the key features?

  • Gmail trigger polls a chosen label every 15 minutes to find new emails with attachments.
  • Google Sheets lookup checks a whitelist and maps sender email to a company name.
  • Company folder verification in Google Drive with auto create if the folder does not exist.
  • Dynamic YYYY/MM folder naming based on the email date to keep files grouped by month.
  • Attachment download and split so each file is handled on its own.
  • Timestamp prefix added to file names for easy tracking and sorting.
  • Batch upload to Google Drive using a loop for reliable, high volume processing.

What are the benefits?

  • Reduce manual filing from hours each week to a few minutes
  • Automate up to 90 percent of attachment downloads and uploads
  • Improve folder consistency by 100 percent with fixed YYYY/MM structure
  • Cut errors from misfiled invoices by over 90 percent with a whitelist
  • Connect Gmail, Google Sheets, and Google Drive in one flow

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You will need accounts with Gmail, Google Sheets and Google Drive. See the Tools Required section above for links to create accounts with these services.
  3. In Gmail, create a label for invoices. Add a filter that tags emails with attachments that include words like invoice or receipt so they get the label.
  4. Open the Gmail Trigger node in n8n. Select the label you created and set the polling interval to 15 minutes or your preferred timing.
  5. Double click the Gmail Trigger node, choose Credential to connect with, click Create new credential, and follow the on screen steps to connect your Gmail account. Name the credential clearly, such as Gmail Finance.
  6. Open the Google Sheets node named Lookup in Sheets. Copy the whitelist sheet with email and company columns or create your own. Point the node to your Document and Sheet.
  7. Create a Google Sheets credential in n8n by choosing Create new credential on the node and following the on screen instructions. Use a clear name like Sheets Whitelist.
  8. Choose a parent storage folder in Google Drive. In the Search Company Folder and Create Company Folder nodes, set the parent folder where company folders will be created.
  9. Create a Google Drive credential in n8n on any Drive node by clicking Create new credential and completing the OAuth steps. Name it Drive Finance.
  10. Open the Set node named YYYY/MM and confirm the folder format is correct. It should build a year and month from the email date.
  11. Run a test by sending or labeling an email with a PDF attached from a whitelisted sender. Check Drive for a new company folder and a YYYY/MM subfolder with the uploaded file.
  12. If nothing appears, confirm the Gmail label, make sure the sender email exists in the sheet, and verify that the Drive parent folder permission allows your connected account.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.