Prompting Users With Ask Nodes

This guide assumes familiarity with the following information:

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 media input source of the television," to create example action flows for these voice commands:

  • The first action flow enables users to give a "Yes" or "No" confirmation response. The device used in this action flow is a virtual TV.
  • The second action flow enables users to choose one option from a set of options. The device used in this action flow is a SmartThings-enabled TV.

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, based on whether the user wakes up Bixby in hands-free or hands-on mode. Select Dialog for Ask Confirmation Node
  6. Add a Response Node and configure it with the template "I won't change it. I won't change the volume." The template includes two separate dialog prompts, "I won't change it." 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 a 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 Numerical Comparison Node's leftValue port connects to the Constant Node that has a value of 90, and its rightValue port connects to the Attribute Node. The Constant Node that has a value of 90 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 asks 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 change it." 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 Ask Confirmation 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 38. 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 change it," 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 an option selection action flow, like in the next example, which uses the Ask Selection Node with the voice command "Set the media input source of the television."

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 Constant Node and create a list of string options in the value section, which the user can choose from when prompted. For this example, use the string options "HDMI" and "USB". Create Options List
  3. Add a Command Node and configure it to execute the setInputSource command for the mediaInputSource 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, based on whether the user wakes up Bixby in hands-free or hands-on mode. 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 second Constant 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 media input source of the television," 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 second Constant 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 media input source 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 Ask Selection 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 "USB".

Ask Selection prompt with USB option selected

Bixby successfully sets the device's media input source to "USB".

Successful execution flow sets the device's media input to USB

Additional Resources

The Node Recommendation feature enables you to get recommendations for next possible nodes, and can make it easier to create a graph.

You can also make more complex graphs by using subgraphs.

For additional examples, see the "Change the Humidity of the Device" Sample Graph and the "Set the Volume of the Device to a Value" Sample Graph.