LogiQuad Solutions

AI-Powered Agentic Workflow for Purchase Order Automation

October 7, 2026Engineering Team
LogiQuad Solutions - n8n LinkedIn Automation Workflow for AI Powered Content Publishing

AI Purchase Order Automation from Email to ERP Sales Order

Industry

Wholesale / B2B Apparel & Workwear Distribution (retail supply chain, order management & ERP automation)

Features
  • Email-to-order automation, eliminating manual purchase order entry.
  • Smart product matching, even when product names are written inconsistently.
  • Human-in-the-loop review before finalizing orders.
  • Self-improving matching accuracy through daily learning from staff corrections.
  • Complete order preview with customer, pricing, and line-item details before submission.
  • One-click integration with the CIN7 ERP system.
Technologies

Python, FastAPI, React, Material UI, Google Gemini AI, MongoDB Atlas (Vector Search), Docker, AWS Lambda, Microsoft Graph API, CIN7 API

Infrastructure

AWS Lambda, Amazon ECR, Amazon S3, Amazon EventBridge, Amazon CloudWatch, MongoDB Atlas, Azure Active Directory

Introduction:

Manually converting customer purchase orders into sales orders is slow, repetitive, and error-prone — especially for distributors handling apparel and workwear, where product names, sizes, and colors vary between what customers write and what’s actually in the catalog. This project replaces that manual process with an AI-driven pipeline that reads incoming PDF purchase orders from email, intelligently matches products to the correct catalog items, and prepares a ready-to-submit sales order in the company’s ERP system (CIN7) — cutting manual data entry while keeping a human reviewer in control before anything is finalized. Over time, the system also learns from staff corrections, so its product-matching accuracy keeps improving automatically.

Client Profile:

The client is an Australia-based workwear and footwear retailer specializing in safety boots, workwear, corporate clothing, and specialty footwear. They offer products from leading brands such as Steel Blue, Blundstone, Redback, FXD, and Mongrel, along with hi-vis clothing, healthcare and hospitality uniforms, and women’s workwear. Their focus is on providing durable, high-quality workwear and footwear for trades, industrial, mining, corporate, and other professional customers.

Challenges:

Before implementing the smart learning system, the QWS SalesBot suffered from a hardcoded, unscalable approach that created several operational bottlenecks:

  • Developer Bottleneck for New Customers: When a new customer emailed a PDF purchase order, the bot failed because it didn’t know their specific format. A developer had to manually update a massive 4,000+ line prompt file with specific instructions (e.g., “If Neilsens, do this...”), test it, and deploy before the bot could process that customer correctly.
  • Extreme Fragility to Format Changes: If a customer slightly changed their PDF layout—moving a field or renaming a label—the system broke. This resulted in continuous developer intervention for minor formatting shifts.
  • Unmanageable Code Growth: To handle Gemini AI’s hallucinations and extraction mistakes, developers had written over 30 hardcoded Python fix functions (e.g., manually overriding branch names or standardizing size codes). This created an unwieldy 3,300+ line processing file full of exception-handling logic.
  • No Systemic Learning (The 9997 Problem): When the bot couldn’t match a product, it fell back to a placeholder product in CIN7 (SKU: 9997). An admin had to fix this manually in CIN7, but the system never learned from the fix. The next time the customer ordered the same product, it resulted in another 9997 failure, forcing the admin to fix the same error endlessly.

Technical Solution:

The system is built as a chain of independent AWS Lambda functions, each handling one step of the pipeline:

fetch email → extract PDF → match products → build sales order → send to CIN7.

A FastAPI backend ties these together and serves a web dashboard where staff review and approve orders before they go live. Product matching uses a combination of exact SKU/code lookups and AI embeddings (turning product text into numeric vectors) stored in a vector database, so the system can find the closest matching product even from imperfect or free-text descriptions. A separate nightly “learning” job compares AI-suggested matches against what staff actually approved in CIN7 and feeds that feedback back into the matching logic to improve accuracy over time.

Technology Stack:

  • Python (backend logic, AI/PDF processing)
  • FastAPI (backend API)
  • React + Material UI (frontend dashboard)
  • Google Gemini (AI model — reads PDFs and generates text embeddings for matching)
  • MongoDB Atlas (database + vector search)
  • AWS Lambda, Docker, Amazon ECR (serverless compute)
  • Microsoft Graph API / Azure AD (secure email access)
  • CIN7 API (ERP/inventory & sales order system)

Results / Business Benefits:

By shifting from hardcoded logic to a Retrieval-Augmented Generation (RAG) and self-learning architecture, the system achieved true autonomy:

  • Zero-Code Customer Onboarding: The system now automatically detects new customers by searching MongoDB via vector similarity rather than exact keyword matches. It uses a generic fallback profile to process the order, alerting the admin to verify, and automatically builds a new extraction profile without any code changes.
  • Intelligent Product Matching: By embedding the CIN7 catalog and utilizing semantic search, the bot matches products by meaning rather than exact string matches. A query for “HIGH VISIBILITY VEST ORANGE XXL” successfully matches 3503/Orange/2XL even if the exact style code wasn’t correctly extracted from the PDF.
  • Automated Self-Learning Loop: A ReviewLearner Lambda function runs every 6 hours, comparing the orders the bot originally created against the final, admin-corrected orders in CIN7. If an admin corrected a “9997” fallback to a real product, the system records this in its match_history. The next time that item appears, the bot uses the learned product instantly.
  • Empowered Admins, Freed Developers: System administration has completely shifted from developers writing Python fixes to admins working naturally within CIN7. The bot flags low-confidence orders (e.g., [SalesBot] REVIEW NEEDED ⚠) and sends an email alert. The admin simply fixes the order in the CIN7 UI, and the system silently learns from their actions.

Conclusion

The evolution of the QWS SalesBot demonstrates the transformative power of pairing Generative AI with a robust Retrieval-Augmented Generation (RAG) and self-healing feedback loop. By replacing fragile, hardcoded heuristics with semantic search and automated learning, the system transitioned from a high-maintenance script into a resilient, autonomous agent. It not only accelerates the sales cycle by instantly processing unstructured PDF orders into structured CIN7 entries, but it also democratizes system maintenance—allowing operations staff to train the AI simply by doing their normal jobs, completely eliminating the developer bottleneck.

Share

Submit your details - We’ll call you back

At LogiQuad Solutions, we believe in providing our clients with excellent customer service.

Recent Case Studies

18 Nov 2026John Karla

AI-Powered Agentic Workflow for Purchase Order Automation

Manually converting customer purchase orders into sales orders is slow, repetitive, and error-prone — especially for distributors handling apparel and workwear, where product names, sizes, and colors vary between what customers write and what’s actually in the catalog. This project replaces that manual process with an

Find out more
13 Nov 2026John Karla

Sales Flow Automation using Monday.com and Make.com

The Sales Flow Automation solution is designed to automate and streamline the complete customer booking journey for a tour management business. The system manages the complete sales lifecycle starting from customer inquiry submission to final booking confirmation and post-tour review collection.

Find out more
28 Oct 2026John Karla

Debt Collection Management Platform

The platform is built as three coordinated applications. The client app is where creditor businesses (and their invited staff, across multiple divisions/business units) register, submit new debt cases individually or in bulk via XLSX upload, track each case's status and financials, exchange messages with the agency through a task system, and pull reports on their portfolio.

Find out more