Skip to main content
  1. Projects/

AI-Powered Purchase Order Ingestion

Overview
#

We built an AI-to-ERP integration layer that lets an AI assistant convert customer purchase orders into sales orders inside a legacy B2B order-management system. The integration exposes structured tools via the Model Context Protocol (MCP), giving the AI a controlled, single API surface for looking up data, validating references, creating records, and uploading supporting documents.

The problem
#

The operations team received a high volume of customer purchase orders as PDFs and image attachments. Each PO had to be read by a person, the customer and products looked up manually, and the data re-typed into an older order system. The process was slow, error-prone, and hard to scale.

Our role
#

We designed and implemented the MCP tool layer that connects the AI to the order system. This included defining tool contracts, writing validation rules, building the backend service that persists the order, and handling the document-upload handoff.

Architecture
#

The flow is orchestrated by the AI but enforced by the backend:

  1. Extraction — The AI reads the PO and extracts header data, line items, fees, shipping details, and the original quote number.
  2. Validation — The AI calls lookup tools to confirm the customer exists, the bill-to/ship-to addresses exist, the carrier and service type are valid, and any quote or product matches are unambiguous.
  3. Creation — A single MCP tool call creates the sales order, line items, and optional charge records.
  4. Document upload — The response includes a presigned URL. The AI uploads the original PO file to that URL so the order is permanently linked to the source document.

Key tools built
#

ToolPurpose
create-customer-order-from-customer-poCreates the sales order and returns a document upload URL
search-customers / create-customerVerify or create the customer before ordering
list-customer-addresses / create-customer-addressResolve or add bill-to/ship-to addresses
list-carriers / list-service-typesValidate shipping options
search-products / find-quote-id-by-number / list-quoted-productsMatch PO line items to the right products
list-cost-categoriesMap PO fees to the correct ledger categories

Notable design decisions
#

  • Fail-fast validation: The AI is never allowed to invent IDs. Every reference must come from a prior tool result or be explicitly present in the PO.
  • Quote-to-order linkage: Orders created from quoted POs are linked to the original quote, enabling downstream conversion tracking and quote performance analytics.
  • Document linkage: Orders are not considered complete until the source PO file is uploaded to a presigned object-storage URL and attached as an order document.

Tech stack
#

  • Java 21
  • Apache Tomcat
  • Spring Framework

Outcome
#

The integration gives the operations team a path toward hands-off PO ingestion: the AI reads the document, the MCP layer enforces correctness, and the sales order is created and linked to the original PO without manual re-entry.

Discuss a Similar AI Integration