AI Frontend · Exercise 5 of 5 Previous
Advanced
Ask Before the Refund
The refund tool waits for the user's approval. Click #start to send Refund ORD-1042. When the tool part is in the state approval-requested, show a card #card with the server's reason (part.approval.requestReason) and two buttons, #approve and #deny.
Answer with addToolApprovalResponse({ id, approved }), and use sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses so the run continues. When the refund step ends, show #result: Refund done for output-available and Refund skipped for output-denied. The card must disappear after the answer.
What Check tests
- No card before the click
- The card shows the server's reason
- Denying removes the card and shows
Refund skipped - The code answers with
addToolApprovalResponse
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.