Build an AI Stockout Alert Before Your Next Purchase Order Is Late
By Ehab Al Dissi ·
Check stock every morning
Open the input workbook, connect it to n8n and run the sample. The schedule starts when you publish the workflow in your n8n account.
Every day at 8:00 a.m. · up to 100 input rows · exceptions go to the Review Queue tab
Set up and run the sample
- Upload the workbook to Drive, open it in Google Sheets, then choose File → Save as Google Sheets. Keep the Input and Review Queue tab names and column headers. Enter your data in the blue columns. The cream columns calculate the case key, exception, evidence and next step.
- In n8n, create a workflow and choose Import from file from its menu. Open the Spreadsheet ID node and replace the placeholder with the text between
/d/and/editin your sheet’s URL. - In both Google Sheets nodes, select a Google Sheets credential that can edit this file. Save the workflow and click Execute workflow to run it once. Check the Review Queue tab before turning on the schedule.
- Set the workflow time zone to yours. The template uses Asia/Amman. Adjust the schedule, then choose Publish in n8n when your sample matches. Keep one copy of the workflow per workbook.
For the first sample run, set Snapshot date on all four sample rows to today. The run should queue A-42 for a late receipt, C-08 for an unknown receipt date, and D-04 for a shortage. Change A-42’s receipt from five days to one to clear the exception on Input. With your own data, use one row per item and location and keep the snapshot date and days until receipt current.
Use Review status and Reviewer notes to record your decision. Repeated runs update the same case key and leave those two columns for the reviewer. A record that stops appearing as an exception remains in the queue for the reviewer to close.
Ask AI to extract the promised receipt date and quote the supporting sentence from a supplier update. The buyer confirms the date before entering it.
Check one item for a stockout
Use one item in one location. Enter the same unit throughout and use the next confirmed restock date.
Your entries stay in this tab. Use reference IDs instead of names or document contents.
What to try next
The example runs out in 2.25 days with a receipt due in five. Change the receipt to one day to see when monitoring is enough. The check assumes steady demand and calculates stock up to the next receipt.
Use AI to pull a proposed receipt date from a supplier message, with a quote and a source reference. Confirm the date and quantity with the buyer before using them in a purchase decision.

Watch the Inventory walkthrough
Read the video transcript
Your warehouse has one hundred and twenty units. You're still about to run out. Here's what the stock report missed.
Thirty units are already reserved. At forty units per day, the remaining ninety cover just over two days.
The supplier says five days. The automation flags the gap and puts a transfer or expedited shipment in front of the buyer.
If the date is missing, the workflow asks for confirmation. The buyer approves any purchase or customer promise.
Take the last item that ran out. Replay the updates in order and find the first day your team could have acted.
The warehouse has 120 units. Thirty are already promised. At 40 units a day, you have 2.25 days of available stock. If the next receipt is five days away, the buyer needs to see the gap today. A useful automation tells them what changed, which products are affected, and what decision they can make before the shortage reaches the customer.
How to build a stockout alert
Start with one warehouse and a shortlist of products whose shortages matter. Run the workflow every morning and whenever a supplier changes a committed date. Join inventory, reservations, recent demand, and open purchase orders by SKU and location. Calculate the stock projection with rules, then use AI to extract a proposed date from a supplier update or summarize the evidence for the buyer.
- Define available stock as on-hand units minus firm reservations. Exclude damaged stock and keep quantities in the same unit of measure.
- Estimate daily demand from the period your team uses to plan. Record the window and flag promotions or unusually large orders so the buyer can inspect the assumption.
- Build a dated view of inventory. Deduct expected demand, add confirmed receipts on their expected dates, and flag the first day availability falls below your safety stock. Put a buffer around uncertain supplier dates.
- Give the buyer a choice. Compare transferring stock, expediting the supplier order, or changing a customer promise. Show estimated costs, lead times, and the records behind each option.
- Let the buyer approve any purchase, transfer, or customer commitment. Keep the alert open until a changed supplier or inventory record confirms the plan.
Try the calculation on three fictional SKUs
Run python replay.py inventory --output inventory.csv. The starter uses constant daily demand and a single receipt date. Replace those assumptions with dated demand and receipts when you connect your own data.
| SKU | Available | Daily demand | Coverage | Receipt | Decision |
|---|---|---|---|---|---|
| A-42 | 90 | 40 | 2.25 days | 5 days | Buyer reviews a transfer or expedite. |
| B-19 | 140 | 20 | 7 days | 5 days | Monitor in this fixture. |
| C-08 | 20 | 10 | 2 days | Unknown | Confirm the supplier date. |
In the starter above, change A-42’s receipt from five days to one. The replay should switch the recommendation to monitoring. Then set daily demand to zero. The replay will ask the buyer to review demand before making a forecast.
Run a two-week pilot
Track time from a known risk to the buyer’s first decision. Compare alerts with actual shortages, count misses and false alarms, and record how much the team paid to expedite. Review the alerts that arrived with too little time to act. That tells you whether your next improvement belongs in the trigger, the data, or the decision process.
Ask the buyer for one SKU that ran out recently. Replay the demand and supplier updates in the order they arrived. Find the earliest date the system could have warned them with the data available at the time.
Download the Python replay · Download the example CSV