01 / 12
AI Systems Engineer2025

Prompt Studio

A collaborative environment for designing, testing, and optimizing AI prompts across LLM providers.

Next.jsOpenAIAnthropicSupabase
Business Context

Private Manufacturing Company

Industry

Manufacturing / Distribution

Size

80–150 employees across operations, warehouse, and admin

A mid-market manufacturing company supplying industrial components to OEMs across the Midwest. They process 40–60 supplier invoices per week, manage 200+ SKUs across two warehouses, and operate on thin margins where procurement efficiency directly impacts profitability. The procurement team consisted of two buyers, one warehouse manager, and an operations director — all spending significant time on manual coordination instead of strategic sourcing.

Procurement was entirely manual — supplier invoices arrived by email, inventory was tracked on paper, and purchase orders required 3–5 days of back-and-forth.

Problem Discovery

Finding the Signal in the Noise

Process audit over 3 weeks: shadowed buyers, reviewed 4 weeks of procurement email threads, mapped every touchpoint from invoice arrival to PO completion.

Symptom

Invoices arriving as PDF attachments in personal email inboxes — no central repository

Symptom

Vendor verification required manual lookup in a shared spreadsheet with 400+ outdated entries

Symptom

Inventory checks meant walking to the warehouse floor and physically counting stock

Symptom

Duplicate purchases occurred 2–3 times per month because nobody had visibility into pending POs

Symptom

Approval chain stopped completely when the manager was out of office — no escalation path

Root Cause

The business grew from 20 to 100+ employees without ever redesigning its procurement process. Every department built its own workaround, and those workarounds became the de facto system.

Impact: Average procurement cycle: 5–7 days from invoice receipt to PO issue. Estimated 20+ hours per week of combined manual work across the procurement team.

Current Process

Before: The Manual Workflow

A week in procurement looked like this. Every step was manual, every transfer was an email, and nobody had a complete view of the pipeline.

1Supplier emails invoice PDF to generic purchasing inbox
2Buyer opens email, downloads PDF, saves to a shared folder
3Buyer searches spreadsheet to verify vendor exists and is approved
4Buyer walks to warehouse or calls to check inventory levels
5Buyer manually checks recent POs for potential duplicates
6Buyer drafts PO in accounting software from scratch
7Buyer emails PO draft to manager for approval
8Manager reviews, may ask for changes via email reply
9Buyer updates PO, resends for final approval
10Approved PO is emailed to supplier
11Buyer manually updates spreadsheet with PO number and status
12Accounting is notified via email for matching when goods arrive
Email (per-inbox silos)Excel (vendor list)Pen and paper (inventory)QuickBooks Desktop (PO creation)Shared drive (PDF storage)
Pain Points
  • No central system of record — information was scattered across inboxes, spreadsheets, and notebooks
  • Every invoice required walking to the warehouse for inventory checks — 15–20 minutes per invoice
  • Vendor spreadsheet had 30% outdated entries — no validation at point of entry
  • Multi-day approval delays when managers were traveling or out of office
  • Duplicate POs slipped through 2–3 times monthly, causing double orders and restocking fees
Analysis

Questions Before Building

Before writing a single workflow node, every assumption gets challenged. These are the questions that shaped the architecture.

Should approval happen before or after inventory validation?

Inventory validation first. If stock is sufficient, no purchase is needed. Approval should only be invoked when procurement is actually required — this avoids unnecessary manager overhead.

What happens when OCR confidence is below 80%?

Route to human review with highlighted low-confidence fields. The AI extracts what it can; the operator only corrects specific values rather than re-entering everything.

How should duplicate invoices be detected?

Hash-based fingerprinting: vendor + invoice number + amount + date produce a deterministic ID. In-flight matching checks pending POs, not just completed ones.

What if the vendor does not exist in the approved list?

Auto-route to procurement lead for vendor onboarding. The system pre-fills vendor details from the invoice to accelerate the process.

Can AI approve purchases directly?

Only for low-value, low-risk categories with deterministic rules (office supplies, recurring subscriptions). All other approvals require human sign-off.

When should accounting be notified?

