Extract invoice data from Gmail PDF invoices with Gemini and Google Sheets
Go to WorkflowDescription
Quick overview
This workflow monitors a Gmail label for unread emails with PDF invoice attachments, extracts the PDF text, uses Google Gemini to parse key invoice fields into structured JSON, and appends the cleaned results to a Google Sheets tab before marking the email as read.
How it works
Polls Gmail every minute for unread emails matching the query has:attachment filename:pdf label:invoices and downloads attachments.
Splits each matching email into separate items so each PDF attachment is processed individually.
Extracts text from each PDF attachment using n8n’s PDF text extraction.
Sends the email context and extracted text to Google Gemini with a predefined JSON schema to return structured invoice fields and a confidence score.
Normalizes dates and numbers, checks basic consistency (like subtotal + tax vs total), and flags low-confidence or incomplete results as needs_review.
Appends the final invoice row (including line items as JSON) to the Invoices sheet in Google Sheets and marks the source Gmail message as read.
Setup
Create or choose a Gmail label (for example, invoices) and ensure invoice emails are labeled to match the workflow’s Gmail search query.
Add Gmail OAuth2 credentials for the Gmail Trigger and Gmail node.
Add a Google Gemini (Google AI Studio) API key/credentials for the Gemini Chat Model.
Add Google Sheets OAuth2 credentials and replace REPLACE_WITH_YOUR_SPREADSHEET_ID, ensuring your spreadsheet has a tab named Invoices.
Test with a text-based PDF invoice (not image-only) or add an OCR step upstream if your invoices are scanned images.
Additional info
Need it installed? I set this up in your n8n on Fiverr, starting around $20: https://www.fiverr.com/mouwah/set-up-a-tested-n8n-invoice-approval-or-lead-routing-workflow-in-your-n8n
Pro version (vendor PAY/HOLD check against a Vendors tab, duplicate detection, approval flow): https://mohabaha0.gumroad.com/l/ap-invoice-triage-pro
This workflow was created by Mohamed Zaghloul and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.