Three way match automation is the process of comparing the purchase order with the goods receipt and vendor invoice in order to verify that the items ordered were received and that the items received were invoiced for. An AI agent is able to compare the three documents and apply tolerance rules for clean matches as well as flag exceptions for a named person to review and approve.

This guide will explain how to create this agent step-by-step. The logic can be implemented using Copilot Studio, Power Automate or any other tool. If you are new to the concept of AI agents in accounting, then first read our overview on AI agents in accounting.

What is a 3-way match?

The three-way match is an accounts payable control that matches the vendor invoice with the purchase order and the goods receipt prior to paying the vendor.

DocumentOwnerWhat it proves
Purchase order (PO)ProcurementWhat was approved: item, quantity and price
Goods receiptReceivingWhat actually arrived, and in what condition
Vendor invoiceThe supplierWhat the supplier is asking to be paid

Two-way matching skips the receipt. This is faster than three-way matching but risks paying for what was ordered rather than what arrived. It is typically used for services and for low-risk, recurring vendors.

Where invoices fail the match

Exceptions can be categorized into several different types. Tipalti identified some of these issues, including missing purchase orders (POs) and possible duplicates. Common sources of these exceptions include:

  • Quantity Differences. An invoice lists 50 items and the receipt lists 48.
  • Price Differences. The unit price listed on the invoice exceeds the unit price listed on the PO.
  • Missing PO or Receipt. Items were received, but no record was made, or the invoice does not contain a PO #.
  • Partial Deliveries. There are multiple receipts for a single PO and only one invoice.
  • Duplicate Invoices. Multiple copies of the same invoice have been submitted.
  • Unit Mismatch / Extra Lines. Cases vs Units; Freight and Tax not included in PO.

An effective customer service agent will identify what specifically caused the exception, to what degree, and provide direction as to who needs to investigate further.

Three way match automation: build the agent step by step

Select a small scope first, e.g. vendor group or cost category. Collect 25–30 past invoices, POs and receipts. Include some with issues. Use sample data or anonymized data to get started.

Step 1: Define the job and the boundaries

Write one sentence: “The agent compares each invoice to the corresponding Purchase Order and receipt and approves any differences within tolerance. Those which vary outside of tolerance are sent to the AP department for further action.” What else should the agent not do? The agent should not alter a Purchase Order, alter the bank details of the vendor to release a payment.

Define the job and the boundaries
Define the job and the boundaries

Example of agent name, description and associated instructions (sample data is illustrative only).

Step 2: Set up the inputs

Three sources are needed by the agent: the invoice (typically attached to a message in a shared mailbox or folder), the PO information and the receipt information. Usually these last two items come from exports or tables in your ERP. Decide where each of these items are located and grant read-only access to the agent.

Set up the inputs
Set up the inputs

Figure 2: Connecting the invoice mailbox or folder and the PO and receipt tables (illustrative sample data).

Step 3: Extract the invoice fields

To extract vendor name, invoice number, date, PO number, line items, quantities, unit prices and total from an invoice. Please have the agent flag any field that it cannot read with confidence as opposed to guessing.

Step 4: Write the matching rules

The agent can perform the comparisons at the field level, not the document level. For each invoice line, the agent will verify six items:

  • Vendor on invoice == Vendor on PO.
  • PO Number exists and is still open.
  • Item or Description is equal to Item or Description.
  • Invoiced Quantity <= Received Quantity.
  • Invoiced Unit Price = PO Unit Price +/- Tolerance.
  • Invoice Total = Sum of Invoice Lines + any approved extra charges.

Step 5: Set tolerance limits

Tolerances prevent the queue from filling with lots of minor differences. In most finance systems (such as Sage Intacct), tolerances for document matching are set as separate percentages for quantity and unit price. Any differences outside these percentages are treated as exceptions. These can be set as you see fit after agreement with the controller. Below is an illustrative table.

CheckSample toleranceIf withinIf outside
Quantity invoiced vs received0%PassException to AP
Unit price vs PO2% or $25 per line, whichever is lowerPassException to the buyer
Invoice total vs PO total1%PassException to the AP lead
Duplicate invoice numberNoneNot applicableBlock and alert

