Production AI agent that extracts unstructured wholesale PDF purchase orders from email streams, maps non-standard buyer descriptions to internal inventory SKUs via GPT-4o, and drafts validated sales orders directly into Cin7 ERP.
Slender Morris, an Australian wholesale textile and furnishings distributor, receives dozens of custom purchase orders daily as email PDF attachments from major enterprise retail buyers like Spotlight Australia. Operations clerks spent roughly 15 minutes per order manually deciphering non-standard buyer descriptions, cross-referencing internal product catalogs, and re-typing records into their ERP (Cin7 / DEAR Systems). This manual workflow created severe shipping dispatch bottlenecks, caused inventory allocation errors from transcription typos, and risked duplicate order creation during order adjustments. Standard regex and keyword matching failed because retail buyers routinely used varying shorthand product names and unstandardized roll units instead of official manufacturer SKUs.
We architected a serverless Python AI microservice operating as an automated bridge between Gmail, OpenAI GPT-4o, and Cin7 ERP, governed by four deterministic engineering guardrails: 1. Inbox Ingestion & Extraction: The agent monitors authorized inbox streams via the Gmail API, isolates incoming PO attachments, and extracts unstructured text layout blocks using pdfplumber. 2. Semantic SKU Translation with Context Grounding: Injected localized customer alias CSV tables into the GPT-4o prompt context. The model cross-references buyer shorthand descriptions, unit of measure (meters vs. 50-meter rolls), and extended line pricing against wholesale brackets to map items to valid internal SKUs. 3. Deterministic ERP Validation Guardrails: - Live Cin7 API Catalog Verification: Verifies active SKU existence before drafting. - Price-Tier Sanity Checks: Validates unit pricing against customer contract tiers. - Isolated Quarantining: Unmapped lines or invalid delivery addresses trigger an immediate alert to operations while allowing the remaining batch to flow. - Draft-Only Order Creation: Orders are committed strictly as Authorised Sales Quotes, preventing premature inventory locks. 4. Idempotency Execution Ledger: Integrated MongoDB Atlas to log email and order hashes, preventing duplicate draft creation during network retries.
The agent transitioned wholesale order intake from a manual transcription chore into an automated, review-only workflow: - 90%+ Cycle Time Reduction: Order processing turnaround collapsed from ~15 minutes of manual data entry to under 10 seconds per order. - High Straight-Through Accuracy: Achieved a sustained 92% to 95% straight-through processing rate, with zero manual data entry required for standard catalog orders. - Zero Downside Risk & Duplicate Orders: The MongoDB idempotency lock and Cin7 API validation rules achieved a 0.0% duplicate order rate and zero inventory misallocations across months of production. - Operational Scalability: Handled seasonal volume surges (spiking to 80-100 orders per day during national retail promotions) without requiring temporary administrative staff or weekend data entry. - Human-in-the-Loop Control: Staff transitioned to a simple 10-second visual verification step in Cin7 rather than typing lines, preserving operator authority while eliminating transcription fatigue.
- Order Turnaround Speed: Compressed cycle time by 98.8% (from 15 minutes to under 10 seconds per order). - Straight-Through Processing: Maintained 92% to 95% automated order acceptance without human intervention. - Data Entry Defect Rate: Reduced order line transcription errors to 0% through deterministic live catalog verification and price-tier checks. - Duplicate Order Prevention: 100% duplicate prevention achieved via MongoDB Atlas transaction locking. - Change Management & Trust: Following a two-week shadow mode that verified mathematical parity against clerk entries, operations fully adopted the agent, reclaiming roughly 15 to 20 hours per week of manual data entry across the team.