AI agent 07 · Shopify webhooks · approval queue

Ops Automation Agent

New orders and stock changes arrive as webhooks. Code adds the tags anyone would add. The agent reads customer notes and low-stock signals and decides what the team needs. A policy in code decides what runs on its own (tags, team alerts) and what waits for a person (holding an order, emailing a customer, reordering stock).

v1 · 11 tests10-event scenario runs end to endlive-model run not done yetWebhooks · HMACSQLite auditClaude API

Replay the events

The real engine, policy checks and approval queue from the repo, running on the sample store in your browser. The model is replaced by keyword rules (demo mode), so you can see exactly what the policy lets through. Send events one by one, then approve or reject what lands in the queue.

● ops agent · demo driver · sample store

Approval queue

Team alerts

The policy (enforced in code)

TierActionsWhy
Runs automaticallyadd_order_tags (allow-list of 11 tags, ≤ 4 per order), post_team_alert (≤ 20 per hour)Reversible, internal
Needs a personhold_fulfillment, draft_customer_email, draft_reorderDelays a customer, talks to a customer, or spends money
Not a tool at allrefund, cancel, edit address, change price, create discountThe agent cannot even ask

Every call also has to be about this event's order or variant: the agent handling order #1104 cannot tag, hold or email about any other order.

What happens to one webhook

VerifyHMAC over the raw body; answer 200 at once
DedupeSame X-Shopify-Event-Id → ignored
Ruleshigh-value · international · first-order · wholesale
Agent (only if needed)A customer note or a low-stock signal
PolicyTier, allow-list, scope, rate limit
ApprovalRuns once when a person approves
Code decidesAI helpsA person decides

Design choices

Results

WhatResult
Tests: dedupe, no AI call without a note, approvals queued, unknown tools / tags / other orders rejected, alert rate limit, injection note, approve-once, reorder only when selling, append-only audit, webhook HMAC, no PII from payloads11 / 11 pass
Server smoke test: signed webhook, duplicate delivery, bad signature (401), approve, approve again (409)As expected
Same scenario with Claude making the decisionsNot run yet
Connected to a real storeNot yet (Admin mutations validated against 2026-10)

What AI wrote vs what I decided

AI (Claude Code)

Drafted the engine, drivers, SQLite store, server, simulator and tests; validated the Admin operations with the Shopify AI Toolkit.

Me

Decided the three tiers, the tag allow-list, "rules first, AI only on notes", event scoping, dedupe on Event-Id and the reorder rule.