Invoice Processing Pipeline
A recipe over the shared block palette that turns invoices landing on a stage into clean, queryable tables —
continuously, as new files arrive.
When to use
Use this when the user wants to build a Snowflake pipeline around invoices — for example to:
- Process invoices (PDFs, scans, images) from a stage into clean, queryable tables — a backlog, new files as they arrive, or both.
- Automate accounts payable (AP): turn incoming invoices into structured data with no manual data entry.
- Extract a standard invoice schema (number, date, vendor, totals, line items) — or a custom one.
Do NOT use for: general non-invoice document pipelines → the base ../../references/multi-step-pipeline.md;
one-off extraction of a single invoice → a one-shot AI_EXTRACT; visual documents (blueprints, drawings) → a vision pipeline.
Read first
The orchestration scaffold (read-the-base, intake, build gate, teardown, stopping points) is shared —
../conventions.md. Load it, plus the palette router ../../blocks/README.md
and contract ../../blocks/conventions.md. This file supplies only the invoice
recipe, defaults, and smoke checks.
Also read examples/basic.md before you build — it is the full worked composition
(gate → header → line items → reconciliation → split shape) with the exact object shapes wired together, and is
the fastest way to get the stream + task + INCREMENTAL DT layout right. Do not compose the recipe from the block
palette alone without consulting it.
Recipe — blocks to compose
Head → tail (drop the optional ones the case doesn't need):
Default invoice header schema (offer it; trim/extend per the user): invoice_number, invoice_date, due_date, vendor_name, total_amount, subtotal, tax_amount, currency, po_number, payment_terms. State formats explicitly
and disambiguate near-neighbours (invoice # ≠ PO #; vendor ≠ bill-to) — field-description quality is the #1
accuracy lever. Strip non-numeric chars from amounts before TRY_CAST.
Intake topics (raise only what the prompt left open)
| Topic |
Default if unspecified |
Block |
| Languages |
English-only |
Translate (in parse-text) |
| Gate out non-invoices? |
no — assume all files are invoices |
Gate |
| Line items & output shape |
split (header + separate <prefix>_LINE_ITEMS); or header-only (skip the line-items block) |
fields (line items) → final shape |
| Totals reconciliation |
off |
reconcile |
| Vendor master to match |
none |
vendor match |
| Derived/judgment fields (priority, risk, action) |
off |
reason → triage |
| Low-confidence review gate |
off |
fields (scored) → triage |
| Final freshness (target lag) |
5 minutes |
base Step 7 |
Refresh expectation
Every DT_<prefix>_* is INCREMENTAL (base Step 6) — this recipe has no aggregate rollups. Stop and fix
any that read FULL.
Smoke checks (after the base Step 8 test)
<prefix>_HEADER returns rows and INVOICE_NUMBER / TOTAL_AMOUNT / INVOICE_DATE are populated (all-NULL →
fix the responseFormat descriptions or the TRY_CASTs).
- If split:
<prefix>_LINE_ITEMS row count is plausible against the invoice count.
Examples
examples/basic.md — full worked composition (gate → header → line items → reconciliation → split shape). Start here.
examples/triage.md — routing / fan-out after extraction; layer on a built pipeline only when asked.
1---2name: invoice-pipeline3description: "Build a persistent, Snowflake-native invoice-processing pipeline using AI_PARSE_DOCUMENT, AI_CLASSIFY, AI_EXTRACT, AI_TRANSLATE, plus incremental dynamic tables, streams and tasks. Use when the user asks for an invoice pipeline, AP automation, accounts-payable pipeline, automated invoice processing/ingestion/extraction, continuous invoice processing, or to process invoices arriving on a stage. Triggers: invoice processing pipeline, AP automation, accounts payable pipeline, automate invoices, invoice ingestion, invoice extraction pipeline, process invoices automatically, continuous invoice processing, invoice AI pipeline, AI invoice processing, build invoice pipeline, AP pipeline, invoice workflow on Snowflake."4parent_skill: ai-functions-pipeline-builder5metadata:6 source: https://skillmd.com/skills/s-14-h/invoice-pipeline7---89# Invoice Processing Pipeline1011A **recipe** over the shared block palette that turns invoices landing on a stage into clean, queryable tables —12continuously, as new files arrive.1314## When to use1516Use this when the user wants to build a Snowflake pipeline around **invoices** — for example to:1718- Process invoices (PDFs, scans, images) from a stage into clean, queryable tables — a backlog, new files as they arrive, or both.19- Automate accounts payable (AP): turn incoming invoices into structured data with no manual data entry.20- Extract a standard invoice schema (number, date, vendor, totals, line items) — or a custom one.2122**Do NOT use for:** general non-invoice document pipelines → the base [`../../references/multi-step-pipeline.md`](../../references/multi-step-pipeline.md);23one-off extraction of a single invoice → a one-shot `AI_EXTRACT`; visual documents (blueprints, drawings) → a vision pipeline.2425## Read first2627The orchestration scaffold (read-the-base, intake, build gate, teardown, stopping points) is shared —28[`../conventions.md`](../conventions.md). Load it, plus the palette router [`../../blocks/README.md`](../../blocks/README.md)29and contract [`../../blocks/conventions.md`](../../blocks/conventions.md). This file supplies only the invoice30recipe, defaults, and smoke checks.3132**Also read [`examples/basic.md`](examples/basic.md) before you build** — it is the full worked composition33(gate → header → line items → reconciliation → split shape) with the exact object shapes wired together, and is34the fastest way to get the stream + task + INCREMENTAL DT layout right. Do not compose the recipe from the block35palette alone without consulting it.3637## Recipe — blocks to compose3839Head → tail (drop the optional ones the case doesn't need):4041| Step | Block | Invoice parameter |42|------|-------|-------------------|43| Ingest | [`ingest/ingestion.md`](../../blocks/ingest/ingestion.md) | extension filter: pdf/png/jpg/jpeg/tiff |44| Parse | [`ingest/parse-text.md`](../../blocks/ingest/parse-text.md) | `mode = LAYOUT` (tables matter); `OCR` for scans/photos. Translate (same file) if multi-language. |45| Gate *(optional)* | [`extract/classify.md`](../../blocks/extract/classify.md) | binary gate, keep `DOC_TYPE = 'invoice'` |46| Header | [`extract/fields.md`](../../blocks/extract/fields.md) | the invoice header schema (below) — typed-header flavor |47| Line items *(optional)* | [`extract/fields.md`](../../blocks/extract/fields.md) | line-item / table flatten → `<prefix>_LINE_ITEMS` |48| Reconcile *(optional)* | [`records/validate.md`](../../blocks/records/validate.md) | totals reconciliation |49| Vendor match *(optional)* | [`records/validate.md`](../../blocks/records/validate.md) | fuzzy match to a vendor master |50| Reason/triage *(optional)* | [`records/reason.md`](../../blocks/records/reason.md) + [`records/triage.md`](../../blocks/records/triage.md) | priority/risk/action + a review queue |51| Serve | [`serve/final-shape.md`](../../blocks/serve/final-shape.md) | `<prefix>_HEADER` (+ `<prefix>_LINE_ITEMS`) |5253**Default invoice header schema** (offer it; trim/extend per the user): `invoice_number, invoice_date, due_date,54vendor_name, total_amount, subtotal, tax_amount, currency, po_number, payment_terms`. State formats explicitly55and disambiguate near-neighbours (invoice # ≠ PO #; vendor ≠ bill-to) — field-description quality is the #156accuracy lever. Strip non-numeric chars from amounts before `TRY_CAST`.5758## Intake topics (raise only what the prompt left open)5960| Topic | Default if unspecified | Block |61|-------|------------------------|-------|62| Languages | English-only | Translate (in `parse-text`) |63| Gate out non-invoices? | no — assume all files are invoices | Gate |64| Line items & output shape | **split** (header + separate `<prefix>_LINE_ITEMS`); or **header-only** (skip the line-items block) | fields (line items) → final shape |65| Totals reconciliation | off | reconcile |66| Vendor master to match | none | vendor match |67| Derived/judgment fields (priority, risk, action) | off | reason → triage |68| Low-confidence review gate | off | fields (scored) → triage |69| Final freshness (target lag) | 5 minutes | base Step 7 |7071## Refresh expectation7273Every `DT_<prefix>_*` is **`INCREMENTAL`** (base Step 6) — this recipe has no aggregate rollups. Stop and fix74any that read `FULL`.7576## Smoke checks (after the base Step 8 test)7778- `<prefix>_HEADER` returns rows and `INVOICE_NUMBER` / `TOTAL_AMOUNT` / `INVOICE_DATE` are populated (all-NULL →79 fix the `responseFormat` descriptions or the `TRY_CAST`s).80- If split: `<prefix>_LINE_ITEMS` row count is plausible against the invoice count.8182## Examples8384- [`examples/basic.md`](examples/basic.md) — full worked composition (gate → header → line items → reconciliation → split shape). **Start here.**85- [`examples/triage.md`](examples/triage.md) — routing / fan-out *after* extraction; layer on a built pipeline only when asked.