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
- Download the workflow file by clicking the Download button on this page.
- Open the n8n editor where you want to use this workflow.
- Click Import from File and select the downloaded workflow JSON file.
Configuring credentials and settings
- Add your Gmail OAuth credentials to the Gmail Trigger and Gmail nodes.
- Add Google Drive OAuth credentials to all Drive nodes.
- Add Google Sheets OAuth credentials to the Sheets node reading the whitelist.
- Update folder IDs for the main “Invoices” folder in Google Drive nodes if needed.
- Check that the Google Sheet ID and sheet name match your whitelist sheet.
- Confirm your Gmail label name matches the label set in Gmail Trigger.
Testing and activating
- Manually run the workflow on a test email with attachment labeled properly.
- Verify the invoice files appear in Drive folders correctly with proper names and metadata.
- After confirming all works, activate the workflow to run automatically on schedule.
- 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.
