Blog/Web engineering
Email order entry automation: turning emailed orders into ERP orders
How to automate B2B order entry from email with LLMs: reliable mailbox intake, line extraction, validation rules as code, idempotency and GDPR.
Balázs Csorba··9 min read
- Order entry
- ERP
- Document AI
- Idempotency
- GDPR

Key takeaways
- In email order entry automation the model never writes to the ERP; it proposes a typed order that must pass the same validations a human-entered order would.
- An order is created automatically only when every line passes every rule; anything else goes to an exception queue with the failing rule named.
- Microsoft Graph counts a webhook notification as delivered only after a 2xx response within 3 seconds, so persist to a queue and answer 202 before doing any work.
- Idempotency keys on the ERP create call and a line-level fingerprint stop the duplicate sales order, the archetypal incident of order automation.
- B2B order emails still contain personal data of named employees, so legal basis, retention of the raw mailbox copy and processor agreements need decisions up front.
Email order entry automation turns purchase orders that arrive by email, as PDFs, spreadsheets or plain text in the message body, into sales orders in the ERP. A document model or LLM reads the order and proposes structured lines; deterministic code checks them against contracts, prices, stock and earlier orders; and the order is created only when every check passes. Everything else lands in front of a person.
This article covers what happens before the ERP write: listening to the mailbox reliably, extracting lines rather than documents, validation rules as code, idempotency and the audit trail, GDPR for order emails, the business case and the order desk as the real user. If quotes are your bottleneck rather than orders, see RFQ automation with LLMs, which shares the extraction layer.
What should you automate, and what stays human?
Automate intake, extraction and validation; keep the decision to create an ERP order under deterministic rules, and keep every exception with a person. The rule to hang the design on: the model never writes to the ERP. It proposes a typed order that has to pass the same validations as an order typed in by the order desk.
Orders are less forgiving than quotes. A wrong quote can be corrected before the customer accepts it; a duplicate or wrong-quantity order moves stock, triggers invoices and costs trust immediately. So automatic creation is allowed only when every line passed every rule, and partial confidence is never enough. In my experience with B2B commerce systems, creating the order is the easy part. The hard part is that the customer’s email is the only record of what they believe they ordered, which is why extraction evidence and the exception queue matter more than the model.
The pipeline from mailbox to ERP
The pipeline has one way into the ERP, through a validation gate, and one way around a failure, through a person who sends the corrected order back through the same gate. There is no bypass path for urgent orders, because the bypass is where duplicates come from.
Each stage stores its artifact: the raw message, the proposed order, the rule results, the ERP document number and the confirmation. Everything after the create call, such as the outbox, retries against the ERP API and nightly reconciliation, is system-to-system sync and should reuse the integration your shop already has for orders.
How do you listen to the mailbox reliably?
In Microsoft 365, which most Austrian and German B2B companies run, subscribe to Graph change notifications, validate each one, persist it to a queue and answer immediately. A notification counts as delivered only when your endpoint returns a 2xx within 3 seconds; otherwise Graph retries for up to 4 hours (Microsoft Learn).
// Graph change-notification endpoint (sketch): validate, persist, answer fast
app.post('/graph/notifications', async (req, res) => {
if (req.query.validationToken) // subscription handshake
return res.type('text/plain').send(String(req.query.validationToken))
for (const n of req.body.value ?? []) {
if (n.clientState !== process.env.GRAPH_CLIENT_STATE) continue // ignore forged notifications
await queue.send({ subscriptionId: n.subscriptionId, resource: n.resource })
}
res.sendStatus(202) // fetch, parse and extract later, from the queue worker
})The same page documents the failure modes that matter. If more than 10% of responses exceed 3 seconds within 10 minutes, the endpoint is marked slow and new notifications are delayed by 10 minutes. If more than 15% exceed the 10-second window, it is marked drop, notifications are dropped for 10 minutes, and dropped notifications cannot be recovered. That is why the handler does no parsing at all. At low volume, polling a dedicated IMAP folder on a timer is an acceptable alternative. Either way, the mailbox copy stops being the record of truth once the order is extracted and logged.
How do you extract order lines from an email?
Extract lines into a strict schema, keep the raw text next to every interpreted value, and do unit conversion in code. Per-line extraction is a different problem from summarizing a document: quantities like “2 Karton à 12 Stk.”, the customer’s own article numbers, delivery-date phrases and “wie letztes Mal” references to an earlier order all need to survive into fields a rule can check.
{
"orderReference": "PO-88213",
"lines": [
{
"position": "10",
"customerPartNo": "4711-22",
"supplierPartNo": null,
"description": "Rillenkugellager 6204 2RS",
"quantityRaw": "2 Karton à 12 Stk.",
"quantity": 2,
"unitRaw": "Karton à 12",
"requestedDate": "2026-10-28",
"source": { "page": 1, "bbox": [72, 310, 520, 326] }
}
],
"referencesPreviousOrder": false
}
// code, not the model, converts "2 Karton à 12" into 24 pieces (UN/ECE Rec 20 code H87)Structured outputs guarantee shape, not business validity. Azure OpenAI’s strict mode, for example, requires all fields to be required, so unknown values become nullable unions, and it does not support minimum, pattern or format (Microsoft Learn). Ranges, unit codes such as UN/ECE Recommendation 20, which Peppol’s ordering code lists also use (Peppol BIS), and date windows are therefore code. Attach the page and bounding box to every field for the review screen; Mistral OCR 4.1, at $4 per 1,000 pages as of October 2026, returns paragraph-level boxes and block confidence (Mistral). The parsing layer itself is covered in Unstructured for document parsing.
Which validation rules decide whether an order is created?
Rules that read from the system of record and run in code. There are only two outcomes per order: every line valid, then create; anything else, then the exception queue with the failing rule named. The model may propose values for some rules, but it decides none of them.
| Rule | Source of truth | LLM’s role | Deterministic check | On failure |
|---|---|---|---|---|
| Known customer | ERP, CRM | none | sender domain and contract, not only the From header | exception |
| Agreed price | pricing, ERP | reads the price on the PO | contract price exists and matches | exception |
| Article match | ERP, cross-reference | proposes candidates | exact identifier or known cross-reference only | exception |
| Quantity and unit | article master | extracts raw text | unit conversion, minimum and increment | exception |
| Availability | ERP, ATP | none | available to promise against partial delivery policy | exception or confirm partial |
| Delivery date | ERP, calendar | parses the phrase | date is feasible and in the future | exception |
| Duplicate | order log | flags “wie letztes Mal” | same customer and line fingerprint within a window | exception, never auto-create |
Write the rules against your ERP’s real fields, minimum order quantity, packaging unit, available-to-promise and scheduling agreements, and version them. The rule version goes into the audit log with every decision, so a changed rule can be traced to the orders it let through.
How do you prevent duplicate ERP orders?
Carry an idempotency key through the create call and keep a line-level fingerprint per customer. Duplicate sales orders are the archetypal incident of order automation: a webhook retried, a worker restarted, or the customer sending the same PDF again with “bitte bestätigen”.
Stripe’s API is a good reference for the key semantics: client-generated keys of up to 255 characters, the saved response of the first request returned on retry, an error if the parameters differ from the original request, and keys that can be pruned after at least 24 hours (Stripe). Derive your key from the message id and the attachment hash, never from personal data. The key catches technical retries; the fingerprint of customer plus line set within a time window catches the business duplicate, the same order sent twice.
What does GDPR require for order emails?
GDPR applies even in B2B. Recital 14 excludes data about legal persons, such as the company name and its contact details, but an order email from a named employee, with a signature and a direct phone number, is still personal data (GDPR, EUR-Lex).
- Legal basis: Article 6(1)(b), performance of the contract, covers processing the order; abuse and fraud checks rest on legitimate interests under Article 6(1)(f).
- Processors: every OCR or model provider in the path needs a processor agreement under Article 28, and the pipeline needs appropriate security under Article 32.
- Minimization: send the order document to the model, not the whole thread with signatures and history; PII redaction in LLM pipelines covers the techniques.
- Storage limitation: under Article 5(1)(e), once the order is in the ERP, the raw mailbox copy needs a defined retention period and an archive or delete step.
An order-entry assistant is not on the EU AI Act’s Annex III high-risk list; frame it as an internal productivity tool, and do not claim a compliance status you have not checked.
What is email order automation worth?
It is worth the entry minutes it removes, the month-end peaks it absorbs and the wrong orders it stops, and none of these has a published B2B benchmark. No public cost-per-email-order figure or error-rate benchmark was verified for this article, so the case is built from formulas and the order desk’s own baseline.
- Touch time: cost per line equals entry minutes times loaded wage, compared with review minutes per line times wage plus extraction cost per document. As a reference, O*NET lists a 2025 US median wage of $22.20 per hour for order clerks, about $0.37 per minute before overhead, with 78,900 employed and duties that include verifying order information and checking inventory availability (O*NET).
- Extraction cost: small by comparison, as of October 2026 Amazon Textract charges $0.0015 per page for text and $0.015 per page with tables (AWS), and Google Document AI OCR $1.50 per 1,000 pages (Google Cloud).
- Wrong orders: a credit note, a replacement shipment, freight both ways and the customer’s own downstream cost. Name these components and measure them in the pilot rather than quoting an industry figure.
- Peaks: capacity without hiring shows up as backlog age and exception overflow at month end, not as headcount saved.
Vendors such as Conexiom advertise this workflow at scale, claiming more than 1.5 billion line items a year and 40+ ERP integrations (Conexiom); treat that as market evidence that the problem is real, not as a benchmark. The decision-maker, usually a COO, head of customer service or order-to-cash lead, searches for “automate order entry from email”, and the promise to make is a lower touch rate measured on the desk’s own numbers, never headcount reduction.
When should you not automate email order entry?
Do not automate when order volume is too low to justify a queue, when contract prices are out of reach, when customers already send EDI or Peppol orders, in which case fix the channel instead of parsing PDFs, or when legal will not accept an LLM in the path of customer documents, in which case deterministic templates and OCR alone are the fallback.
The order desk is the user, the auditor and the change risk. Start with “AI drafts, humans send”, publish the touch rate, make corrections one click and treat each correction as an asset that improves matching. Where usage or per-person performance is logged, involve the works council early; AI tools and the works council covers the Austrian and German framing.
A checklist for an email order entry pilot
- Build a golden set from two to four weeks of real, anonymized mailbox history.
- Measure extraction accuracy per field, not per document.
- Review which rules fail most often and fix the data behind them.
- Send the same order twice and assert exactly one sales order.
- Run an end-to-end test through the one canonical ERP writer; I would drive it with Playwright MCP from a fixture email to the created order.
- Agree an exception-queue response time with the order desk.
- Write the retention policy for raw emails and enforce it.
- Pin the extraction model version and re-run the golden set on every change.
A fixed-scope pilot on a few weeks of real mailbox history, producing an extraction report, a working exception queue and a validated create path against an ERP test client, is a well-bounded project. If you are planning one, my B2B e-commerce work covers the ERP and catalog side it depends on.
Sources
- Microsoft Learn: Receive change notifications through webhooks (Microsoft Graph)
- Microsoft Learn: Azure OpenAI structured outputs
- Stripe API reference: Idempotent requests
- Regulation (EU) 2016/679 (GDPR), EUR-Lex
- Peppol BIS Upgrade 3: ordering profiles and code lists
- O*NET OnLine: Order Clerks (43-4151.00)
- Amazon Textract pricing
- Google Cloud: Document AI pricing
- Mistral AI: OCR 4.1 model card
- Conexiom: sales order automation (vendor)
Frequently asked questions
What is email order entry automation?
It is a pipeline that reads purchase orders arriving by email, extracts the order lines with a document model or LLM, validates them against contracts, prices, stock and duplicates, and creates the sales order in the ERP only when every rule passes. Everything else goes to a person in an exception queue.
Can an LLM create sales orders in the ERP directly?
It should not. Let the model propose a structured order and let deterministic code decide whether the order may be created, through the one integration path that also handles idempotency and audit logging. The same validations apply as for an order typed in by the order desk.
How do you prevent duplicate orders from email automation?
Use an idempotency key on the ERP create call, derived from the message and its content, and a line-level fingerprint per customer within a time window to catch the same order sent twice by different routes. Test it by sending the same email twice and asserting exactly one sales order.
Is email order processing with AI allowed under GDPR?
Yes, with care. Order emails from named employees are personal data even in B2B. Processing for the order rests on contract performance, providers need processor agreements, prompts should contain only the order content, and the raw mailbox copy needs a defined retention that you have checked against the tenant’s own retention settings.
What does email order automation save?
No published benchmark for cost per email order was verified. Compute it from your own data: entry minutes per line times loaded wage, versus review minutes per line plus extraction cost per document. The US median wage for order clerks was $22.20 per hour in 2025, about $0.37 per minute before overhead.