Sort email attachments by document type

They built an n8n workflow that sends inbox attachments to Gemini, then files each one by type and handles purchase orders separately.

Done with n8nGemini· Advanced· Apr 2026

What they did
They set up a roughly 50-step n8n flow for a busy mailbox. The workflow grabs attachments from incoming mail, asks Gemini to label each file as invoice, quote, statement, PO, or other, and then sends most of them to the matching Google Drive folder. When the system spots a PO, it looks up the related estimate in QuickBooks Online, adds the PO number, uploads the file, and creates the linked invoice. They also built in retries, a separate error folder, and spreadsheet checkpoints so they can trace where each document ended up.
How it went
The workflow had not gone live yet, so there were no production numbers to share. The builder said they were still uneasy about switching it on in the live environment. The main protection they mentioned was tracking each document’s route or failure point.
Tips
This kind of setup needs solid error handling from the start, especially for timed-out API calls. It also helps to keep a separate log and failure folder so you can review anything that does not classify cleanly.

Try it yourself with n8n

Set up a workflow for [email account or mailbox] that checks for new attachments, downloads each file, and uses Gemini to sort it into invoice, quote, statement, purchase order, or other. Record the sender, filename, and label in [Google Sheet or tracking file], then route the file to the right [folder or drive path]. If the file is a PO, pause and show me the matched estimate and proposed invoice update in QuickBooks Online before you create, upload, or save anything, and wait for my approval first. Run this on [number] test emails and report any failures, retries, or files sent to an error folder.

Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.

Get 3 agent uses like this every morning

With the day's top AI news. Free, and one click to unsubscribe.