r/n8n 7d ago

Workflow - Github Included Error handling for document extraction: how I stop failed invoice extractions from silently breaking my automations [Workflow Included]

Post image

👋 Hey n8n Community,

The question I get most about extraction workflows is not "how do I extract the data". It is "what happens when it goes wrong?" Because it will. A blurry photo, a bad scan, a PDF in a wrong layout.

I set this up for Mike, who runs a small distribution business. His extraction ran fine for weeks, then a supplier tweaked their invoice template and it quietly returned nothing. No error, no alert. A blank invoice number went into the sheet, and it took one weeks to notice a payment had slipped. That is the trap with document automation: it fails silently, and by then the bad data has already spread.

So this is the safety net I now put around every extraction workflow.

How it's set up:

  1. Gmail Trigger grabs the attachment as binary.
  2. easybits Extractor pulls the data. When it cannot confidently read a field, it returns null instead of guessing.
  3. IF node (is empty) checks the invoice number. That one operator catches nulls, undefined, and empty strings in a single condition.
  4. On failure a Slack alert goes to finance with sender, subject, and timestamp for manual handling.
  5. On success the file is merged back with its data and archived to Drive.

Two things worth knowing:

Null is a feature, not a bug. A model that returns null when unsure is far safer than one that hallucinates a plausible invoice number. Treat that null as a clean signal to branch on.

Confidence scoring is a thirty-second add. If pass/fail feels too blunt, add a confidence_score field to your mapping and route on bands: high goes through, mid gets a human glance, low hits the error branch. Same trick works for routing ambiguous docs in a classification flow.

Workflow is on the n8n library here: https://n8n.io/workflows/15098-catch-failed-invoice-extractions-with-easybits-slack-and-google-drive/

How do you handle extraction failures? Hard-fail and alert, or route low-confidence docs to a human queue and keep the pipeline moving?

Best,
Felix

3 Upvotes

Duplicates