Execute conditional logic using the Condition and Merge nodes.

If you want to execute different parts of your pipeline based on some condition that is determined as the Pipeline runs, you can use the Condition and Merge nodes in the Logic tab.

Condition Nodes

Condition nodes allow you to specify a series of conditions and execute different parts of the pipeline with different outputs based on the value of the conditions.

Conditions must evaluate to either True or False.

The conditions use the same syntax as Python's conditions:

  • Variables: Any word (other than certain keywords) that is not surrounded in quotes ("", '') will be interpreted as a variable. Variables will appear as handles on the left side of the node and take the outputs of other nodes as input.

  • Strings: Any word surrounded in quotes ("", '') will be interpreted as a string.

  • Conditional Operators:

    • == equal to

    • > greater than

    • >= greater than or equal to

    • < less than

    • <= less than or equal to

    • != not equal to

    • and checks if both conditions are True

    • or checks if at least one condition is True

    • not negates a condition

Example Usage

For example, let's say I have this simple Pipeline:

In the example, the Condition node evaluates a variable we call greeting.

We pass the result of an Input node—a user input that we label greeting. The Condition node will return a different result based on what the user inputs:

  • If the user inputs "Hello there!", the condition will execute whatever is connected to the top node on the left, and the node will output "General Kenobi!".

  • If the user inputs anything else, the condition will execute whatever is connected to the bottom node on the left, and the node will output a ghost emoji: "👻".

If a condition is not met, any nodes downstream of the unmet condition will not be executed.

Merge Node

If you need to execute a common set of logic after using a Condition node, you can use a Merge node to recombine the previous paths.

Building on our previous example:

In this case, we take the outputs of the Condition node and pass them to Merge node, which will automatically select the path that was successful.

The output of this final Pipeline would be grievous if greeting == "Hello there!" and incorrect otherwise:

The Merge node's default function here selects the first path it receives that evaluates to True, meaning that if you were to pass multiple conditional nodes with multiple True outputs to one Merge node, it would only return a single output.

Split Text

Split Text nodes allow you to take input text and separate it into a list of texts. The input text is split according to a delimiter, which can be selected directly on the node. The Split Text node will find every instance of the delimiter in the original text and return a list of texts separated by those delimiters, not including the delimiter itself. The three options for delimiters are newline, space, and character(s) (which allows the user to enter a custom character or string).

Last updated