A customer purchase order can be easy to read and still produce the wrong sales order. The buyer’s item code may map to a discontinued SKU. A price may be per case while the ERP prices per unit. A reply in the same email thread may change the ship-to address. The order entry team needs to see each of those differences before approving the order.
Start with one order inbox and map what the team does between opening a purchase order (PO) and entering a sales order. Give the automation a draft as its endpoint. Check what saving a draft actually does in your ERP system, including whether it reserves stock, sends an acknowledgment, or releases fulfillment. If the ERP has no draft state that keeps those effects behind approval, hold the proposed order in a staging queue and create the ERP order after a person approves it.
Record which document the customer wants processed
Capture the mailbox, provider message ID, attachment or body location, and the source document itself. Keep enough of that evidence for a reviewer to open the relevant page or email passage. The Gmail API exposes an immutable message ID, a separate thread ID, and a parsed payload made up of MIME parts. Store the provider message ID with the mailbox identity. Keep the thread ID for context because one thread can contain the original PO, a replacement, and a cancellation. Google Gmail API messages reference
Use a plain text parser for extracts from known templates and OCR for scans. An extraction model can propose fields when the layout varies. Preserve the value as written, its source location, and the normalized value separately. Keep each line tied to its source row, especially when a table spans pages. If an email attaches a PO and a quote, identify their roles before extracting the order. If the message says to use a new delivery date and the attached PO gives a different one, show both and ask the reviewer to resolve the instruction. Standardized partner feeds have a different intake contract. EDI or Emailed PDFs for Supplier Order Integration
Map the PO to the fields an order clerk checks
Treat the table as a starting point for mapping your ERP. For each destination field, agree on which source may set it, which master record can supply a default, and what should happen when they disagree.
| Customer PO data | Proposed sales order field | Check before approval |
|---|---|---|
| Buyer name, buyer account reference, billing address | Sold-to account and bill-to record | Resolve an active account in the correct selling entity and confirm the billing relationship. Use the sender as supporting evidence. |
| PO number, revision, and document date | Customer PO reference, revision, and PO date | Preserve prefixes and leading zeros. Look for previous drafts and posted orders for this account and reference. |
| Ship-to code or address and delivery instructions | Ship-to site and delivery notes | Resolve a site allowed for the account. Route unknown sites and conflicting addresses for review. |
| Customer item code, description, and PO line number | ERP SKU and customer line reference | Use the account’s item cross-reference. Check for a single active match and preserve the original line number. |
| Quantity, purchase unit, and pack size | Order quantity and unit of measure | Apply the approved conversion for that SKU. Flag missing units, unknown pack sizes, or quantities the ERP cannot represent. |
| Currency, unit price, discount, and line amount | Currency, selling price, and discount | Compare with the applicable contract, accepted quote, or approved price list on a common currency and unit basis. |
| Requested date on the header or line | Requested delivery date or line schedule | Resolve the intended date and retain any line-level overrides. Leave the committed date to the ERP’s availability process or an authorized planner. |
| Subtotal, freight, tax, and total | Reconciliation values for the draft | Compare like-for-like amounts. Keep buyer-stated amounts visible and let the ERP apply its configured tax and freight rules. |
Use a schema for the extracted record and a stricter one for the proposed draft. The first can represent missing or uncertain fields explicitly. The second can require the fields needed for review and enforce their types. JSON Schema supports field definitions through properties, and required controls which fields must be present. Add business checks against ERP data to tell whether a valid string identifies the right account or a valid price reflects the agreement. JSON Schema object reference
Match the customer, item, and price in that order
Resolve the selling entity and the sold-to account before looking up the buyer’s item code or price. A procurement mailbox can serve multiple subsidiaries. Use an approved customer reference or a combination of matching account and billing details. If several accounts fit, show the candidates and the evidence. Once the account is known, look up customer item codes within that account. Description matches can help a reviewer find a product, but require a confirmed mapping before using one to populate the SKU.
Normalize the unit before comparing the proposed selling price. In an illustrative example, the PO lists a quantity in cases while the ERP sells in eaches. If a maintained conversion exists, convert both the quantity and price, then compare the extended line amount using the ERP’s rounding rules. If the conversion is missing, the clerk needs the packaging record or a confirmation from the buyer. If the conversion is sound and the price still differs, route the line to the pricing owner with the PO amount, ERP price, and agreement reference. Preserve the customer’s stated amount when a reviewer changes the draft.
Route exceptions with enough evidence to resolve them
Confidence can help decide where the reviewer should look first. A low-confidence digit in a part number calls for checking the source image. A clearly extracted code with no account-specific mapping calls for a master-data decision. A known item at a conflicting price calls for a commercial decision. Give each queue entry a reason, an owner, and the expected resolution. Keep the order pending when a line is unreadable or a required check is unresolved. AI Document & Order Processing
Show the email and PO beside the proposed order. For the flagged field, display what the customer wrote, the suggested value, the rule or master record behind it, and the latest reviewer edit. Make it possible to return the case to order entry or hold it pending customer clarification. Record who resolved each exception and why. Require a person with order approval rights to approve the exact draft version before the ERP posts it. If the ship-to, quantity, price, or source revision changes after approval, send the updated version back for review.
Make repeated delivery safe and route revised POs explicitly
Use a durable unique key on the mailbox identity and provider message ID so a retried notification resumes the same intake record. When one message carries multiple distinct POs, give each proposed order its own stable document reference under that intake record. Carry a unique external draft reference into the ERP if the integration supports it. If a draft write times out, look up the existing ERP record before retrying. Hold the case for reconciliation if the write outcome is unknown and the integration cannot safely look it up or replay it. How to Prevent ERP Double Posting When a Request Retries
A forwarded copy or revised PO can arrive under a new message ID. Check the selling entity, customer account, PO reference, and any stated revision against both drafts and posted orders. If a revision arrives before approval, show the differences and have the reviewer confirm which version governs. If it arrives after posting, send it to the order amendment process. Keep a possible duplicate visible until the reviewer decides whether it is a resend, a change, or a separate order. The same distinction between transport identity and business identity matters in accounts payable. Duplicate Supplier Invoice Detection in ERP
Before connecting the posting action, replay past orders through the draft and review steps. Include a repeat email, a revised attachment, a valid code for the wrong account, a case-to-each price comparison, and a PO with a missing page. Compare the proposed account, lines, and amounts with what order entry ultimately accepted. Check which errors the workflow surfaced and which the reviewer had to find without a flag.
Sources
- Third-party documentation on authorized mailbox access and the distinction between messages and threads. Google Gmail API overview
- Third-party API reference for immutable message IDs, thread IDs, and parsed MIME parts. Google Gmail API messages resource
- Third-party documentation on object properties, types, and required fields. JSON Schema reference · Object reference
Request an audit of your order inbox
Bring a customer PO with its corresponding sales order and one example your team had to put on hold. Insonl can map the fields, checks, and approval steps for that workflow. The audit is free. Insonl charges for follow-on work you choose to commission. Request a free AI workflow audit