E-commerce order assistant workflow
Route product and order questions through approved agent tools, staged order changes, and idempotent shop actions.
Order assistants often expose many tools for product search, order status, cancellation, refunds, recommendations, and email.
Framework code usually decides which tools are safe. The database may not know whether the customer could access the order, whether cancellation was approved, or whether confirmation email was sent twice.
Synapsor binds customer/cart session values, restricts allowed commerce capabilities, stages sensitive order changes, and queues provider calls through idempotent external actions.
Example names and seed ids are developer-defined. SESSION values are set by your backend. ARG values come from the SDK/HTTP call. Handles such as wrp://..., evidence://..., and agent-run://... are returned by Synapsor and should be stored for audit/replay.
Read the value-source guideThe model stays conversational while Synapsor handles customer access, allowed actions, evidence, staged changes, and replay.
Production checks
- Customer/order ids come from trusted session context.
- Cancellation and refund actions are proposal-gated.
- Provider calls use external-action idempotency keys.
- EXPLAIN AGENT RUN shows status check, proposal, approval, and confirmation steps.
CREATE TABLE orders (
id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
customer_id TEXT NOT NULL,
status TEXT NOT NULL,
total_cents INT NOT NULL
);
CREATE TABLE carts (
id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL,
customer_id TEXT NOT NULL,
status TEXT NOT NULL
);CREATE AGENT WORKFLOW commerce.order_assistant_flow
SESSION REQUIRE tenant_id, principal, current_customer_id, current_cart_id
ALLOWED CAPABILITIES (
commerce.answer_product_question,
commerce.check_order_status,
commerce.propose_order_change,
commerce.recommend_products
)
ALLOWED EXTERNAL ACTIONS (
shopify.create_order,
shopify.cancel_order,
sendgrid.send_confirmation_email
)
EVIDENCE REQUIRED
AUTO BRANCH ON PROPOSAL
CHECKPOINT EVERY STEP
ON RISK medium REQUIRE APPROVAL ROLE 'support_lead'
TOKEN BUDGET MAX INPUT TOKENS 8000, MAX OUTPUT TOKENS 1500;run = db.agent_runs.start(
workflow="commerce.order_assistant_flow",
input={"order_id": "ORD-1001", "user_request": "Can you cancel my order?"},
)
status = run.invoke_capability(
"commerce.check_order_status",
step_key="check_order_status",
arguments={"order_id": "ORD-1001"},
response_envelope=True,
)
proposal = run.invoke_capability(
"commerce.propose_order_change",
step_key="propose_cancel_order",
mode="propose_only",
arguments={"order_id": "ORD-1001", "change": "cancel_order"},
response_envelope=True,
)