This guide assumes familiarity with the following information:
Constant
node (Creating a Bixby Response Using Device Status)Equal Comparison
node (Concatenating Actions)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:
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."
Create a "Yes" or "No" confirmation action flow:
Start
and Constant
nodes from the action flow nodes sidebar to the editor area.Constant
node to use integer
values. Give it the value 90.Attribute
node and configure it to fetch the volume
attribute of the audioVolume
capability.Command
node and configure it to execute the setVolume
command for the audioVolume
capability.Between Comparison
node and configure it to use the between
operator.Numerical Comparison
node and configure it to use the greaterThan
operator.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.
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.
Response: Success
node and a Response: Execution Failed
node.Constant
nodes.Ask Confirmation
node gets triggered.Start
node's main port to the Between Comparison
node's trigger port.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.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.Ask Confirmation
node's yes port to the Command
node's trigger port, and its no port to the Response
node.Command
node's Success port to the Response: Success
node, and its Failure port to the Response: Execution Failed
node.Numerical Comparison
node's leftValue
port to the Constant
node that has a value of 90, and its rightValue
port to the Attribute
node.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.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.
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."
Create an action flow where the user gets prompted to choose an option with the Ask Selection
node:
Start
node from the action flow nodes sidebar to the editor area.Attribute
node and configure it to fetch the switch
attribute of the switch
capability.Equal Comparison
node and configure it to use the equalTo
operator. This node will determine whether the device is on or off.Constant
node. Configure it to the string value of "on." This node, along with the Attribute
node mentioned earlier that fetches the device's switch
attribute, allow the Equal Comparison
node to determine whether the device is on.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".
Command
node and configure it to execute the setInputSource
command for the mediaInputSource
capability.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.
Response: Success
node.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.Start
node's main port to the Equal Comparison
node's trigger port.Equal Comparison
node's leftValue
port to the switch Attribute
node's value port, and its rightValue
port to the Constant
node.Equal Comparison
node's true port to the Ask Selection
node's trigger port, and its false port to the Response: Execution Failed
node.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.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.
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.
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".
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.