Workflow automation · eSIM.net

Stock that restocks itself

An AI bot reads low-stock alerts every 15 minutes and provisions new eSIM lines — with nobody pressing a button.

limit = 10 New lines ready
The problem

Running out of SIM stock means lost sales

Every order claims a ready-made eSIM from stock. When stock hits zero, customers cannot buy. Restocking by hand meant someone watching email, then opening a carrier console to create each line.

Alerts get missed

A low-stock email can sit unread overnight or at weekends.

Manual work is slow

A person types ICCIDs and tariff details into a supplier portal, line by line.

The fix: automate it

Let a bot notice the alert and run the same safe provisioning steps, every 15 minutes.

Automated stock provisioning2 / 8
Step 1 · The foundation

First, the platform was made safe to automate

Four ways in — one body of code. Whoever starts the work, the same rules, checks and logging apply.

Customer browser / appPayment webhooksScheduler (30 jobs)AI assistant / bot One application · IIS + VB.NET Pages · WebHooks · WebJobs MCP/ — AI tool endpoints Shared business logic Provider clients · 1 per carrier Azure SQL · orders, stock, queueCarrier APIs · 11 carriersAPI gateway · one exitKey Vault · every secret The AI path is deliberately not a side door — it passes through the same checks as a customer click.
Automated stock provisioning3 / 8
Step 2 · The automated process

From a sale to a new line — end to end

The whole loop runs on its own. Each stage is one small, recoverable step.

1
Customer buysAn eSIM is claimed from stock
›
2
Stock < 10Low-stock limit is crossed
›
3
RED alertAutomatic email + image sent
›
4
Bot scansOpenAI batch job, every 15 min
›
5
Skill runsprovision stock save
›
6
MCP toolprovisionnewline
›
7
Stock refilledNew lines ready to sell

Trigger

Steps 1–3 happen by themselves when a customer's purchase drops stock below the limit.

AI decides

Steps 4–5: the bot finds the alert, understands which product is low, and runs the skill.

System acts

Steps 6–7: audited tools create the lines through the same code a person would use.

Automated stock provisioning4 / 8
Step 3 · The trigger

A simple rule: stock below 10 raises a RED alert

Stock level after each sale

Low-stock limit = 10 1514121197 each bar = stock after one more customer purchase
● RED ALERT · LOW STOCK

To: stock-alerts@esim.net

eSIM plan — only 9 left

Threshold: 10 · Status: Below limit
Action needed: provision new lines

Example alert for illustration. The email and its image are what the bot looks for next.

Automated stock provisioning5 / 8
Step 4 · The AI bot

Every 15 minutes the bot checks for RED alerts

15 minutes

1 · Scan

A background batch job in OpenAI reads the alert inbox and the alert images.

2 · Spot RED alerts

It picks out only the RED low-stock alerts and which product each one is for.

3 · Run the skill

For each one it runs provision stock save. Nothing to find? It simply waits for the next cycle.

Automated stock provisioning6 / 8
Step 5 · Skill and tools

The skill tells the AI what to do. MCP tools do it.

OpenAI skill: provision stock save

A saved set of instructions: read the alert, confirm the product and quantity, then call the right tool. The same steps run every time.

›

MCP tool: provisionnewline

One of 67 business tools on the MCP server. It writes the same work-queue row a person's action would, so every call is logged and audited.

›

Event Processor

The worker picks up the queue every 30 minutes, asks the carrier for new SIMs and tariffs, and records the result.

Why it is safe: a new tool is a database row, not a code release, and the AI has no shortcut around business rules. It can only use the tools it has been given.

Automated stock provisioning7 / 8
Tools & safeguards

The AI tools used, and the guards around them

OpenAI

Batch scan of alerts, plus the provision skill.

MCP tool server

67 live tools for orders, stock, queue, payments.

Claude Code

Writes code changes and opens pull requests.

Codex

Reviews every pull request before it can merge.

What stops mistakes

● Single-run switch — two runs never overlap

● SIM claimed first — a retry never double-allocates

● Unsure? Alarm. — it never guesses, it emails support

● Retry, then escalate — timeouts cost a retry, not a failure

● Full audit log — every tool call is traceable

Automated stock provisioning8 / 8
1 / 8