- Python
- TypeScript
- The caller makes a request — e.g. “I’d like to check the status of my order.”
- Guava invokes
on_action_requestwith a summary of the request — e.g. “the customer would like to check the status of their order.” - You classify the request and return a
SuggestedAction— e.g.SuggestedAction(key="order_status"). You can use our built-inIntentRecognizerhelper, or build your own intent classifier. ReturnNoneif no action matches the request. - Guava decides whether to execute the action — it may proceed immediately or ask the caller to confirm.
- Guava executes the action — The
on_actionhandler registered under the matching suggested action key is called.
Design note: The two-step pattern (request → execute) gives the agent a chance to confirm intent with the caller before committing to an action.
- Python
- TypeScript
signature
Interaction with on_question
A caller utterance can be both a question and an action (e.g. “Could you help me pay my bill?”). In this case Guava will invoke both callbacks in parallel and synthesize an appropriate response based on the results.- Python
- TypeScript
For example, if
on_question returns “Yes, we handle bill payment” and on_action_request returns SuggestedAction(key="bill_pay"),
Guava may immediately chain into executing the action, or it may respond “Yes — would you like to get started?” to confirm the action with the caller.Example
- Python
- TypeScript
restaurant_controller.py