Conditional Branch
Definition
The Conditional Branch node splits an AI Studio workflow into multiple branches based on IF, ELIF, and ELSE logic.
Prerequisites
How it works
A Conditional Branch node works as follows:
-
IF condition: Select a variable, set a condition type, and specify a value.
-
If the IF condition evaluates to
True, the workflow executes the IF path. -
If the IF condition evaluates to
False, the workflow executes the ELSE path. -
If an ELIF condition evaluates to
True, the workflow executes that ELIF path. -
If an ELIF condition evaluates to
False, the workflow evaluates the next ELIF condition or executes the final ELSE path.
Condition types
You can set the following condition types:
-
Contains
-
Not contains
-
Starts with
-
Ends with
-
Is
-
Is not
-
Is empty
-
Is not empty
Configure the node
Click the
icon after the Start node to add a Conditional Branch node.
Click the node to configure it in the Conditional Branch panel.
The panel has several sections for configuration. In the IF (CASE 1) section, define a condition by selecting a variable (for example, from the Start node), choosing a condition type, and entering a value. To add multiple conditions within this branch, click Add condition. To add more conditional branches, click + ELIF in the ELIF section. The ELSE section defines the path taken if no preceding conditions are met. Finally, use the Next Step section to select the subsequent node for each path.
Use cases
The following example shows how conditions work in a Conditional Branch node:
-
IF condition: Select the test variable from the Start node, set the condition to Contains and the value to
Technology. -
If the IF condition evaluates to
True, the workflow executes the IF path. -
If the IF condition is
False, the workflow proceeds to the firstELIFcondition. For example, assume the value of thetestvariable does not containTechnology, and anELIFcondition checks if the variable containsScience. The workflow then evaluates thisELIFcondition. If it isTrue, the workflow executes the path defined for that ELIF branch.
Multiple conditions
For complex logic, you can define multiple conditions and connect them with AND or OR operators. This creates an intersection (all conditions must be true) or a union (any condition can be true) of the conditions.
In the condition configuration area, click Add condition to add multiple conditions, one per line. For each line, select a variable, a condition type, and a value. Click the delete icon at the end of a line to remove a single condition, or click Remove to delete the entire condition group.