Flight search and selection
The assistant lists flights from your API; the user taps one; the selection returns to the model as a structured value, not free text.
Goal
“I need a flight from Tokyo to Osaka tomorrow” → search_flights → cards with Select buttons → tap → the model continues with the chosen flight.
Pieces
- Tool
search_flights:GET https://api.kletso.ai/demo/acme/flights?from={{ input.from }}&to={{ input.to }}&date={{ input.date }}, schema{ from, to, date? }withfromandtorequired (IATA codes). Description: “Default from=HND and date=tomorrow when the user does not say.” - Blocks:
card,row,column,text,badge,buttonwith anagentaction. - Prompt line: “flights → search_flights (default from HND, date tomorrow); render each flight as a card whose Select button carries an agent action
{ intent: 'select_flight', flightId }.”
The action
{ "id": "select", "kind": "agent", "value": { "intent": "select_flight", "flightId": "NH873" }, "label": "Select NH873" }
When tapped, the SDK sends an action frame; the runtime records the user’s choice as a message with value (and the label as the visible text) and starts a turn. The model receives the structured value and does not have to parse “the 8:15 one”.
Verify
- Preview or app: flights render; tap Select → user bubble “Select NH873” → the model continues (“NH873 departs 08:15, ¥14,800. Book it?”).
- Inspector:
ui.action, thenmessage.createdwithvalue.intent = select_flight.
Variations
- Add a
formfor passenger details on the next turn; the submit action returnsvaluesas structured data. - If you have a booking API, make
book_flighta confirmation tool.