Prompting Users With Ask Nodes

This guide assumes familiarity with:

In this guide, you'll learn how to get a "Yes" or "No" confirmation response from users in order to proceed to the next action, and how to get users to choose one option from a set of options. You'll also learn how to use the following:

This guide uses the examples "Set the volume of the television to 90" and "Set the fan speed of the thermostat" to create example action flows for these voice commands:

First, create the "Yes" or "No" confirmation action flow, which uses the Ask Confirmation Node, for the voice command "Set the volume of the television to 90."

Prompting Users With Ask Confirmation Node

Create a "Yes" or "No" confirmation action flow:

  1. Set up your initial action flow like in the Arithmetic Operations Using the Sum Node guide:
  2. Add a Command Node and configure it to execute the setVolume command for the audioVolume capability.
  3. Add a Between Comparison Node and configure it to use the between operator.
  4. Add a Numerical Comparison Node and configure it to use the greaterThan operator.
  5. Add an Ask Confirmation Node and configure it with the template "That volume may be a bit loud. Do you still want to turn it up? That volume may be pretty loud. Should I still turn it up?" The template includes two separate dialog prompts, "That volume may be a bit loud. Do you still want to turn it up." and "That volume may be pretty loud. Should I still turn it up?" Bixby chooses one of the two dialog options as a user prompt. Select Dialog for Ask Confirmation Node
  6. Add a Response Node and configure it with the template "I won't turn up the volume. I won't change the volume." The template includes two separate dialog prompts, "I won't turn up the volume." and "I won't change the volume." Bixby chooses one of the two dialog options as a user response. Select Dialog for Response Node
  7. Add a Response: Success Node and Response: Execution Failed Node.
  8. Add 2 Constant Nodes.
    • Configure the first one to the integer volume value of 80.
    • Configure the second one to the integer volume value of 100. If the user's input value is between these two values and is greater than the current volume value, the Ask Confirmation Node gets triggered.
  9. Connect all of the nodes with the appropriate execution and data paths, as seen below. The Start Node's main port connects to the Between Comparison Node's trigger port. The Between Comparison Node's true port connects to the Numerical Comparison Node's trigger port, and its false port connects to the Command Node's trigger port. The Numerical Comparison Node's true port connects to the Ask Confirmation Node's trigger port, and its false port connects to the Command Node's trigger port. The Ask Confirmation Node's yes port connects to the Command Node's trigger port, and its no port connects to the Response Node. The Command Node's Success port connects to the Response: Success Node, and its Failure port connects to the Response: Execution Failed Node. The Numerican Comparison Node's leftValue port connects to the Utterance Parameter, and its rightValue port connects to the Attribute Node. The Utterance Parameter Node connects to the Command Node's dynamic input port and to the Between Comparison Node's input port. The Between Comparison Node's minValue port connects to the Constant Node with the value of 80, and its maxValue port connects to the Constant Node with the value of 100.

When the user says "Set the volume of the television to %value%," this executes a POST command. For more information about sending commands, see the Sending a Device Command guide.

If the user utters a value that's between 80 and 100 and greater than the current volume, Bixby triggers the Ask Confirmation Node. The user is prompted with an utterance. For this example, Bixby can ask the user "That volume may be a bit loud. Do you still want to turn it up?" for confirmation.

The Ask Confirmation Node takes the user input (either "Yes" or "No") and performs the next actions based on that. If the user answers "Yes," Bixby tells the device to set the volume to the user's uttered value. If the user answers "No," the Response Node gets triggered, and Bixby tells the user "I won't turn up the volume." or "I won't change the volume."

If the user utters a value that isn't between 80 and 100 and greater than the current volume, Bixby tells the device to set the volume to the user's uttered value.

Testing Your Action Flow

To test the action flow, click the Try It button at the top right of the editor window.

For this example, the user's uttered volume value is 90, which is within the range of 80 and 100 and greater than the current volume value of 10. So, Bixby triggers the Ask Confirmation Node, and the confirmation prompt asks the user "That volume may be a bit loud. Do you still want to turn it up?"

Ask Confirmation Prompt Appears

If the user clicks NO, Bixby doesn't change the volume and tells the user "I won't turn up the volume," as shown below:

Bixby Doesn't Change the Volume

What if Bixby requires a specific value to be passed, but the user hasn't supplied it? In this case, you can create the option selection action flow, like in the next example, which uses the Ask Selection Node, for the voice command "Set the fan speed of the thermostat."

Prompting Users With Ask Selection Node

Create an action flow where the user gets prompted to choose an option with the Ask Selection Node:

  1. Set up your initial action flow like in the Concatenating Actions guide:
  2. Add another Attribute Node and configure it to fetch the supportedThermostatModes attribute of the thermostat capability. Also create a list of string options in the defaultValue section, which the user can choose from when prompted. For this example, use the string options "low," "medium," and "high." Create Options List
  3. Add a Command Node and configure it to execute the setThermostatMode command for the thermostatMode capability.
  4. Add an Ask Selection Node and configure it with the template "What do you want to set it to? What should I set it to?" The template includes two separate dialog prompts, "What do you want to set it to?" and "What should I set it to?" Bixby chooses one of the two dialog options as a user response. Select Dialog for Ask Selection Node
  5. Add a Response: Success Node.
  6. Add two Response: Execution Failed Nodes. One will get triggered if the Equal Comparison Node has a false value. The second one will get triggered if the Command Node unsuccessfully executes a command.
  7. Connect all of the nodes with the appropriate execution and data paths, as seen below. The Start Node's main port connects to the Equal Comparison Node's trigger port. The Equal Comparison Node's leftValue port connects to the switch Attribute Node's value port, and its rightValue port connects to the Constant Node. The Equal Comparison Node's true port connects to the Ask Selection Node's trigger port, and its false port connects to the Response: Execution Failed Node. The Ask Selection Node's choices port connects to the thermostat Attribute Node's value port, and the Ask Selection Node's main port connects to the Command Node's trigger port. The Command Node's dynamic input port connects to the Ask Selection Node's value port. The Command Node's success port connects to the Response: Success Node, and its failure port connects to the Response: Execution Failed Node.

The user says "Set the fan speed of the thermostat," which executes a POST command. For more information about sending commands, see the Sending a Device Command guide.

If the Equal Comparison Node determines that the device is off, the Response: Execution Failed Node gets triggered, and the user can no longer move forward. If the Equal Comparison Node determines that the device is on, the Ask Selection Node gets triggered. A prompt then asks the user to select one of the options provided by the supportedThermostatModes Attribute Node, which provides option input values to the Ask Selection Node.

The Ask Selection Node takes the user's selected option and triggers the Command Node, which then tells the device to set the fan speed based on the user's selected option.

Note

If you want, you can also set up an action to trigger if the device is off, as was seen in the Concatenating Actions guide.

Testing Your Action Flow

To test the action flow, click the Try It button at the top right of the editor window.

For this example, the device is on. So, Bixby triggers the Ask Selection Node, and a prompt asks the user "What do you want to set it to?" For this example, the user chooses the option "low."

Ask Confirmation Prompt Appears

Bixby successfully tells the device to set the fan speed to "low."

Bixby Successfully Sets the Device Fan Speed to Low