This guide assumes familiarity with the following information:
Constant
and Response
nodes (Creating a Bixby Response Using Device Status)In this guide, you'll learn how to set a device to its maximum or minimum setting value if an input value is out of range, depending on whether the input value is closer to the maximum or minimum possible device value. The device used in this guide is a virtual TV. The example "Set the volume of the TV to 150" will be used to design an action flow for this voice command.
You'll also learn how to use the following:
The example "Set the volume of the TV to 150" will be used to design an action flow for this voice command.
To start creating the action flow for these examples, use the action flow in the Set the Brightness of the Device sample graph as a foundation.
To use this sample graph, do the following:
Click the Sample Graphs icon in the activity bar on the left.
Drag and drop the Set the Brightness of the Device graph into the editor.
For this example, the device is a virtual TV, and the selected voice intent is volume-setValue
.
Next, add a Variable
node.
The Variable
node stores a value that you can use later. In this example, it stores the Volume
value and lets you adjust the value based on whether the mock uttered value is higher or lower than the device's maximum volume value or its minimum volume value, respectively.
Add the Variable
node and configure it with a variable name. This example uses the variable name Volume
.
Next, add a Numerical Comparison
node.
The Numerical Comparison
node determines whether one value is greater than, less than, or equal to another value. In this section you will add a Numerical Comparison
node to the action flow and make some additional adjustments. These changes enable Bixby to determine if an uttered value isn't within the range of minimum and maximum setting values. Bixby can then determine whether this uttered value is higher than the maximum setting value or lower than the minimum setting value.
Add a Numerical Comparison
node, and configure it to use the greaterThanOrEqualTo
operator.
Connect the Numerical Comparison
node's trigger port to the Between Comparison
node's false
port its false
port to the Response: Out of Range
node, and its rightValue
port to the Constant
node containing the maximum setting value of 100
.
Delete the connection between the Between Comparison
node's false
port and the Response: Out of Range
node.
Configure the Command
node with the audioVolume
capability and the setVolume
comand.
Connect the Variable
node to the Command
node's 1:volume
input port.
Add a third Constant
node. In this example, Bixby isn't prompting a user for an input. So, this additional Constant
node allows manual input values for testing purposes.
Connect the third Constant
node to the Numerical Comparison
node's leftValue
port and the Between Comparison
node's input
port.
Next, add a Set Variable
node.
The Set Variable
node sets the value of a Variable
node. In this section you will add a Set Variable
node, which enables Bixby to set the device to the maximum setting value if an uttered value is greater than the maximum setting value.
Add a Set Variable
node and configure it by entering the name of the variable to set. In this example, the name of the variable to set is Volume
.
Connect the Set Variable
node's input port to the Constant
node containing the maximum setting value of 100
, its trigger port to the Numerical Comparison
node's true
port, and its main port to the Command
node's trigger port.
Here's the finished action path:
When the user says "Set the volume of the television to %value%," Bixby first determines whether the uttered value lies between the minimum setting value of 0
and maximum setting value of 100
. If so, the volume is set to the uttered value. If not, Bixby then determines if the uttered value is greater than or equal to the maximum setting value of 100
. If so, Bixby sets the input variable for the Command
node to 100
. But if the uttered value is lower than the minimum setting value of 0
, Bixby responds that the uttered value is out of range.
To test the action flow, click the Try It button at the top right of the editor window. The flow editor should look like this:
As shown in the action flow, the mock utterance value is 150
. Bixby determines that this value is not between the setting values of 0
and 100
and is greater than the device's maximum volume value of 100
. So, Bixby sets the device to its maximum possible volume value of 100
.
You can add a minimum threshold for device volume to the previous action flow by adding two additional Set Variable
nodes to the graph made for the maximum threshold and making a few more adjustments. This updated action flow enables Bixby to set a device's volume at the minimum or maximum possible value, even if an input value exceeds either.
To add a minimum threshold to the action flow from the previous section, do the following:
Between Comparison
node with a second Numerical Comparison
node, and configure it use the lessThanOrEqualTo
operator.Response: Out of range
node. Because this graph will include maximum and minimum setting thresholds, an out of range response is no longer necessary.Set Variable
nodes, and configure them by entering the name of the variable to set. In this example, the name of the variable to set is Volume
.Numerical Comparison
node's trigger port to the Start
node's main port, its leftValue
port to the third Constant
node, and its rightValue
port to the Constant
node containing the maximum setting value of 100
.Numerical Comparison
node's main port to the first Numerical Comparison
node's trigger port, and its false
port to the third Set Variable
node's trigger port.Constant
node containing the maximum setting value of 100
to the third Set Variable
node's input port, and delete its connections to the first Numerical Comparison
node and the first Set Variable
node.Constant
node to the first Set Variable
node's input port.Constant
node containing the minimum setting value of 0
to the first Numerical Comparison
node's rightValue
port and the second Set Variable
node's input port.Numerical Comparison
node's false
port to the second Set Variable
node's trigger port.Command
node's trigger port to the second and third Set Variable
nodes' main ports.Here's the finished action path:
When the user says "Set the volume of the television to %value%," Bixby first determines whether the uttered value is less than or equal to the maximum setting value of 100
. If not, Bixby sets the device to its maximum setting value of 100
. If so, Bixby then determines whether the uttered value is greater than or equal to the minimum setting value of 0
. If so, Bixby sets the device's volume to the uttered value. If not, Bixby sets the device's volume to the minimum setting value of 0
.
To test the action flow, click the Try It button at the top right of the editor window. The flow editor should look like this:
As shown in the action flow, the mock utterance value is -1
. Bixby determines that this value is less than or equal to the device's maximum volume value of 100
but not greater than or equal to the device's minimum value of 0
. So, Bixby sets the device to its minimum possible volume value of 0
.
The Node Recommendation feature enables you to get recommendations for next possible nodes, and can make it easier to create a graph.