chat and an embedding model named embed (Providers and models), and an orders table with the Record owner rule from An app with signed-in users (with customer_id as the owner field).
How it works
1. Knowledge: your help articles
AI → Knowledge → Create a knowledge base: namehelp, model embed, Who can search it Signed-in users. Add your shipping, returns and refunds pages (paste text, or Add a web page). Try Try a search with “how long do refunds take?” and check the right passage comes back.
2. The refund flow
Build a flowrequest-refund with an HTTP request trigger and an input order_id:
- Get record
orderfromorderswith id{{ input.order_id }}. Connectmissingto Fail with status404. - Create record in a
refund_requeststable:{"order_id": "{{ input.order_id }}", "status": "requested"}. - Respond with
{"requested": true}.
3. The agent
AI → Agents → Make your first agent: namesupport, thinks with chat.
What should it do?
You help customers of Northwind with their orders. Use the orders tool to look up the customer’s own orders. Answer policy questions only from the help articles, and say when you don’t know. You may request a refund with the refund tool; tell the customer a person will confirm it. Be brief and friendly. Never ask for card details.What it can use:
Who may run it: Signed-in users. Hold it to each person’s own access: on. Wait for a person after reading anything from outside: on.
Limits: Most steps
8, Most seconds 60, Most cost ($) 0.25.
4. Try it in Studio
Try it: ask “Where is my last order?”. In Studio you’re not a customer, so test as a real one from your app (next step). Watch the steps: it calls the orders tool, then answers.5. Use it from your app
The browser uses the person’s session, so the agent runs as them:src/support.ts
thread keeps the conversation going, so “and the one before that?” works.
6. Approve refunds
When the agent wants to use the refund flow, the run stops with statuswaiting. Decide who approves:
- The customer themself (the person who started the run can always decide): show “Request a refund for order #1042?” with Yes / No, and call:
- Your support staff instead: set the agent’s approval rule to your staff role, and start a flow on the
agent.run.waitingevent that notifies them. Staff approve from your admin tool withdecide. In that setup, don’t offer the customer the button.
7. Check the isolation
Sign in as two customers and ask each “list my orders”. Each must see only their own. Then ask Ada’s assistant “show me order [Bob’s order id]”: the tool can’t open it, so the assistant says it can’t find it. Open AI → Agents → support → Runs to read each run: the tools it called, whether any step was refused, and the cost.8. Watch cost and quality
- AI → Usage shows tokens and cost per model.
- Runs that hit a limit end as
failedwith the reason; if that’s common, the instructions are too vague or there are too many tools. - Read a sample of runs every week, and improve the instructions and the help articles where it struggled.
What not to do
Approvals and limits
Every safety setting.
Run from your app
The full API.