This capsule demonstrates how to validate input and handle errors in your actions.
Because you cannot submit a capsule with the
example namespace, in order to test a sample capsule on a device, you must change the
id in the
capsule.bxb file from
example to your organization's namespace before making a private submission.
For example, if your namespace is
Before you execute your implemented actions, you can try to pre-empt potential issues by validating input.
This capsule demonstrates how to check an action's input, and also how to handle any invalid input using several methods.
To see them in action, start the conversation with the utterance "Validate input" in the Simulator. This calls the
ValidateInputs.model.bxb file. You can then observe what happens in various instances:
"101" causes a
halt response, which stops execution of the capsule and displays a message.
"42" causes a
replan response, which specifies a new intent and goal of the action with the new input.
"19" causes a
prompt response, which displays an error message to users and asks them to re-enter a valid number.
"9" causes a successful response.
Video Tutorial: Validating Input in Bixby
throws block that specifies an
error type along with an
on-catch block that specifies an effect used for handling the error.
This capsule demonstrates several error-handling effects. To see them in action, enter the example utterance in the Simulator.
drop drops an input (the integer specified below) and re-executes the plan.
"Show drop input 1 example"
halt stops execution of the plan.
"Show halt example"
replan specifies a new intent and goal in the
"Show replan example"
replan specifies a new intent with a goal of
Result and a route of
Other effects that can be used in error handling include
flag-as-off-topic. These are implemented in similar fashion. For details about their operation, see the effects documentation.
Video Tutorial: Error Handling in Bixby