跳到正文
DEV Community· Ahmed Negm·· 1 天前AI 評分43

更安全的 n8n 發票工作流程:抽取、驗證,再交由人工審核

A safer n8n invoice workflow: extract, validate, then review

AI 導讀

這個 n8n 示範以 Gemini 從阿拉伯文或英文 PDF、JPG、PNG 發票抽取欄位,再用程式核對總額及檢查重複記錄,並將結果存入 n8n Data Table 等待人工審核。流程不會批准發票或提交至 ERP;儲存庫有 26 項離線檢查通過,但這不代表已完成即時 n8n 測試或適合投入正式環境。

正文

Ahmed Negm

An invoice workflow can fail in two different ways: it can extract the wrong value, or it can confidently move a correct-looking value into the wrong business action. I designed this n8n demo to make those steps visible and keep approval outside the automation.

The example processes Arabic or English invoices supplied as PDF, JPG, or PNG. It uses Gemini to extract fields, then applies deterministic checks to catch arithmetic inconsistencies before writing a record to an n8n Data Table. Each record remains pending review.

The flow

  1. Receive the file. The workflow accepts an invoice document and routes supported formats into extraction.
  2. Extract candidate fields. Gemini returns structured values such as supplier, invoice number, line amounts, tax, and total. These are suggestions from a model, not trusted accounting data.
  3. Check arithmetic in code. The workflow recalculates totals and compares them with the extracted total. A mismatch is recorded as a validation issue rather than silently accepted.
  4. Look for duplicates. It checks the supplier and invoice number against prior records. This catches a common repeat-submission case, though it is not a universal duplicate detector.
  5. Save for review. The result is written to an n8n Data Table with a pending-review state so a person can inspect the document and extracted values.

Why keep approval separate?

Extraction quality and business authorization are different questions. A model can help turn an unstructured document into fields, and code can check arithmetic, but neither decides whether a payment should be approved. Keeping the demo at “pending review” makes that boundary explicit.

The same separation is useful when tailoring an invoice process for a business: define what the system may extract, which checks can be deterministic, who reviews exceptions, and what authenticated downstream action is permitted. A production integration would also need the customer’s document storage, access rules, accounting system, retention policy, and error-handling requirements. Those are not included here.

What I verified

The repository includes two workflow exports, six screenshots, synthetic invoice examples, and 26 passing offline checks. Those checks do not establish a fresh live n8n run or production readiness. The public exports need credentials, the supporting subworkflow and Data Tables to be configured, and fresh runtime testing; the backup Gemini model also needs review. The demo does not approve invoices, post to an ERP, or claim zero errors or measured savings.

Source and setup notes: https://github.com/ahmednegm91/intelligent-invoice-processing

This is a portfolio demonstration of an approach I can adapt after requirements and approval boundaries are clear.

來源:DEV Community · dev.to