{"product_id":"gmail-pdf-invoice-po-extract-to-xml-csv-json-n8n","title":"Gmail PDF Invoice \u0026 PO Extract to XML CSV JSON | n8n","description":"\u003ch3\u003eTurn Gmail invoice \u0026amp; PO PDFs into ERP-ready XML, CSV, and JSON automatically\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow monitors your Gmail for unread invoice or purchase order PDF attachments, extracts their text, validates key fields and line-item totals, and outputs structured XML, CSV, and JSON files—while alerting a reviewer when something doesn’t match the rules.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cb\u003ePolls Gmail every 15 minutes\u003c\/b\u003e for unread messages matching a configurable PDF invoice\/PO search query, then downloads attachments.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eSplits and processes PDF attachments\u003c\/b\u003e and extracts selectable text from each PDF.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eDetects document type\u003c\/b\u003e (invoice vs purchase order) and parses header fields such as document numbers, dates, vendor, and currency.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eParses line items and totals\u003c\/b\u003e, then performs rule-based validation of required fields.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eValidates calculations\u003c\/b\u003e by checking line-item math and subtotal\/tax\/total consistency.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eFlags duplicates\u003c\/b\u003e using workflow static data to avoid re-processing the same document.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eOutputs structured files\u003c\/b\u003e for valid documents: generates \u003cb\u003eERP-style XML\u003c\/b\u003e, plus \u003cb\u003eCSV\u003c\/b\u003e and \u003cb\u003eJSON\u003c\/b\u003e per document.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eHandles exceptions\u003c\/b\u003e by sending a Gmail message to a reviewer email with validation errors and key extracted values.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eMarks the original Gmail message as read\u003c\/b\u003e so it won’t be processed again (skipping the built-in sample run).\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eSaaS operations teams routing invoice\/PO PDFs from suppliers directly into downstream ERP formats.\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers building a reliable invoice-to-data pipeline with validation and human review for edge cases.\u003c\/li\u003e\n  \u003cli\u003eFinance teams reducing manual copying by converting Gmail PDF invoices\/POs into XML\/CSV\/JSON for ingestion.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cb\u003eGmail\u003c\/b\u003e trigger (OAuth2) for polling unread invoice\/PO PDFs and actions to mark messages as read.\u003c\/li\u003e\n  \u003cli\u003eParsing and control flow using \u003cb\u003eif\u003c\/b\u003e, \u003cb\u003eset\u003c\/b\u003e, \u003cb\u003ecode\u003c\/b\u003e, \u003cb\u003efilter\u003c\/b\u003e, and documentation\/flow notes via \u003cb\u003esticky note\u003c\/b\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cb\u003eOptional:\u003c\/b\u003e upload the generated XML\/CSV\/JSON files to a specified \u003cb\u003eGoogle Drive\u003c\/b\u003e folder.\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46192814031027,"sku":"N8N-20691","price":38.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/J2T5a6N6WI6no_fKX3KLb_gdmkwbwU.png?v=1791536533","url":"https:\/\/buyflowscripts.com\/products\/gmail-pdf-invoice-po-extract-to-xml-csv-json-n8n","provider":"N8N Commerce","version":"1.0","type":"link"}