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 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 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."

Prompt 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 a two-line template, for two separate dialog prompts. The first line is: "That volume may be a bit loud. Do you still want to turn it up?" The second line is: "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.
  6. Add a Response node and configure it with another two-line template: "I won't change it." and "I won't change the volume." Bixby chooses one of the two dialog options as a user response.
  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:
    • Connect the Start node's main port to the Between Comparison node's trigger port.
    • Connect the Between Comparison node's true port to the Numerical Comparison node's trigger port, and its false port to the Command node's trigger port.
    • Connect the Numerical Comparison node's true port to the Ask Confirmation node's trigger port, and its false port to the Command node's trigger port.
    • Connect the Ask Confirmation node's yes port to the Command node's trigger port, and its no port to the Response node.
    • Connect the Command node's Success port to the Response: Success node, and its Failure port to the Response: Execution Failed node.
    • Connect the Numerical Comparison node's leftValue port to the Constant node that has a value of 90, and its rightValue port to the Attribute node.
    • Connect the Constant node that has a value of 90 to the Command node's dynamic input port and to the Between Comparison node's input port.
    • Connect the Between Comparison node's minValue port to the Constant node with the value of 80, and its maxValue port 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.

Test 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?"

If the user clicks NO, Bixby doesn't change the volume and tells the user "I won't change it.":

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."

Prompt 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".
  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 a two-line template for 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.
  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:
    • Connect the Start node's main port to the Equal Comparison node's trigger port.
    • Connect the Equal Comparison node's leftValue port to the switch Attribute node's value port, and its rightValue port to the Constant node.
    • Connect the Equal Comparison node's true port to the Ask Selection node's trigger port, and its false port to the Response: Execution Failed node.
    • Connect the Ask Selection node's choices port to the second Constant node's value port, and the Ask Selection node's main port to the Command node's trigger port.
    • Connect the Command node's dynamic input port to the Ask Selection node's value port, its success port to the Response: Success node, and its failure port 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.

Test 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".

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.