Concatenating Actions

This guide assumes familiarity with the following information:

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

  • Control the action flow using the Equal Comparison Node
  • Concatenate actions

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

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

This is the simplest action flow for this voice intent:

Simplest action flow

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.

Controlling Flow Using Equal Comparison Node

To start, you'll need to fetch the device's power status. To do this, add the 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 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.

Equal Comparison Node

Drag an Equal Comparison Node from the action flow sidebar to the editor area.

Action Flow With Equal Comparison Node

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 or not they're equal to each other.

In this example, the Equal Comparison Node compares the television's power status with the value "on."

Equal Comparison Node Compares Values

Configure the Equal Comparison Node:

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

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 is not yet attached to the false trigger port.

Action Flow With Equal Comparison Node

Concatenating Actions

Now, you must define the action flow if the television is off. In this case, after the first command is sent (and the television 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 the 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. Then, connect this new node with the original Command Node's trigger port. This ensures that a successful command to turn on the television triggers the original Command Node to set the volume.

Action Flow With Concatenated Actions

Testing 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, since the device is already in the on state, the execution path (denoted by the dashed green line) only sends the command to set the volume.

Execution Path When Device Starts On

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.

Execution Path When Device Starts Off

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.