Quick overview
This workflow checks Gmail for invoice emails, saves PDF invoices to Google Drive in automatically created YYYY/YYYY-MM folders, extracts key invoice fields with Anthropic Claude, and logs each invoice in a monthly Google Sheets spreadsheet stored in the same month folder.
How it works
- Triggers every 15 minutes from Gmail for messages matching the invoice/receipt search and not yet labeled
invoices-processed, downloading any attachments.
- Determines the target year and month from the email date (optionally filing to the previous month) and tries to detect an invoice/receipt link in the email body.
- Finds or creates the corresponding year (YYYY) and month (YYYY-MM) folders in Google Drive under your chosen root invoices folder.
- Collects invoice PDFs from email attachments, or downloads the detected invoice link and either uploads the returned PDF or renders an invoice web page to PDF using PDF.co.
- Sends each invoice PDF to Anthropic Claude to extract supplier name, VAT/tax ID, issue date, amount, and currency.
- Uploads the PDF to the month folder in Google Drive and appends a row with the extracted fields to an “Invoices YYYY-MM” Google Sheets file in the same folder (creating and moving the sheet there if needed).
- Adds the
invoices-processed label to the Gmail message so it is not processed again.
Setup
- Connect Gmail OAuth2 and create/select a Gmail label named
invoices-processed for the label step.
- Connect Google Drive OAuth2 and set
invoicesFolderId in the Settings step to the ID of your root invoices folder.
- Connect Google Sheets OAuth2 so the workflow can create the monthly spreadsheet and append rows.
- Add an Anthropic credential (or n8n AI Gateway credits) for the Claude document extraction step.
- Optional: add a PDF.co API key/credential and set
renderLinkDomains (comma-separated) if you only want to render invoice links from specific domains.
- Review and adjust the Gmail search query in the trigger to match the senders/subjects you receive invoices from.