Concatenating Actions

This guide assumes familiarity with the following information:

In this guide, you'll learn how to do the following:

Example: "Set the volume of the television to 25."

The device used in this guide is a SmartThings-enabled TV.

This is the simplest action flow for this voice intent:

Action flow with a Start node's main port connected to a Command node's trigger port via execution path, and its volumeLevel port connected to the Command node's 1:volume dynamic input port via data path

However, this action flow only works if the device is already on, such as in the Sending a Device Command With an Argument guide. What happens if the television is off and the user gives the command to Bixby? An intelligent action would be to turn on the television and then set the volume to the user's desired value. This guide helps you to incorporate this type of smart behavior into your device.

Control Flow and Compare Values With Equal Comparison Node

To start, you'll need to fetch the device's power status. To do this, add an Attribute node and configure it to get the power status of the device.

Next, you need to create logic to check the power status, and then turn the television on if it is off. You need a node that triggers a specific execution path out of multiple options based on a condition. To create this logic, use an Equal Comparison node.

Diagram of equalTo node that labels input ports for leftValue and rightValue, output port for boolean value of result, and the output ports that are triggered if leftValue and rightValue are equal or unequal

This node takes the value of the Attribute node and uses the selected operator (in this example, equalTo) to compare the Attribute node value with the value of a Constant node.

The value output ports of the Attribute and Constant nodes connect to the leftValue and rightValue input ports of the Equal Comparison node, respectively. The Equal Comparison node then compares the values of the Attribute and Constant nodes to determine whether they're equal to each other. In this example, the Equal Comparison node compares the television's power status with the value "on."

Configure the Equal Comparison node:

  1. Click the node to open the Node Configuration menu.
  2. Select equalTo in the operator list.

The Equal Comparison node fetches and compares the values from the Attribute and Constant nodes. If both values are the same (in this example, the device is set to on), the Command node gets triggered. Otherwise, the Equal Comparison node doesn't trigger a node because one isn't attached yet to the false trigger port.

Action flow with Equal Comparison node

Concatenate Actions

Now, you must define the action flow if the TV is off. In this case, after the first command is sent (and the TV turns on), the second command is sent to set the volume. If the first command fails, the second command does not execute. These concatenated actions demonstrate the flexibility of action flows. To achieve this concatenated flow, do the following:

  1. Add another Command node.
  2. Configure the new node to send a command to turn on the television.
  3. Connect this new node with the Equal Comparison node's false trigger port with an execution path.
  4. Connect this new node with the original Command node's trigger port. This ensures that a successful command to turn on the device triggers the original Command node to set the volume.

Action Flow With Concatenated Actions

Test Your Action Flow

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:

If the device is already on, meaning it is in the on state, the execution path (denoted by the dashed green line) only sends the command to set the volume.

If the device is off, the action flow first executes a command to turn on the device. Then, it executes a command to set the volume.

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 an additional example, see the "Set a Cooling Setpoint With or Without Temperature Unit" Sample Graph.