Read Batches -> Rank by Expiry -> Set FEFO Order -> Flag Held Stock -> Publish

Shelf-Life, Retest and First-Expiry Watchlist

This agent reads batch dates, stock by bin, and quality status every day, then lists which raw material and finished-goods batches are nearing retest or expiry. It sets out the correct first-expiry-first-out issue and dispatch order and calls out held stock that is about to expire. It reports the order; it does not plan production or reserve stock.

The Problem

Two pallets of the same grade. The older one sat behind the newer one.

A picker takes the finished-goods pallet that is easiest to reach, which happens to be the one made last week. The older batch, three months from expiry, sits at the back and keeps sliding down the queue. Meanwhile a raw material passes its retest date in a corner of the store and nobody notices until QC pulls it. The dates are all in the system, just not on anyone's morning list.

What Changes

One morning list, in first-expiry order, across raw and finished goods

Each day the agent reads manufacture, retest, and expiry dates alongside stock by bin and quality status, then builds a watchlist of what is closest to retest or expiry. It sets the first-expiry-first-out issue and dispatch order so the oldest usable batch goes first, and it flags held stock that will expire before it can be released. The team works the list; the system stays the source of truth.

Humans stay in control: the agent lists near-expiry batches and the first-expiry issue order, but your stores and QC teams decide what to issue, dispatch, or hold.

HOW THE AGENT WORKS

TRIGGERLLMAPIDECISIONACTIONWAIT
TRIGGERDaily batch scanRuns each morning to read current batch and stock data.
APIPull batch and stock dataReads manufacture, retest, and expiry dates, stock by bin, and quality status.
LLMRank by retest and expirySorts batches by how soon they hit retest or expiry across raw and finished goods.
LLMSet FEFO issue orderBuilds the first-expiry-first-out issue and dispatch order per material.
DECISIONHeld stock expiring?
LLMDraft held-stock alertWrites an alert for held stock that will expire before it can be released.
ACTIONPublish watchlistDelivers the watchlist and issue order to stores and QC.
The agent does not issue stock, book dispatches, or change quality status. Your stores and QC teams do. The agent removes the daily hunt through batch dates to find what expires next.

HOW TO BUILD IT

Three levels of depth. Pick the one that matches where you are.

For the ops person who needs to understand what's involved and brief their team.

Warehouse Batch DataBatch dates, stock by bin, quality status
The AgentWorkflow engine + LLM
Stores and QCNear-expiry watchlist and FEFO order

WHAT YOUR TEAM PROVIDES ONCE

  • Batch data export - manufacture, retest, and expiry dates per batch
  • Stock by bin - where each batch sits and how much is there
  • Quality status - which batches are released, held, or quarantined
  • Warning windows - how far ahead to warn on retest and expiry
  • Notification channel - where the daily watchlist lands for stores and QC
What happens day-to-day: each morning the agent ranks batches by how soon they reach retest or expiry, sets the first-expiry issue order, and flags held stock that will lapse. Stores works the issue order and QC sees what needs a decision before it expires.

For the IT person or technical lead who needs to scope the integration.

INQUIRY SOURCES

Warehouse or ERP batch export with manufacture, retest, and expiry dates
Stock by bin showing quantity and location per batch
Quality status per batch, released, held, or quarantined

WORKFLOW ENGINE (N8N)

Scheduled daily run
Fetch batch and stock data
Rank batches by retest and expiry
Build FEFO issue order
Route held stock expiring
Draft held-stock alerts
Publish watchlist to teams

CONNECTS TO

ERP batch management (SAP / Oracle / Microsoft Dynamics)Read: batch dates, quality status. Write: none
Warehouse management (SAP EWM / Manhattan / Blue Yonder)Read: stock by bin and quantity. Write: none
Quality system (LIMS / SAP QM)Read: release and hold status. Write: none
Notification (Slack / Microsoft Teams / Email)Read: none. Write: daily watchlist and held-stock alerts
WITHOUT PMS API

Without API access, the team drops a daily batch and stock export into a watched folder and the agent builds the watchlist from that. It stays read-only and posts to the channel, so accuracy depends on the export being fresh.

WITH PMS API