At PO generation, not at goods receipt. This lets accounting plan cash flow in advance. A second notification fires when goods are received and matched.

Business Analysis

Understanding the System

Methodology: Value-stream mapping over 3 weeks. Every procurement step was timed, every handoff documented, and every delay root-caused. We measured cycle time, touch time, wait time, and error rate across 40 real invoices.

68% of cycle time was waiting — approvals, inventory checks, information requests

12% of cycle time was value-adding work (decisions, vendor communication)

20% was rework — fixing errors from manual data entry, correcting wrong POs

5 distinct systems touched per invoice, none integrated

Opportunities Identified
  • Eliminate inventory walk by digitizing stock levels with a simple check-in/check-out log
  • Auto-validate vendors against an approved list at point of entry — block unknown vendors
  • Generate PO drafts from invoice data instead of re-typing everything
  • Structured approval with auto-escalation after 24 hours
  • Single dashboard showing all active POs, pending approvals, and recent completions
System Architecture

How the System Is Built

A modular event-driven procurement system connecting supplier communications, document AI, inventory tracking, approval routing, and accounting synchronization through a central workflow engine.

Trigger

Email Ingestion

Monitors purchasing inbox, extracts invoice attachments, and initiates workflow

AI Service

Document AI (OCR)

Extracts vendor, amount, line items, and PO number from invoice PDFs

Data Store

Vendor Database

Approved vendor list with status, payment terms, and contact information

Data Store

Inventory Tracker

Simple stock level database for real-time availability checks

Logic

PO Generator

Auto-populates PO template from extracted invoice data and approved vendor info

Workflow

Approval Router

Routes POs to appropriate approver with escalation after 24h

Integration

Accounting Sync

Creates PO record in accounting system and matches on goods receipt

UI

Dashboard

Real-time view of all procurement activity, pending items, and cycle metrics

Workflow

Live Workflow Simulation

Watch the automated procurement system process a supplier invoice from arrival to completion — AI extracts data, business rules validate, and the system orchestrates every step.

Intelligent ProcurementReady
Playground

Procurement Operations Dashboard

Step into the operations manager role. Select a sample invoice, review the AI-extracted data, and approve or reject — all within the automated workflow.

Today's OperationsAwaiting selection

Supplier Inbox

3 pending

Select an invoice to process through the automated workflow.

Activity Log

No activity yet. Select an invoice to begin.

Edge Cases

Edge Cases & Exceptions

Supplier accounting error sends the same invoice twice within 3 days. The second invoice has a different email subject line but identical content.

Resolution

Hash-based fingerprinting detects the match against a pending PO. The duplicate is automatically rejected with a message: "This invoice appears to be a duplicate of PO-2024-0142. If this is a correction, please reference the existing PO number."

A new supplier sends an invoice before completing vendor onboarding. Their company does not appear in the vendor database.

Resolution

Invoice is routed to procurement lead with pre-filled vendor details extracted by OCR. The lead reviews, approves the vendor, and the workflow resumes automatically. Vendor onboarding time: under 5 minutes.

A supplier sends a handwritten invoice that was scanned at low resolution. OCR confidence drops to 34%.

Resolution

Invoice is flagged for manual review. The AI highlights which fields it could read (total amount) and which it could not (line items, vendor name). The operator corrects only the unreadable fields.

The inventory system shows 50 units available, but 40 are already reserved for an existing production order that has not been picked yet.

Resolution

Inventory check now queries available-to-promise (ATP) quantity, not physical stock. Reserved but unpicked stock is excluded. Workflow holds until actual ATP is sufficient.

A PO requiring manager approval sits for 36 hours because the manager is at a conference with limited email access.

Resolution

Escalation timer fires at 24 hours — sends reminder. At 36 hours, auto-escalates to department head. The system also notifies the original approver when they return: "You have 3 pending approvals that were escalated in your absence."

A supplier submits an invoice under a different legal entity name than the one in the approved vendor list (e.g., "Acme Corp" vs "Acme Manufacturing Inc.").

Resolution

