Concatenated Actions

This guide assumes familiarity with:

In this guide, you'll learn:

  • Control Flow using Equal Comparison node
  • Concatenated Actions

Consider the voice command you've seen in an earlier guide:

"Set the brightness of bulb to {value}"

The simplest action flow for this voice intent will be:

Simple action flow

But this action flow only works if the bulb is already on. What happens if the bulb is currently turned off and the user gives the command to Bixby?

In this scenario, an intelligent action from Bixby would be:

  • Turn on the bulb.
  • Set the brightness to the user's desired value.

This guide will help to incorporate this behavior into the device.

Control Flow Using Equal Comparison Node

To start, you'll need to fetch the device's power status. You can do that by adding the Attribute node and configuring it appropriately. The Attribute node will get the power status of the device. Next, you need to create logic to check the power status, and turn it on if it is off. You'll need a node that triggers a different execution path based on a condition.

For this scenario, you can use the Equal Comparison node as shown below.

Action Flow With Equal Comparison Node

This node takes the value of the Attribute node and uses the selected operator to compare it with a Constant node. For this example, the equalTo operation will compare the power status with the value "ON". When the node is triggered by the Start node, it will collect and compare the value from the Attribute and Constant nodes. If both the values are same (in the example, the device is already on), it will trigger the Command node that is connected to the actual trigger port. Otherwise, it will not trigger any node: no node is attached to the false trigger port yet.

Action Flow With Equal Comparison Node

Concatenated Actions

Now, you must define the action flow if the bulb is off. In this case, first send the Command to turn on the bulb, then send a second Command to set the desired brightness. These concatenated actions demonstrate the flexibility the action flows in the editor can incorporate.

To achieve this, first add a Command node. Next, configure it to send the command to turn on the bulb. Afterwards, connect this node with the Equal Comparison node's false trigger port through an execution path. On a successful command to turn on the bulb, the Set Brightness Command node is triggered:

Action Flow With Concatenated Actions

Test With Try It

When the device is already on, when you click the Try It button, the execution path (denoted by the dashed green line) is as expected. As the device is already in the ON state, it sends only the command to set the brightness.

Execution Path When Device Starts On

If the device is off and you click Try It, observe that two commands are sent: the first to turn on the device and the second to set its brightness.

Execution Path When Device Starts Off