{"product_id":"n8n-gmail-pdf-invoice-ocr-ai-extract-to-google-sheets","title":"n8n Gmail PDF Invoice OCR \u0026 AI Extract to Google Sheets","description":"\u003ch3\u003eTurn IKEA-style PDF invoices from Gmail into structured Google Sheets—automatically\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow watches your Gmail inbox for unread invoice emails from a specific sender, saves the attached PDFs to Google Drive, runs OCR with Mistral, and uses Google Gemini to extract structured invoice data—then appends invoice headers and line items into Google Sheets.\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 from a configured sender (and applies a Gmail label after processing).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDownloads attachments\u003c\/strong\u003e and splits the email into one item per attachment.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFilters to PDFs only\u003c\/strong\u003e by checking the MIME type.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRoutes and archives invoices in Google Drive\u003c\/strong\u003e based on a filename prefix, then downloads the archived PDF for OCR.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRuns OCR with Mistral\u003c\/strong\u003e by uploading the PDF to the Mistral Files API, retrieving a signed URL, waiting briefly, and submitting the document URL to the Mistral OCR API.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtracts structured invoice data with Google Gemini\u003c\/strong\u003e by sending the OCR text to a Gemini chat model and parsing the returned JSON (invoice summary + line items).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eWrites to Google Sheets\u003c\/strong\u003e: appends invoice summary fields to the \u003cem\u003eInvoices\u003c\/em\u003e tab and each line item to the \u003cem\u003eInvoice_Items\u003c\/em\u003e tab.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eMarks the email as handled\u003c\/strong\u003e by adding the configured Gmail label.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eAutomate extraction of invoice totals, vendor details, and line items from PDF invoices sent via email.\u003c\/li\u003e\n  \u003cli\u003eReduce manual work for SaaS operations and finance teams by keeping Google Sheets up to date from inbox activity.\u003c\/li\u003e\n  \u003cli\u003eBuild a lightweight invoice ingestion pipeline using n8n, OCR, and AI extraction—without changing how invoices are delivered.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eTrigger:\u003c\/strong\u003e Gmail (checks every minute for unread messages from a specified sender).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eProcessing:\u003c\/strong\u003e filter, switch, code (splits attachments, validates PDFs, parses\/cleans Gemini JSON, generates invoice ID).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStorage:\u003c\/strong\u003e Google Drive (archives PDFs to a target folder).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOCR:\u003c\/strong\u003e Mistral Files API + Mistral OCR API (signed URL flow).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAI extraction:\u003c\/strong\u003e Google Gemini chat model (structured JSON output).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOutputs:\u003c\/strong\u003e Google Sheets (\u003cem\u003eInvoices\u003c\/em\u003e and \u003cem\u003eInvoice_Items\u003c\/em\u003e tabs).\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45741419167923,"sku":"N8N-17600","price":23.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/w9UgAW2rH7OJJ8rSZ8bHt_Oild9J4a.png?v=1785316186","url":"https:\/\/buyflowscripts.com\/products\/n8n-gmail-pdf-invoice-ocr-ai-extract-to-google-sheets","provider":"N8N Commerce","version":"1.0","type":"link"}