AI Spend Analysis Workflow: Automated Classification and Savings
AI spend analysis (spend analytics) uses machine learning to classify every invoice and purchase-order line into a category taxonomy, normalise supplier names, and build the spend cube — supplier × category × business unit × time — that procurement needs to find savings. Run as an n8n workflow it refreshes monthly instead of once a year, and an AI agent writes the opportunity summaries a category manager would otherwise spend a week producing.
Written by Max Zeshut
Founder at Agentmelt · Last updated Sep 11, 2026
The problem
Most companies have 30–60% of spend unclassified or classified as “other”. Supplier names are duplicated across systems (IBM, I.B.M., International Business Machines Corp). Spend analysis is done once a year by a consultant, is out of date by the time it is presented, and the savings it identified are never tracked.
What changes when it runs
Every month, the spend cube refreshes automatically: 95%+ of spend classified to a level-3 category, suppliers deduplicated, and a short list of opportunities — maverick spend, supplier fragmentation, price variance for the same item — with the numbers attached. Category managers start from the list, not from the extract.
Trigger, then 8 steps
Trigger
Schedule Trigger (monthly, after AP close)
Runs after accounts payable closes the month. A weekly incremental run classifies new invoices so the cube is never more than a week behind.
Extract AP and PO lines
PostgresInvoice lines and PO lines from the ERP (SAP, Oracle, NetSuite, Dynamics) and the card or expense platform: supplier, description, GL account, cost centre, amount, currency, date. Line level, not header level — headers hide the categories.
Normalise suppliers
CodeCleans legal suffixes and punctuation, then matches to a master supplier list using fuzzy matching plus tax IDs where available. Unmatched names go to a review queue; matches above the threshold are applied automatically.
Classify each line
Information ExtractorAn LLM classification step assigns each line a level-1/2/3 category from your taxonomy (UNSPSC or a custom tree) using the description, supplier, GL account and cost centre, and returns a confidence score. High-confidence lines are accepted; the rest go to review.
Learn from corrections
Google SheetsReviewers correct low-confidence lines in a sheet. Corrections become few-shot examples and supplier → category rules for the next run, so accuracy climbs month over month.
Build the spend cube
PostgresAggregates classified lines by supplier, category, business unit, cost centre and month into the table your BI tool reads (Looker, Power BI, Metabase).
Detect opportunities
CodeDeterministic checks: same item bought from several suppliers at different prices, categories with many small suppliers, spend outside contracted suppliers (maverick spend), spend without a PO, contract expiries in the next 90 days.
Write the opportunity briefs
AI AgentFor each flagged opportunity the agent drafts a half-page brief with the numbers, the suppliers involved and a suggested action (consolidate, renegotiate, enforce PO policy). Category managers edit and own the brief.
Publish and track
SlackPosts the monthly summary and briefs. Each opportunity gets an owner and a status in the sheet so realised savings can be reported against the estimate.
Data it touches
- AP invoice lines and PO lines (ERP)
- Corporate card and expense platform transactions
- Supplier master (with tax IDs where available)
- Category taxonomy (UNSPSC or custom)
- Contract register (suppliers, terms, expiry dates)
Guardrails
- Classification below the confidence threshold is reviewed by a person before it enters the cube.
- Supplier merges are logged and reversible; tax-ID matches are the only automatic merges.
- The AI agent drafts briefs; savings are only reported as realised when finance confirms them.
- Source lines are never altered — the cube is a derived table with a run id.
What spend analysis is, and why it was always out of date
Spend analysis answers three questions: what did we buy, from whom, and at what price — across every system, business unit and country. The output is the spend cube, and everything procurement does (sourcing waves, supplier consolidation, contract compliance, budget planning) starts from it. The traditional way to build one is a consulting project: extract the AP data, spend weeks classifying lines in Excel, present a deck, repeat in eighteen months.
The reason it was always stale is that classification was manual. A mid-size company generates 20,000–100,000 invoice lines a month, and a person can classify a few hundred an hour. Machine learning changed the economics: a classifier reads the description, supplier and GL account and assigns a category in milliseconds, and — this is the part that matters — it gets better every time someone corrects it. Run monthly, the cube stops being a snapshot and becomes a live dataset.
How AI classification works on spend data
Two approaches, usually combined. Rules and lookups: a supplier that only sells one thing (a law firm, an electricity utility) maps directly to a category; a GL account often narrows it to a level-1 category. These handle a large share of spend with certainty and cost nothing. Machine learning for the rest: a language model reads the line — “HP LaserJet toner 26A black” — and returns the category (Office supplies › Printer consumables › Toner) with a confidence score. Modern LLM classification with a few hundred labelled examples per category reaches 90–95% agreement with human reviewers on level-2 categories and 85–92% on level-3, and the review loop pushes those numbers up over the first three months.
Supplier normalisation is the unglamorous half. “Amazon Web Services”, “AWS EMEA SARL” and “Amazon Web Svcs” are one supplier; without normalisation the cube shows three, and supplier-fragmentation analysis is meaningless. Fuzzy matching on cleaned names gets most of the way; tax IDs and DUNS numbers, where you have them, make merges certain.
The taxonomy decision
UNSPSC is the standard four-level taxonomy (segment, family, class, commodity) with tens of thousands of codes. It is free, widely understood and what most analytics tools expect. Its weakness is that it is built for products, not for the way procurement teams think about services and IT. Most companies use UNSPSC at levels 1–2 and a custom tree beneath it for their biggest categories (IT/software, professional services, marketing, logistics). Whichever you choose, freeze it before classification starts; changing the tree halfway invalidates the corrections the model learned from.
What the cube finds, with a worked example
A 400-person services company runs the workflow on 14 months of AP data: 38,000 lines, $21M. After normalisation the supplier count drops from 2,140 to 1,610. Classification lands 96% of spend at level 2 and 91% at level 3 by the third monthly run. The opportunity step flags: software subscriptions bought by 11 cost centres from 34 vendors with six overlapping tools ($410k, consolidate); temp staffing from 9 agencies at rates varying 22% for the same role ($1.3M, renegotiate to a panel of three); 18% of spend with no PO, concentrated in two business units (policy enforcement, not a sourcing event). The agent writes the three briefs; the category manager takes them to the CFO the same week. Typical addressable savings identified by a first spend analysis are 5–12% of the analysed spend; how much is realised depends entirely on whether someone owns each opportunity, which is why the workflow tracks them.
Where the AI agent fits, and where it must not
The agent writes the briefs — the narrative around the numbers that a category manager would otherwise spend days producing. It reads the flagged opportunity, the suppliers, the spend history and the contract register and drafts what happened, what it costs and what to do. It does not classify silently (the classifier does, with confidence scores and review), and it does not declare savings realised (finance does). Those boundaries are what make the output defensible in front of a CFO.
Tools in the stack
| Tool | Role in this workflow |
|---|---|
| n8n | Extraction, normalisation, review loop, cube build |
| Claude | Line classification and opportunity briefs |
| Postgres / BigQuery | Spend cube and history |
| Looker / Power BI / Metabase | Dashboards on the cube |
| Google Sheets | Review queue and corrections |
Want this running without building it?
Automation workflow
$297/month
We set up, host and maintain this workflow on n8n and connect it to your tools. Setup included, cancel monthly, you keep the JSON.
Custom build
$6,000–12,000 one-time
Your systems, your rules, your edge cases. A one-off build on Claude and n8n, delivered with documentation and a walkthrough.
The subscription covers one ERP source and up to 50,000 lines a month with a standard UNSPSC taxonomy. Multiple ERPs, a custom taxonomy, or contract-compliance checks are a custom build.
Frequently asked questions
How accurate is AI spend classification?
With a frozen taxonomy and a review loop, 90–95% of spend at level 2 and 85–92% at level 3 in the first months, rising as corrections feed back. Lines below the confidence threshold are reviewed by a person, so the cube never contains an unreviewed low-confidence guess.
Which ERPs and data sources does it work with?
SAP, Oracle, NetSuite, Dynamics, Sage and QuickBooks for AP and PO lines; Ramp, Brex, Pleo, Expensify and bank feeds for card spend. Any source that can export line-level data with supplier, description, amount and account works.
Do we need UNSPSC?
No, but you need a fixed taxonomy. UNSPSC levels 1–2 with a custom tree for your largest categories is the common choice. We set it up with you before the first classification run.
How is this different from the spend module in Coupa or Ariba?
Those modules classify spend that flows through their own platform. The workflow classifies everything — ERP, cards, expenses, off-platform invoices — and writes to your own database, so it works alongside a P2P suite or without one.
What does AI spend analysis cost?
$297/month as a subscription for one ERP source and up to 50,000 lines a month. Multiple sources, custom taxonomies or contract-compliance checks are a one-off build from $6,000. Compare that to a one-time consulting spend analysis, which usually costs more and is stale on delivery.
Calculator
Put your own numbers in
Estimate the cost of the current process and what this workflow changes.
The pillar
AI Procurement Agent
Analyze spend, source suppliers, automate purchase orders, and manage vendors with AI.