
n8n Invoice OCR to CSV & Google Sheets via Webhook
Secure checkout on the merchant’s Shopify store
<h3>Turn Invoice PDFs/Images into CSV + Google Sheets in One Webhook</h3> <p>Send an invoice file to an <strong>n8n webhook</strong>, and this workflow will extract key invoice fields using <strong>OCR.space</strong>, parse line items with deterministic rules, then return the results as <strong>JSON</strong>—while also generating a <strong>CSV</strong> and (optionally) appending the record to <strong>Google Sheets</strong>.</p> <h3>What this workflow does</h3> <ul> <li> <strong>Accepts uploads via HTTP POST</strong>: receive an invoice PDF/image in a binary field named <strong>invoice</strong>.</li> <li> <strong>Runs OCR with OCR.space</strong>: forwards the file to the OCR.space API to extract text.</li> <li> <strong>Handles OCR failures</strong>: if OCR.space does not succeed, the workflow returns a <strong>422 JSON error response</strong>.</li> <li> <strong>Parses invoice data</strong>: extracts vendor, invoice number, invoice date, subtotal, tax, and total, plus <strong>line items</strong> using deterministic rules.</li> <li> <strong>Adds validation flags</strong>: generates flags for missing fields and line-item calculation mismatches.</li> <li> <strong>Generates a CSV</strong>: converts extracted fields into a CSV file and writes it to disk (default path: <strong>./output/</strong>).</li> <li> <strong>Optionally updates Google Sheets</strong>: appends the extracted record to a worksheet.</li> <li> <strong>Returns extracted results</strong>: responds with the extracted invoice data, including flags and raw OCR text.</li> </ul> <h3>Use cases</h3> <ul> <li>Automate AP data capture by converting invoice PDFs into structured records for finance workflows.</li> <li>Centralize invoicing data in <strong>Google Sheets</strong> for visibility and lightweight reporting.</li> <li>Build an internal tool that uploads invoices to an <strong>n8n webhook</strong> and immediately receives parsed JSON.</li> </ul> <h3>Technical details</h3> <ul> <li> <strong>OCR.space</strong> integration via HTTP request (header auth uses <strong>apikey</strong>).</li> <li>Uses <strong>webhook</strong>, <strong>http request</strong>, <strong>if</strong>, <strong>code</strong>, and <strong>Google Sheets</strong> nodes (plus sticky note documentation).</li> <li>Requires write access to the configured CSV output path (default: <strong>./output/</strong>).</li> </ul>