With API access to the ERP and warehouse, the agent reads live batch dates, stock, and quality status each morning and builds the watchlist without anyone exporting a thing. The list reflects yesterday's moves. Best experience.

For the person who wants to build this agent step by step. Each node below maps to an n8n workflow node.

TRIGGERNode 1
Schedule Trigger - fires the daily scan
Set a Cron node for early morning on working days.
Output: A trigger event with the run date.
APINode 2
HTTP Request - pull batch and stock
GET batches with dates, quality status, and stock by bin.
Output: A JSON array of batch records with quantities.
LLMNode 3
LLM - rank by expiry and retest
Send batches with today's date and the warning windows.
Output: Batches sorted by soonest retest or expiry with days remaining.
You build a shelf-life watchlist for stored chemical batches. Today is {today}. Warning windows are {windows} days for retest and expiry. For each batch in {batches}, compute days to the nearest retest or expiry date and sort soonest first. Respond ONLY with valid JSON. No explanation.
INPUT
{"today":"2026-08-18","windows":{"retest":30,"expiry":60},"batches":[{"batch":"RM-1001","retest_date":"2026-09-01","expiry_date":"2027-01-01"},{"batch":"FG-2002","expiry_date":"2026-09-10"}]}
OUTPUT
{"watchlist":[{"batch":"RM-1001","event":"retest","date":"2026-09-01","days":14},{"batch":"FG-2002","event":"expiry","date":"2026-09-10","days":23}]}
LLMNode 4
LLM - build FEFO order
For each material, order released batches so the earliest expiry issues first.
Output: An ordered issue list per material.
You set the first-expiry-first-out issue order for released chemical batches. Given material {material} and its released batches {batches} with expiry dates, order them so the earliest expiry issues first. Respond ONLY with valid JSON. No explanation.
INPUT
{"material":"Solvent X","batches":[{"batch":"B-01","expiry_date":"2026-12-01","qty_kg":500},{"batch":"B-02","expiry_date":"2026-10-15","qty_kg":300}]}
OUTPUT
{"material":"Solvent X","issue_order":[{"batch":"B-02","expiry_date":"2026-10-15","qty_kg":300},{"batch":"B-01","expiry_date":"2026-12-01","qty_kg":500}]}
DECISIONNode 5
IF - flag held stock expiring
Filter to held or quarantined batches inside the expiry window.
Output: The subset of held stock needing a decision.
ACTIONNode 6
Send - publish the watchlist
Format the ranked list, FEFO order, and held-stock flags and post them.
Output: A delivered watchlist message.
MVP vs Advanced — Where To Start
MVP — START HERE
  • Start with one export of batches, dates, and quality status.
  • Rank by soonest retest or expiry using a hard-coded window.
  • Post the ranked list to one channel each morning.
  • Add the FEFO issue order for one busy material.
  • Flag held stock inside the expiry window.
  • Check the list against a batch you know is close to expiry.
ADVANCED — ADD LATER
  • Pull batch, stock, and quality data live from the ERP and WMS.
  • Extend FEFO order across every material, not just one.
  • Split the list by store or zone so each team sees its own.
  • =+ Add a dispatch order so finished goods leave in first-expiry order too.
  • Track how much near-expiry stock is issued versus written off.
  • =+ Add a retest-due reminder that pings QC ahead of the date, for them to schedule.

Full Video Walkthrough Coming Soon

Watch the agent turn scattered batch dates into one first-expiry watchlist each morning.

Register to be notified

Everything on this page is free to learn.

When you're ready to build — do it yourself or bring us in.

OTHER AGENTS IN LEASING & MARKETING

Ranks what to count by value and error risk, explains each variance
Checks a material against its bin neighbours before put-away confirms
Checks gate weights against the PO before goods receipt posts

Frequently asked questions

Shelf-Life, Retest and First-Expiry Watchlist is an AI agent that daily list of batches nearing retest or expiry, in FEFO order.
Two pallets of the same grade. The older one sat behind the newer one. The Shelf-Life, Retest and First-Expiry Watchlist addresses this: daily list of batches nearing retest or expiry, in FEFO order.
No. Your team stays in control. The agent does not issue stock, book dispatches, or change quality status. Your stores and QC teams do. The agent removes the daily hunt through batch dates to find what expires next.