# Invoice Payment Processing

Automatically read a vendor invoice, extract its details and line items, reconcile the charges against its stated total, and route only the exceptions to a person before payment.

## The business problem

Vendor invoices — from defense counsel, IMEs, investigators, restoration vendors, repair shops, and other service providers — arrive against open claims in whatever format the vendor sends: email, portal, EDI, mail, PDF. Someone has to open each one, index it to the right claim, check the charges, and route it for payment — time that comes out of claim work, not invoice triage. Discrepancies like duplicated or out-of-scope line items and totals that don't add up are easy to miss one invoice at a time, and compound across a book of business.

The **Invoice Payment Processing** template automates that pass: it extracts the invoice details and every line item, reconciles the line items against the invoice's stated total, and writes payment insights and a recommended action — so a reviewer only sees the invoices that don't reconcile, are missing required information, or were extracted with low confidence.

## Trigger and source data

The template ships with the **Manual File Upload** trigger. You can configure other triggers if you'd like, including a connection to an Outlook email inbox. See [Configure triggers](../build-ai-agents/triggers.md).

To run the template, upload a vendor invoice, along with any cover correspondence that travels with it. By default, the template works entirely from the uploaded content.

## Template starting point

Create an AI agent from the **Invoice Payment Processing** template for a working flow that extracts, reconciles, validates, and routes for review out of the box. Open it in the canvas, select an environment, click **Start Editing**, and adjust it to your invoice mix — field prompts, extraction rules, or validation thresholds. See [Create an AI Agent](../build-ai-agents/create-agent.md).

## What the template preconfigures

The template will execute the following nodes:

| Step in the flow | Node it uses | Category |
| --- | --- | --- |
| Prepare the uploaded files | [Read Files](../build-ai-agents/utility-nodes.md) | Utility |
| Extract the invoice details (claim number, policy number, claimant, vendor, invoice number, dates, total, bill type) | [InsurGPT: Custom](../build-ai-agents/insurgpt-nodes.md) | InsurGPT |
| Extract every billed line item | [InsurGPT: Custom](../build-ai-agents/insurgpt-nodes.md) | InsurGPT |
| Reconcile the line items against the invoice's stated total | [Custom Code Blocks](../build-ai-agents/utility-nodes.md) | Utility |
| Generate the payment insights — summary, due-date note, charge coherence, payment risk flags, and a recommended action | [InsurGPT: Custom](../build-ai-agents/insurgpt-nodes.md) | InsurGPT |
| Check extracted values and the reconciliation result against rules | [Field Validation](../build-ai-agents/utility-nodes.md) | Utility |
| Branch on whether review is required | [If](../build-ai-agents/control-nodes.md) | Control |
| Route the invoice to a person, only when needed | [Review](../build-ai-agents/utility-nodes.md) | Utility |
| Summarize the actions taken, whether or not review ran | [Custom Code Blocks](../build-ai-agents/utility-nodes.md) | Utility |
| Close out the item | [Complete](../build-ai-agents/action-nodes.md) | Action |

## What builders must configure before deployment

- **Field sets and bill-type categories.** Tune the extraction prompts and the bill-type categories to the vendor types and claim lines you actually process.
- **Validation thresholds and review routing.** Set confidence thresholds and the reviewer assignment to your standards. See [Utility nodes](../build-ai-agents/utility-nodes.md).
- **A connection to your claim and fee-agreement systems.** We recommend an [HTTP node](../build-ai-agents/utility-nodes.md) after validation to look up the claim and its fee agreement, followed by a [Custom Code Block](../build-ai-agents/utility-nodes.md) to apply your own rate and authority checks.

## How the AI agent behaves

The agent extracts the invoice details, then every line item, in two passes so each can carry its own field set.

A **Custom Code Block** sums the line items and compares the total to the invoice's stated total, returning **Match**, **Mismatch**, or **Unable to Verify** with a reconciliation detail explaining the arithmetic. A second InsurGPT pass factors that result into a plain-language invoice summary, a due-date note, a charge-coherence check that names any duplicate or out-of-scope line items, and payment risk flags such as an overdue or future-dated invoice or a bill date inconsistent with its own cover correspondence. The same pass writes a recommended action addressed to the reviewer, and it never recommends approval when reconciliation didn't match.

