For operations teams in manufacturing, email is still the primary channel for receiving documents from suppliers: invoices, purchase order acknowledgments, shipping confirmations, certificates of conformance, material data sheets. These arrive in Gmail, get downloaded manually when someone remembers, get renamed inconsistently, and get filed wherever made sense that day.
The n8n workflow in this tutorial replaces that process. It monitors your Gmail for new emails with attachments, uploads each file to the correct Google Drive folder automatically, and labels the original email so your team knows it has been captured.
Four nodes. No code. No ERP required.
Gmail Trigger (new email with attachment)
→ IF node (confirm attachment exists)
→ Google Drive (upload file to folder)
→ Gmail (label original email as processed)
Optional extension: add a Switch node to route different document types (invoices, shipping docs, PO confirmations) into separate folders automatically.
n8n instance. n8n Cloud or self-hosted, version 1.0 or later.
Gmail OAuth2 credential in n8n. Go to Credentials in n8n, add a new credential, select Gmail OAuth2, and authorize against the Google account that receives supplier emails.
Google Drive OAuth2 credential in n8n. Add a second credential, select Google Drive OAuth2, and authorize against the account that owns the Drive folders you want to upload into.
Google Drive folders set up. Create the destination folders before building the workflow. You need the folder ID for each one (visible in the Drive URL when you open the folder: https://drive.google.com/drive/folders/FOLDER_ID_HERE).
A Gmail label for processed emails. In Gmail, create a label called "Auto-Filed to Drive." You will apply this after the upload to confirm the workflow ran.
Add a Gmail Trigger node as the first node in the workflow.
Configuration:
The trigger polls Gmail on the interval you set and returns each new email since the last check as a separate item. When "Download Attachments" is on, each attachment becomes binary data attached to the item.
Run the trigger manually using "Fetch Test Event" to confirm it returns a real email with binary data in the output panel. The binary property is named data by default.
Not every email in a monitored inbox will have an attachment. The IF node catches this before the workflow attempts to upload nothing.
Configuration:
{{ $json.attachments ? $json.attachments.length : 0 }}0True branch: emails with at least one attachment continue to the upload step.False branch: leave unconnected or route to a No Operation node.
Add a Google Drive node on the True branch.
Configuration:
data (the binary property from the Gmail trigger){{ $json.subject }}_{{ $now.toFormat('yyyy-MM-dd') }}_{{ $binary.data.fileName }}The file name expression combines the email subject, today's date, and the original attachment file name. This creates a consistent naming pattern without manual renaming.
Run the node with your test item and confirm the file appears in Drive with the correct name.
After the upload, add a second Gmail node to label the original email.
Configuration:
{{ $('Gmail Trigger').item.json.id }}This gives your team a visual confirmation in Gmail that the attachment was captured. It also makes it easy to audit: any supplier email without this label was not processed by the workflow.
If a single email regularly contains multiple attachments (an invoice plus a packing slip, for example), add a Split Out node between the IF node and the Google Drive node.
Configuration for the Split Out node:
attachmentsEach attachment becomes its own item in the workflow. The Google Drive node uploads each one separately.
Updated workflow with multiple attachment support:
Gmail Trigger
→ IF (has attachments)
→ Split Out (split attachments array)
→ Google Drive (upload each file)
→ Gmail (label original email)
Note: the Gmail label node should be placed after all uploads complete. If using the Split Out approach, confirm the label applies once per email rather than once per attachment by routing the label node after a Merge node that waits for all items to process.
For ops teams receiving multiple document types from multiple suppliers, folder routing by document type is the most useful extension.
Add a Switch node between the IF node and the Google Drive node:
/Supplier Docs/Invoices/ (Folder ID A)/Supplier Docs/Shipping/ (Folder ID B)/Supplier Docs/PO Confirmations/ (Folder ID C)/Supplier Docs/Unsorted/ (Folder ID D)Each case connects to its own Google Drive node (duplicate the node and change the folder ID). Files land in the correct folder without any manual sorting.
Before activating:
data in the Binary tab of the output panel)Once testing passes, activate the workflow. Every qualifying email processes automatically within the polling interval.
Gmail API polling quota. Every 5 minutes means 288 trigger executions per day. This is well within Google's API limits for a single account. If you have multiple workflows polling the same Gmail account, increase the interval on lower-priority workflows to stay clear of rate limits.
Emails received while the workflow is inactive. The Gmail trigger creates a checkpoint at the last processed email. If the workflow is deactivated or n8n is down, emails received during that window will not be processed retroactively. For high-importance document types (invoices, compliance certificates), add a manual audit step: weekly, check the inbox for supplier emails older than 48 hours that lack the "Auto-Filed to Drive" label.
Attachment size limits. Google Drive via the API supports files up to 5TB. In practice, supplier documents are small. The limit to watch is Gmail's 25MB attachment cap: anything over that was likely sent via a link rather than a direct attachment, and the trigger will not capture those.
Binary data property name. If you modified the Gmail trigger configuration, confirm the binary property name matches what the Google Drive node expects. Open the trigger output, click the Binary tab, and check the property name shown. Update the "Input Data Field Name" in the Drive node to match.
The Flow Kaizen guide covers how to sequence document handling workflows alongside your other automation builds, including which integrations to prioritize first and how to connect these workflows to your ERP once you are ready.