Fuzzy matching on business name + tax ID catches the mismatch. Invoice is routed to procurement lead with both names displayed for comparison. Once confirmed, the alias is added to the vendor record.

Engineering

Engineering Breakdown

Event-driven architecture using n8n as the central workflow orchestrator. Each procurement step is a discrete node in a directed graph — parallelizable where possible (vendor validation + inventory check), sequential where required (approval after PO generation). AI document processing runs as a serverless function triggered by workflow events. The data layer combines Airtable (vendor database, PO records) with a lightweight SQLite inventory tracker. Accounting sync uses QuickBooks Online API via OAuth2.

Outcome

Business Impact

The manual procurement process was systematically replaced with an automated workflow. Cycle time dropped from days to minutes. The team shifted from data entry to exception handling. No new headcount was needed as the company grew.

Cycle Time

5 days → 30 min

Manual Steps

12 → 3

Duplicate POs

~0 per month

Process Visibility

Real-time dashboard

Director's Commentary

Notes from the Engineer

What I initially considered — and why I rejected it

I initially wanted to build a custom procurement platform with a React frontend, backed by a PostgreSQL database. The reasoning was: "If this is going to be their core procurement system, it deserves a proper application." I rejected this after the first week of discovery. The client did not need another application — they needed their existing tools to talk to each other. A custom platform would have meant retraining, migration, and ongoing maintenance. n8n let me connect what they already had: email, spreadsheets, QuickBooks. The lesson: build the thinnest possible integration layer, not the most impressive application.

The hardest part was not the automation — it was the data

Writing the n8n workflows took about a week. Cleaning the vendor database took three weeks. The spreadsheet had 400+ vendors, 30% of which were outdated — duplicates, renamed companies, vendors that had been inactive for years. Before you can automate a process, you have to trust the data that feeds it. We ended up building a vendor verification workflow as a prerequisite step: email each vendor, confirm their details, mark active/inactive. This was tedious, but it directly prevented the worst failure mode: the system auto-generating a PO for a defunct vendor.

The biggest trade-off: AI vs. deterministic rules

There is a temptation to use AI for everything because it looks impressive. I deliberately chose deterministic rules for vendor validation, duplicate detection, and approval routing. AI is used only where it genuinely adds value: document understanding (OCR) and fuzzy vendor matching. Why? Because procurement spend is real money. A false-positive duplicate detection means a double order. A false-negative vendor validation means ordering from an unapproved supplier. Deterministic rules are auditable, predictable, and explainable. AI is probabilistic. Use it where probabilities are acceptable (data extraction) but not where they are not (financial validation).

What I would change if rebuilding today

I would add idempotency keys from day one. We had incidents where a network timeout caused the workflow to retry, creating duplicate entries in the accounting system. The fix was straightforward — generate a unique idempotency key at the email ingestion step and check it before any side-effect operation. This should have been in the initial architecture, not added as a patch. Second, I would use a proper queue (RabbitMQ or Redis) instead of n8n's built-in execution queue for high-volume periods. On Monday mornings when suppliers send 20+ invoices simultaneously, execution order matters.

Reflection

Lessons Learned

Automation reveals data quality issues before it solves process issues

The hardest part of this project was not building the workflows — it was cleaning the vendor database. Every automation initiative should budget 2x the expected time for data preparation. If the data feeding your workflow is unreliable, the workflow itself becomes unreliable.

Deterministic rules should always run before AI

There is a temptation to use AI as a hammer for every nail. But most errors in the procurement process were not comprehension errors (AI territory) — they were validation errors (rules territory). Checking a vendor against an approved list does not require GPT-4. Running deterministic checks first catches the majority of issues cheaply and predictably.

Humans are not the problem — bad tools are

Before this project, the procurement team was blamed for being slow. After automation, the same people processed 3x more POs in less time. They were not the bottleneck — the tools forced them to be. The correct framing is not "replace humans with automation" but "give humans tools that let them do the work that matters."

Approval workflows must design for absence, not presence

The original process assumed managers were always available. The automated system assumes they are not — and escalates accordingly. Designing for the failure case (manager on leave, sick, quit) made the system resilient to reality rather than fragile to an ideal.