{"product_id":"invoice-ocr-validation-with-openai-postgresql-slack","title":"Invoice OCR \u0026 Validation with OpenAI, PostgreSQL \u0026 Slack","description":"\u003ch3\u003eAutomatically extract, validate, and log invoices from PDF—then notify Slack\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow receives invoice PDFs via a webhook, uses \u003cstrong\u003eOpenAI\u003c\/strong\u003e to extract structured invoice data, validates required fields, saves results to \u003cstrong\u003ePostgreSQL\u003c\/strong\u003e, and posts a clear status update to \u003cstrong\u003eSlack\u003c\/strong\u003e—with success\/error responses returned to the webhook caller.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReceives invoices:\u003c\/strong\u003e Accepts an uploaded PDF through a \u003cstrong\u003ePOST webhook endpoint\u003c\/strong\u003e (use the binary field name \u003cem\u003efile\u003c\/em\u003e).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtracts and cleans text:\u003c\/strong\u003e Pulls text from the PDF and normalizes whitespace and line breaks for reliable parsing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eParses invoice fields with OpenAI:\u003c\/strong\u003e Sends the cleaned invoice text to \u003cstrong\u003eOpenAI\u003c\/strong\u003e to extract key fields (e.g., vendor, invoice number, dates, amounts, currency, tax, and category) as \u003cstrong\u003eJSON\u003c\/strong\u003e using \u003cstrong\u003egpt-4o-mini\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eValidates required data:\u003c\/strong\u003e Checks that essential fields like \u003cstrong\u003evendor name\u003c\/strong\u003e and \u003cstrong\u003etotal amount\u003c\/strong\u003e are present.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStores outcomes in PostgreSQL:\u003c\/strong\u003e\n    \u003cul\u003e\n      \u003cli\u003eValid invoices are written to \u003cstrong\u003epublic.invoices\u003c\/strong\u003e.\u003c\/li\u003e\n      \u003cli\u003eValidation failures are recorded in \u003cstrong\u003efailed_invoices\u003c\/strong\u003e.\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNotifies Slack:\u003c\/strong\u003e Posts a formatted message to the same \u003cstrong\u003eSlack\u003c\/strong\u003e channel for both successful and failed processing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReturns a webhook response:\u003c\/strong\u003e Sends a JSON success or failed status response after processing completes.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eSaaS operations teams ingest incoming supplier invoices and turn PDFs into structured records automatically.\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers route invoice data into accounting-like systems using validated fields only.\u003c\/li\u003e\n  \u003cli\u003eTeams that need audit-friendly error handling for unreadable or incomplete invoices.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNodes\/stack:\u003c\/strong\u003e webhook, OpenAI (gpt-4o-mini), code, if, postgres, slack, sticky note\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore logic:\u003c\/strong\u003e PDF text extraction \u0026amp; cleaning → OpenAI JSON parsing → required-field validation → PostgreSQL write → Slack notification → webhook JSON response\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46018928607411,"sku":"N8N-19558","price":19.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/MVWFnI_fx4ZfIP9R5sH_n_1OozRMTc.png?v=1789376571","url":"https:\/\/buyflowscripts.com\/products\/invoice-ocr-validation-with-openai-postgresql-slack","provider":"N8N Commerce","version":"1.0","type":"link"}