Low-confidence or missing fields are flagged by validation rather than invented, and **Grounding** ties each extracted value back to its place on the page.

## Human review model

Review happens on the item in the Bevaya Platform.

- The **Insights tab** opens with an AI recommendation, key fields (claim number, vendor name, total amount), the invoice summary, the billing reconciliation detail, and payment risk flags.
- The **Review tab** is organized by group — Claim Identification, Invoice Details, Line Items, Billing Reconciliation, Payment Insights, and Outcome — where the reviewer confirms values, corrects a mistranscribed amount, and approves.

When an invoice is routed for review, the exception reason names the specific fields that were flagged — for example a reconciliation mismatch or a missing invoice number — so the reviewer knows exactly what to check first. See [Human review](../monitor-review/human-review.md).

## Run status and reporting

Each invoice becomes an item that moves through the standard lifecycle statuses — **In Progress, Review, Complete, Failed, Canceled**. Watch individual runs and inspect each step's input, output, and status in [Run history](../monitor-review/run-history.md), and see live counts of items by status on the [Item status reporting](../monitor-review/item-status-reporting.md) page.

## Example run

A restoration vendor submits an invoice for $4,200 against an open property claim, itemizing water extraction, drying equipment rental, and a routine gutter cleaning. The scan is faint enough that the invoice number comes back low-confidence.

1. The flow reads the file and extracts the invoice details and its three line items.
2. It sums the line items to $4,200 and reconciles cleanly against the invoice's stated total — a **Match**.
3. The payment-insights step flags the gutter-cleaning line as out of scope for a water-damage repair in its charge-coherence note.
4. Validation flags the low-confidence invoice number, and the item routes to review with that reason named.
5. The reviewer opens the item, corrects the invoice number, reads the charge-coherence note, removes the gutter-cleaning line, and submits. The item is marked complete.

## Common failure modes

- **An invoice's line items don't match its stated total.** The flow always flags this for review rather than silently accepting or averaging it — the gap is commonly explained by a deductible, discount, or fee the invoice doesn't break out as its own line, but it's the reviewer's call to confirm against the source document.
- **Duplicate or out-of-scope line items.** The payment-insights step names any it notices in its charge-coherence note, so a reviewer already on the item has that context. Add a Field Validation rule on `charge_coherence` alongside the existing rules to have it route the invoice to review on its own.
- **Low-confidence or missing required fields on a poor scan.** Flagged by validation and surfaced for review rather than guessed.

## Recommended rollout path

1. **Connect it to your claim and fee-agreement systems.** Add the HTTP and Custom Code Block nodes for your claim lookup, rate checks, and authority rules.
2. **Build and test on real invoices.** Use **Run Draft** on representative invoices across your vendor mix, inspecting each step. See [Test and debug a draft](../build-ai-agents/test-debug-draft.md).
3. **Pilot with a reviewer** to confirm extraction, reconciliation, and risk-flag accuracy on your document mix.
4. **Promote to production.** Publish the flow and configure your production trigger. See [Drafts and publishing](../build-ai-agents/drafts-publishing.md).

## Where to go next

- [Utility nodes](../build-ai-agents/utility-nodes.md) — Field Validation, Custom Code Blocks, and Review.
- [InsurGPT nodes](../build-ai-agents/insurgpt-nodes.md) — extraction and insights.
- [Control nodes](../build-ai-agents/control-nodes.md) — If.
- [App integration nodes](../build-ai-agents/app-integration-nodes.md) — connect a write-back to your own systems.
- [Human review](../monitor-review/human-review.md) — the Insights and Review tabs the reviewer works from.
- [Item status reporting](../monitor-review/item-status-reporting.md) — track invoices by status.
- [Medical Bills Identification and Extraction](./medical-bills-identification-and-extraction.md) — a related template for identifying and extracting medical bills before they reach payment processing.
- [Use cases overview](./overview.md) — the full catalog of supported patterns.
