A MuleSoft IDP prompt that segments a scanned accounts-payable packet into its logical documents (inbound invoice, outbound invoice, work order, contract, other), tags each with a page range and confidence score, and extracts a polymorphic field set per segment in one pass.
IDP Prompt — AP Packet Segmentation (multi-doc)
Objective: Accounts-payable packets are often a scan of several stapled documents — a third-party vendor invoice, your own outbound invoice, an internal work order, and a multi-page rental contract. Manually splitting and re-keying each one is slow and error-prone. This prompt segments the whole packet by document type and extracts each segment's fields in a single IDP call.
Prerequisites
- MuleSoft IDP (Einstein) enabled; a
GENERIC document action created in Anypoint IDP.
- IDP Connector wired into the calling Mule app (per-action generated
mule-plugin dependency, not the generic connector GAV).
- Document-action prompt configured with
source: "llm".
The prompt
This document is an Anderson Crane & Bridge Technologies (ACBT) accounts-payable packet. ACBT rents under-bridge inspection equipment to its customers (e.g. Michael Baker International) and subcontracts traffic-control / freight / parts services from third parties.
A single packet typically contains MULTIPLE distinct logical documents stapled or scanned together:
- InboundInvoice — a third-party vendor billing ACBT (e.g. TCS&E flagging, Carolina Freight haul)
- OutboundInvoice — ACBT's own invoice to its customer (Anderson Crane & Bridge as the issuer)
- WorkOrder — ACBT-internal quote / work order linking a job to its costs
- Contract — multi-page rental agreement / equipment rental terms
- Other — anything else (cover sheet, blank pages, notes)
Segment the entire packet by logical document type. For each segment, extract its fields. Return ONLY a JSON array (no prose) where each element has this shape:
[
{
"documentType": "InboundInvoice" | "OutboundInvoice" | "WorkOrder" | "Contract" | "Other",
"pageRange": "<comma- or hyphen-separated page numbers, 1-indexed, e.g. \"1\" or \"4-5,7-8\">",
"confidence": <0.0..1.0 — how confident you are about the documentType classification>,
"fields": {
"vendor-name": "...",
"vendor-address": "...",
"invoice-number": "...",
"invoice-date": "<ISO 8601 yyyy-mm-dd>",
"due-date": "<ISO 8601>",
"po-number": "...",
"subtotal": <number, no currency symbol>,
"tax-amount": <number>,
"total-amount": <number>,
"bill-to": "...",
"ship-to": "...",
"payment-terms": "Net 30" | "Net 45" | ...,
"line-items": [ { "partNumber":"...", "description":"...", "quantity":<n>, "unitPrice":<n>, "lineTotal":<n> }, ... ],
"work-order-number": "...",
"customer-name": "...",
"job-site": "...",
"rental-out": "<ISO 8601 datetime>",
"rental-in": "<ISO 8601 datetime>",
"equipment": "...",
"contract-title": "...",
"renter": "...",
"signed-date": "<ISO 8601>",
"jurisdiction": "..."
}
}
]
Rules:
- Only include fields that are actually visible on that segment's pages — omit irrelevant keys (e.g. omit "renter" on an InboundInvoice).
- Numbers must be raw numbers, not strings or currency-formatted.
- For the InboundInvoice, "vendor-name" is the third-party vendor billing ACBT (NOT ACBT itself).
- For the OutboundInvoice, "vendor-name" is ACBT and "customer-name" / "bill-to" is ACBT's customer.
- For the WorkOrder, the most important fields are work-order-number, customer-name, job-site, equipment, rental-out, rental-in, subtotal.
- "pageRange" must reflect the actual page numbers — multi-page contracts often span non-contiguous pages.
- If a packet has only one segment (a single document, not a packet), return a 1-element array.
Return the JSON array directly, no markdown fences, no explanatory text.
Sample payload — segmentation + extraction output
[
{
"documentType": "InboundInvoice",
"pageRange": "1",
"confidence": 0.92,
"fields": { "vendor-name": "TCS&E Flagging", "invoice-number": "INV-4021", "total-amount": 1875.00 }
},
{
"documentType": "Contract",
"pageRange": "4-5,7-8",
"confidence": 0.81,
"fields": { "contract-title": "Equipment Rental Agreement", "renter": "Michael Baker International", "signed-date": "2026-03-14" }
}
]
Testing and validation
- Happy path: a 4-document packet (inbound invoice, outbound invoice, work order, contract) returns 4 array elements with disjoint, correctly-ordered
pageRanges.
- Edge case: a contract split across non-contiguous pages (e.g.
"4-5,7-8") — verify downstream page-range parsing handles the comma+hyphen mix rather than assuming a single contiguous block.
- Confirm
vendor-name role-reversal is correct: on InboundInvoice it's the third-party vendor, on OutboundInvoice it's ACBT itself — a common mapping bug.
Deliverable: A single prompt that both splits a mixed AP packet into its component documents and extracts a schema-appropriate field set per segment, ready to drive invoice/contract/work-order downstream processing without a separate splitting step.