Order status for a signed-in customer
A customer signed in to your shop asks "Where is my order?". The bot looks up their orders, shows the order as a card, offers the next steps as buttons ("Track the parcel", "Talk to a person"), and hands the conversation to your team when they want a person.
Customer: Where is my order 104233?
Bot: It's on its way with DHL and should arrive on 4 December.
┌ Order 104233: On its way, arriving 2026-12-04 ┐
│ 1 × Linen shirt, sand, M │
│ Track the parcel ↗ │
└────────────────────────────────────────────────┘
[ Track the parcel ] [ Talk to a person ]| Feature | Guide |
|---|---|
| The customer's identity, signed by your backend and checked by askdare | Signed-in visitors |
A tool that reads identity, never an ID from the model | Tools |
| The order as a card in the chat inside your page | Tools: cards, React: tool cards |
| Next steps as buttons, from the order's status | Reply options |
| "Talk to a person", with a summary for your team | Handoff |
The code is in site/recipes/order-status/, with three made-up orders in orders.ts.
1. The tools read the identity
The model passes an order number; whose orders can be looked up is decided by identity, which askdare verified from the token your backend signed. A number that belongs to someone else is "not found", like one that doesn't exist. From tools.ts:
export const orderStatus = defineTool({
name: 'get_order_status',
description:
"Status, items and delivery date of one of the signed-in customer's orders, by its six-digit number.",
input: z.object({
orderNumber: z.string().regex(/^\d{6}$/).describe('Six-digit order number'),
}),
execute: async ({ orderNumber }, { identity }) => {
if (!identity) return NOT_SIGNED_IN;
// The verified identity decides whose orders are looked up, never the model's arguments.
const order = await orders.find(orderNumber, identity.id);
if (!order) return { error: `There is no order ${orderNumber} on this account.` };
return {
orderNumber: order.number,
status: order.status,
placedOn: order.placedOn,
items: order.items,
carrier: order.carrier?.name ?? null,
trackingUrl: order.carrier?.trackingUrl ?? null,
eta: order.eta,
};
},
// …ui and replies below
});get_my_orders, in the same file, lists the customer's latest orders for "Where is my order?" without a number. Both return only the fields the model needs: the order record's warehouseNote never leaves your server.
2. A card and the next steps
ui picks what the visitor sees of the result, and replies turns the status into buttons. Both get the result as the model received it, so a failed lookup gets no card:
ui: (order) =>
'error' in order
? undefined
: {
orderNumber: order.orderNumber,
status: order.status,
eta: order.eta,
items: order.items,
trackingUrl: order.trackingUrl,
},
replies: (order) => {
if ('error' in order) return ['Talk to a person'];
switch (order.status) {
case 'processing':
return ['Change the delivery address', 'Talk to a person'];
case 'shipped':
return ['Track the parcel', 'Talk to a person'];
case 'delivered':
return ['Return an item', 'Something is missing', 'Talk to a person'];
}
},A click on an option sends its text as the customer's message. "Talk to a person" is a message too: the model reads it and calls its handoff tool, which the instructions ask it to do.
The card is a component of yours, order-card.tsx, typed from the tool:
export function OrderCard({ data }: Chat.ToolRendererProps<typeof orderStatus>): ReactElement {
return (
<figure className="order-card">
<figcaption>
Order {data.orderNumber}: {STATUS[data.status]}
{data.eta && `, arriving ${data.eta}`}
</figcaption>
<ul>
{data.items.map((item) => (
<li key={item.name}>{item.quantity} × {item.name}</li>
))}
</ul>
{data.trackingUrl && <Chat.Link href={data.trackingUrl}>Track the parcel</Chat.Link>}
</figure>
);
}3. The bot and its handoff
From bot.ts:
export const shopBot = defineBot({
id: 'shop',
model: process.env.ASKDARE_MODEL ?? '',
instructions: ({ locale, identity }) =>
[
"You are the assistant of a clothing shop. You answer questions about the customer's orders.",
identity
? `The visitor is signed in as "${identity.name ?? identity.id}".`
: 'The visitor is not signed in: they can see their orders after signing in.',
'Use get_my_orders when they ask about an order without its number.',
'The visitor sees the order as a card and the next steps as buttons: keep your answer to a sentence or two.',
'When the visitor wants a person, or you cannot help, hand the conversation over.',
`Reply in the visitor's language; default to ${locale}.`,
].join(' '),
tools: [myOrders, orderStatus],
forms: [contact],
handoff: { form: 'handoff', content: 'summary' },
});A signed-in customer whose token carries an email skips the handoff's form: that address is where your team replies. route.ts sends each request to your help desk with webhookHandoff; Handoff to Slack shows a receiver.
4. The page signs the customer in
The card needs the chat inside your page (React). The page renders per request, signs a one-hour token for the signed-in customer, and passes it to Root. From page.tsx and shop-chat.tsx:
const identityToken = async (user: { id: string; name: string; email: string }): Promise<string> =>
new SignJWT({ name: user.name, email: user.email })
.setProtectedHeader({ alg: 'HS256' })
.setSubject(user.id)
.setAudience('shop')
.setIssuedAt()
.setExpirationTime('1h')
.sign(new TextEncoder().encode(process.env.IDENTITY_SECRET));
export const dynamic = 'force-dynamic';
export default async function HelpPage(): Promise<ReactElement> {
const user = await currentUser();
const config = getChatConfig({ bots, bot: 'shop' });
return <ShopChat config={config} identity={user ? await identityToken(user) : null} />;
}<Chat.Root config={config} identity={identity} toolRenderers={toolRenderers}>
<Chat.DefaultChat className="shop-chat" />
</Chat.Root>With the script-tag widget instead, hand the token to askdare('identify', token); the cards then need your own page in the widget's iframe (Embedding).
Make it yours
| Replace | With | Guide |
|---|---|---|
orders in orders.ts | Your order API or database, queried by the customer's ID. Or an httpTool that sends the verified ID in a header | Tools: httpTool |
currentUser() in page.tsx | Your session lookup. IDENTITY_SECRET goes to your backend and the askdare app, never to a page | Signed-in visitors |
| The tracking URL | Your carrier's tracking page. Chat.Link opens only http, https and mailto links | React: tool cards |
The options in replies | The next steps your bot can handle: each needs instructions, a tool or knowledge behind it | Reply options |
HANDOFF_WEBHOOK_URL | Your help desk's webhook, or emailHandoff | Handoff |