{"product_id":"gmail-to-google-sheets-invoice-ocr-with-openai-gpt-4o-n8n","title":"Gmail to Google Sheets Invoice OCR with OpenAI GPT-4o (n8n)","description":"\u003ch3\u003eTurn PDF invoice emails into structured rows in Google Sheets—automatically\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow polls your \u003cstrong\u003eGmail\u003c\/strong\u003e inbox for \u003cstrong\u003ePDF invoice\/receipt attachments\u003c\/strong\u003e, extracts the text, uses \u003cstrong\u003eOpenAI GPT-4o\u003c\/strong\u003e to parse key invoice fields into strict JSON, and then \u003cstrong\u003eappends the results to Google Sheets\u003c\/strong\u003e as a new row—ready for reporting, reconciliation, and downstream automation.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePolls Gmail every 15 minutes\u003c\/strong\u003e for messages matching the query: \u003ccode\u003ehas:attachment filename:pdf (invoice OR receipt)\u003c\/code\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDownloads the first PDF attachment\u003c\/strong\u003e found in each matching email and \u003cstrong\u003eerrors if no PDF is present\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtracts text from the PDF\u003c\/strong\u003e attachment.\u003c\/li\u003e\n  \u003cli\u003eSends the extracted text to \u003cstrong\u003eOpenAI Chat Completions\u003c\/strong\u003e using \u003cstrong\u003egpt-4o-mini\u003c\/strong\u003e and requests a \u003cstrong\u003estrict JSON object\u003c\/strong\u003e containing: vendor, invoice number, dates, currency, and amounts.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eParses the OpenAI response\u003c\/strong\u003e, adds the \u003cstrong\u003esender email address\u003c\/strong\u003e and a \u003cstrong\u003eprocessed timestamp\u003c\/strong\u003e, and normalizes missing fields to \u003ccode\u003enull\u003c\/code\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAppends a new row to Google Sheets\u003c\/strong\u003e with invoice fields and email metadata.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eAccounts payable teams who receive invoices by email and want an always-updated \u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e ledger.\u003c\/li\u003e\n  \u003cli\u003eSaaS operators consolidating recurring vendor billing into a single spreadsheet for visibility.\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers building invoice ingestion pipelines without manual copy\/paste from PDFs.\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 (with a configurable search query and a \u003cstrong\u003e15-minute polling interval\u003c\/strong\u003e).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtract from file\u003c\/strong\u003e step for PDF text extraction.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHTTP Request\u003c\/strong\u003e to \u003ccode\u003ehttps:\/\/api.openai.com\/v1\/chat\/completions\u003c\/code\u003e using an \u003cstrong\u003eOpenAI API credential\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOpenAI Chat Completions\u003c\/strong\u003e prompt returns \u003cstrong\u003estrict JSON\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e integration to append rows.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eSetup checklist\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eConnect Gmail credentials to the \u003cstrong\u003eGmail Trigger\u003c\/strong\u003e and ensure you can access the invoice emails mailbox.\u003c\/li\u003e\n  \u003cli\u003eAdd \u003cstrong\u003eOpenAI API credentials\u003c\/strong\u003e for the HTTP request to the Chat Completions endpoint.\u003c\/li\u003e\n  \u003cli\u003eConnect \u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e and ensure your sheet has matching columns: \u003cem\u003eVendor, Invoice #, Date, Due Date, Currency, Subtotal, Tax, Total, Email From, Processed At\u003c\/em\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45905431724211,"sku":"N8N-18742","price":30.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/9SPtXZ8pPYq6_hWlJqU89_KYuBRKMZ.png?v=1787821722","url":"https:\/\/buyflowscripts.com\/products\/gmail-to-google-sheets-invoice-ocr-with-openai-gpt-4o-n8n","provider":"N8N Commerce","version":"1.0","type":"link"}