# Log Brazilian NF-e invoice XMLs from Gmail into Google Sheets

> Quick overview This workflow polls Gmail for emails with XML attachments, extracts Brazilian NF-e invoice data, validates the 44-digit access key against the XML content, and upserts one row per invoice into Google Sheets while sending invalid or conflicting records to a separate Review tab. How it works 1. Triggers every 5 minutes by polling Gmail for messages that have .xml attachments and downloads the attachments. 2. Splits each email into one item per attachment and keeps only files whose filename ends with .xml. 3. Reads each XML file, converts it to JSON, and filters out non-NF-e documents. 4. Validates the NF-e access key (including the mod-11 check digit) and checks that it matches the issuer and protocol details in the XML to assign a status. 5. Writes invalid or mismatched keys to a Google Sheets Review tab with the reason, message metadata, and invoice identifiers. 6. Sorts valid items to prefer Authorized invoices, de-duplicates by access key, checks existing Google Sheets

- **Domain**: `n8n-workflow-22230.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/22230
- Page (HTML): https://agenstry.com/agents/n8n-workflow-22230.n8n.io
- Documentation: https://n8n.io/workflows/22230
