{"product_id":"gmail-pdf-table-extract-to-google-sheets-openai-slack-n8n","title":"Gmail PDF Table Extract to Google Sheets (OpenAI + Slack) - n8n","description":"\u003ch3\u003eExtract PDF tables from Gmail, verify totals, and auto-post line items to Google Sheets\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow reads PDF attachments from incoming Gmail report emails, extracts the table using OpenAI, \u003cstrong\u003ereconciles the math in plain JavaScript\u003c\/strong\u003e, and only writes to your Google Sheets “Line Items” when the sum matches the printed total—otherwise it flags the issue in Slack and logs it to “Needs Review”.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eTriggers on new Gmail messages\u003c\/strong\u003e under a configured label and downloads the attachment for processing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFilters attachments to PDFs only\u003c\/strong\u003e, then converts each PDF into plain text.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eUses OpenAI with a structured output schema\u003c\/strong\u003e to extract:\n    \u003cul\u003e\n      \u003cli\u003ereport title\u003c\/li\u003e\n      \u003cli\u003ecurrency\u003c\/li\u003e\n      \u003cli\u003estated total (as printed in the PDF)\u003c\/li\u003e\n      \u003cli\u003eall line-item rows from the PDF text\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSums extracted line totals in JavaScript\u003c\/strong\u003e and compares them to the stated total using configurable absolute and percentage tolerances.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIf totals reconcile:\u003c\/strong\u003e splits the extracted rows into individual line items and \u003cstrong\u003eappends them to the “Line Items” tab\u003c\/strong\u003e in Google Sheets.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIf totals do not reconcile (or no stated total exists):\u003c\/strong\u003e appends a summary row to the \u003cstrong\u003e“Needs Review” tab\u003c\/strong\u003e and posts a \u003cstrong\u003emismatch alert to Slack\u003c\/strong\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eAutomatically capture \u003cstrong\u003einvoice-like report line items\u003c\/strong\u003e received via Gmail into Google Sheets for bookkeeping.\u003c\/li\u003e\n  \u003cli\u003eReduce extraction errors by \u003cstrong\u003everifying totals\u003c\/strong\u003e instead of trusting model calculations.\u003c\/li\u003e\n  \u003cli\u003eCreate an operational review queue (“Needs Review”) and notify your team in \u003cstrong\u003eSlack\u003c\/strong\u003e when reports don’t match.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGmail trigger\u003c\/strong\u003e filtered by label ID\/name; processes PDF attachments.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePDF to text\u003c\/strong\u003e conversion step.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOpenAI structured extraction\u003c\/strong\u003e for title, currency, stated total, and line-item rows.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eJavaScript total reconciliation\u003c\/strong\u003e with absolute\/percentage tolerances.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e writes to “Line Items” or “Needs Review”.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSlack\u003c\/strong\u003e mismatch alerts.\u003c\/li\u003e\n  \u003cli\u003eImplemented with nodes including \u003cstrong\u003eif, set, code, slack, filter, split out\u003c\/strong\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45978923794611,"sku":"N8N-19346","price":6.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/aCtUvCdCPhY_L2BZJMEux_AVupEijw.png?v=1788858992","url":"https:\/\/buyflowscripts.com\/products\/gmail-pdf-table-extract-to-google-sheets-openai-slack-n8n","provider":"N8N Commerce","version":"1.0","type":"link"}