Concatenating Actions

This guide assumes familiarity with:

In this guide, you'll learn how to:

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

Example: "Set the brightness of the bulb to 25."

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 bulb is off and the user gives the command to Bixby?

In this scenario, an intelligent action from Bixby would be to turn on the bulb and then set the brightness to the user's desired value.

This guide helps you to incorporate this type of intelligent 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 bulb 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 bulb's power status with the value "on."

Equal Comparison Node Compares Values

To 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 drop-down 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 bulb is off. In this case, after the first command is sent (and the bulb turns on), the second command is sent to set the brightness. 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:

  1. Add another Command Node.
  2. Configure the new node to send a command to turn on the bulb.
  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 bulb triggers the original Command Node to set the brightness.

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.

If the device is already on:

As the device is already in the on state, the execution path (denoted by the dashed green line) only sends the command to set the brightness.

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 brightness.

Execution Path When Device Starts Off