> For the complete documentation index, see [llms.txt](https://docs.riff.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.riff.ai/playbooks/operations/alert-on-stock-thresholds.md).

# Alert on stock thresholds

**Best fit:** Agent **ERP systems:** Infor LN / M3, SAP S/4HANA, Oracle ERP Cloud, Microsoft Dynamics 365 **Time to build:** \~25 minutes

***

## What you're building

A Riff agent that monitors your inventory on a schedule, compares current stock levels against your reorder points, and takes action when levels fall below threshold — alerting a planner, creating a purchase requisition in your ERP, or both.

***

## What you need

* Riff workspace with your ERP connected
* Read access to inventory / stock levels and item master data (reorder points, safety stock)
* Write access to create purchase requisitions (if you want automated replenishment)
* Routing rules: who to alert for which item category or warehouse location

***

## Step 1: Define your threshold logic

| Rule               | Example                                                               |
| ------------------ | --------------------------------------------------------------------- |
| Reorder point      | When on-hand + on-order falls below safety stock level in item master |
| Critical threshold | When on-hand falls below 3 days of average consumption                |
| Overstock alert    | When on-hand exceeds 60 days of average consumption                   |
| Slow-mover alert   | When an item hasn't moved in 90 days and stock is above zero          |

Use your ERP's existing reorder points and safety stock settings as the starting point — brief the agent to read them directly rather than duplicating them in Riff.

***

## Step 2: Create the agent

1. Click **+ New** → **Agent**
2. Name it — e.g. "Stock Level Monitor"
3. In the **Profile** tab:

> You monitor inventory levels in \[ERP] twice daily (07:00 and 14:00). For each item, you compare on-hand stock plus confirmed inbound against the reorder point in the item master. If the combined total falls below the reorder point, you create a draft purchase requisition for the standard order quantity and alert the planner responsible for that category. If the on-hand stock falls below 3 days of average consumption, you mark it as critical and alert the planner immediately regardless of schedule. You do not raise actual purchase orders — PRs require planner sign-off.

Note: the last line is important. The agent drafts PRs and alerts planners, but doesn't place orders autonomously. Adjust based on your organisation's automation policy.

***

## Step 3: Connect your ERP

Stock level access by ERP:

| ERP              | Access path                                              |
| ---------------- | -------------------------------------------------------- |
| SAP S/4HANA      | Materials Management → Inventory Management (MMBE, MB52) |
| Infor LN         | Inventory → Item master, on-hand balance queries         |
| Oracle ERP Cloud | Inventory Management → On-hand balances and availability |
| Dynamics 365     | Inventory Management → On-hand inventory list            |

Connect via the **Integrations** tab and test that the agent can read stock levels for a sample of items.

***

## Step 4: Configure the trigger

* **Schedule trigger**: twice daily at 07:00 and 14:00 (or more frequent for critical categories)
* **Event trigger**: if your ERP can fire a webhook on goods issue, add that as a trigger so the agent runs immediately when a large consumption event occurs

***

## Step 5: Test

1. In the **Chat** tab: `Show me the items currently below their reorder point`
2. Compare the list against your ERP's own MRP or reorder report
3. `Draft a purchase requisition for item [X]` — review the output
4. If everything looks right, enable the trigger

***

## What good looks like

* Planners get alerts before stock runs out, not after
* Draft PRs are created automatically — planners review and approve rather than creating from scratch
* Critical alerts arrive immediately, not on the next scheduled run
* The agent's Activity log shows every check and every PR created — full audit trail

***

## Variations

**If you want fully automated replenishment (no planner sign-off):** Change the brief to create confirmed PRs or even POs directly. Only do this for low-value, high-velocity items where the replenishment is genuinely routine.

**If you have multiple warehouses:** Brief the agent with warehouse-specific reorder points and route alerts to the warehouse manager, not just the central planner.

**If you want to factor in supplier lead times:** The agent can read confirmed supplier lead times from your ERP and factor them into the "when to order" calculation — so it alerts earlier for items with long lead times.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.riff.ai/playbooks/operations/alert-on-stock-thresholds.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
