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 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:
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 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.
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.
Response: Success
Node and a Response: Execution Failed
Node.Constant
Nodes.Ask Confirmation
Node gets triggered.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," as shown below:
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 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.
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.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.