The Sage Intacct documentation provides a useful test case: a PO for 50 desks at $100 and a receipt for 48 is a 4% quantity shortfall which passes or fails depending on the quantity tolerance set.

Step 6: Route exceptions to the right person

The different types of errors are sent to different people. Price errors go to the buyer, missing receipts go to the receiving team, unknown vendors go to AP. The agent sends a short message with the invoice number, the failed check, the amounts on each document and a link to the files.

Route exceptions to the right person
Route exceptions to the right person

Figure 3: Exception routing and the message the agent sends (illustrative sample data).

Step 7: Add the approval step

For clean matches, determine whether the agent marks the match “ready to pay” and also sends it to an approver. For the first version, mark the match and have AP pay it. Add an approval to any invoice that is above a certain dollar amount per policy.

Step 8: Log everything

All decisions must be logged with the invoice, the documents it was matched against, the checks that were run, the result, the time, and the person who approved the override.

Log everything
Log everything

Figure 4: The log or tracker the agent writes to (illustrative sample data).

Step 9: Test with known cases

Run your 25 to 30 past invoices through the agent and see what AP did with them. Then go through all the differences between the agent’s results and AP’s results and tighten the rules until the results are completely consistent and boring.

Step 10: Pilot, then widen

Run the agent along with your normal process for a month. Get someone to double check a sample each week. Do not expand to more vendors until the exception queue is healthy.

Controls and audit trail checklist

Controls are more important for an agent in accounts payable because they are near cash.

The person who creates a PO should not be the person who receives the PO, nor should they be the person who pays the PO. The accounts payable agent should not be able to do all three of these actions.

  • Read-only by default. The agent reads documents and writes only to the tracker and to messages.
  • Controlled changes. Only the named owner of a tolerance or rule can make changes to that tolerance or rule. Any changes must be recorded.
  • Human decision on money. The agent never releases a payment.
  • Duplicate checks. Compare vendor, invoice number and amount together.
  • Sampling. Review a sample of auto-approved invoices every month.
  • Evidence. Keep the log, the matched documents and any override notes together, so an auditor can follow one invoice from start to finish.

Practice it hands-on

If you prefer to be guided through the process, then the accounts payable agent in Miles AI Labs operates with the exact same logic but in a no-code setting using practice data (no client information, no setup required). Miles Masterclass sessions provide the control thinking behind the system and the hands-on practice can be used toward Miles AI Labs’ Certified AI-Ready Accountant (CAIRA) credential.

Miles Masterclass is a NASBA-registered CPE provider. State boards of accountancy grant final approval of individual courses for credit towards a license. When done well, three way match automation can remove tedious comparison and allow humans to focus on the things that require judgment.

Frequently asked questions

1. What is a 3-way match in accounts payable?

It is a payment control that checks the vendor invoice against the purchase order and the goods receipt before money leaves the business. If quantity, price and vendor agree within tolerance, the invoice can be paid. If not, it becomes an exception that a person reviews.

2. How does 2-way matching differ from 3-way matching?

2-way matching compares the invoice to the purchase order. 3-way matching compares the invoice to the purchase order and the goods received note. This extra step can take time but will help to ensure that you are not paying for goods that have not arrived or have arrived in less than full quantity.

Tolerance is the amount of difference in quantity, price or total value of an invoice that is accepted before it becomes an exception. Separate limits are usually set for quantity, unit price and total value of an invoice. Tight limits will create more exceptions while loose limits will allow some overpayments to pass through.

3. Can AI do a 3-way match?

Yes, for reading documents and comparing fields, which is where most of the manual effort sits. A person should still review exceptions and decide on payment. The agent proposes and routes, and the accountant approves, so accountability stays with a human.

Three way match automation is not the same as AP automation. AP automation is the broader process of automating the entire invoice process from capture to payment. Automating the three way match is typically the first step in automating the AP process, as the rules are simple and easy to test.