# Extract invoice data from Gmail PDF invoices with Gemini and Google Sheets

> 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 1. Polls Gmail every minute for unread emails matching the query has:attachment filename:pdf label:invoices and downloads attachments. 2. Splits each matching email into separate items so each PDF attachment is processed individually. 3. Extracts text from each PDF attachment using n8n’s PDF text extraction. 4. Sends the email context and extracted text to Google Gemini with a predefined JSON schema to return structured invoice fields and a confidence score. 5. Normalizes dates and numbers, checks basic consistency (like subtotal + tax vs total), and flags low-confidence or incomplete results as needsreview. 6. Appends the final invoice row (including line items as JSON) to the Invoices sheet in G

- **Domain**: `n8n-workflow-21181.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/21181
- Page (HTML): https://agenstry.com/agents/n8n-workflow-21181.n8n.io
- Documentation: https://n8n.io/workflows/21181
