{"product_id":"gmail-invoice-pdf-extractor-with-openai-to-google-sheets-n8n","title":"Gmail Invoice PDF Extractor with OpenAI to Google Sheets (n8n)","description":"\u003ch3\u003eExtract invoice data from Gmail PDFs and auto-log it into Google Sheets (with OpenAI via n8n)\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow watches your Gmail inbox for unread invoice emails with PDF attachments, extracts the invoice text, uses \u003cstrong\u003eOpenAI (via LangChain)\u003c\/strong\u003e to pull key fields, and appends a structured row into Google Sheets—ready for operational reporting and follow-up.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eMonitors Gmail every minute\u003c\/strong\u003e for unread messages that include \u003cstrong\u003ePDF attachments\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eValidates the attachment\u003c\/strong\u003e: it downloads and checks that the first attachment is a PDF; non-PDF attachments are ignored.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtracts PDF text\u003c\/strong\u003e: combines the extracted content from the invoice PDF into a single text payload.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eUses OpenAI to extract structured fields\u003c\/strong\u003e: sends the extracted text to the \u003cstrong\u003eLangChain OpenAI Chat Model\u003c\/strong\u003e to identify four invoice values:\n    \u003cul\u003e\n      \u003cli\u003eVendor name\u003c\/li\u003e\n      \u003cli\u003eInvoice number\u003c\/li\u003e\n      \u003cli\u003eDue date\u003c\/li\u003e\n      \u003cli\u003eTax-included total\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNormalizes results\u003c\/strong\u003e into a consistent JSON structure (including converting the total into a number).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAppends to Google Sheets\u003c\/strong\u003e in a tab named \u003ccode\u003einvoice_lite\u003c\/code\u003e with headers:\n    \u003ccode\u003etorihikisaki_mei\u003c\/code\u003e, \u003ccode\u003eseikyusho_bango\u003c\/code\u003e, \u003ccode\u003eshiharai_kigen\u003c\/code\u003e, \u003ccode\u003ezeikomi_gokei\u003c\/code\u003e.\n  \u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eAccount receivable teams want to turn emailed PDF invoices into sheet-ready records automatically.\u003c\/li\u003e\n  \u003cli\u003eSaaS operators managing vendor billing can centralize due dates and totals without manual copy\/paste.\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers can deploy a repeatable Gmail-to-Google-Sheets invoice pipeline using OpenAI extraction.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n trigger\u003c\/strong\u003e: Gmail trigger that checks every minute for \u003cem\u003eunread\u003c\/em\u003e emails with PDF attachments.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eValidation \u0026amp; logic\u003c\/strong\u003e: filter logic to ensure the first attachment is a PDF.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePDF processing\u003c\/strong\u003e: “Extract from file” handling to retrieve and combine text.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAI extraction\u003c\/strong\u003e: LangChain OpenAI Chat Model (OpenAI credential required) for field extraction.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eData handling\u003c\/strong\u003e: code step to normalize values into a consistent JSON structure before writing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStorage\u003c\/strong\u003e: Google Sheets append into \u003ccode\u003einvoice_lite\u003c\/code\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003cp\u003e\u003cstrong\u003eSetup requirements:\u003c\/strong\u003e connect Gmail (read unread messages + download attachments), add an OpenAI credential for the LangChain OpenAI Chat Model, create the Google Sheets tab \u003ccode\u003einvoice_lite\u003c\/code\u003e with the specified headers, then send a test email with a PDF invoice—confirming a new row is added.\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46008697454771,"sku":"N8N-19514","price":36.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/7UAe1hf1G-eY6eHFmZbvJ_3GN0xcIf.png?v=1789203753","url":"https:\/\/buyflowscripts.com\/products\/gmail-invoice-pdf-extractor-with-openai-to-google-sheets-n8n","provider":"N8N Commerce","version":"1.0","type":"link"}