Skip to main content

Perform conditional logic with the Branch block

Learn how to perform conditional logic in a workflow.

Instead of writing if...else statements in JavaScript, you can use Branch blocks to visually build conditional statements that control different connected blocks. This is useful for breaking out complex JavaScript logic into more manageable blocks.

A Branch block evaluates the data it receives from a connected block using the defined condition. If the condition evaluates as a truthy value, the workflow follows the control flow for the If statement. If not, it follows the control flow for the Else statement.

Use a Branch block

For example, you could build a workflow that alerts your shipping department if the number of unshipped orders exceeds a certain threshold, such as query1.data.length > 2.

You can add multiple branches as Else if statements to visually build out complex conditional logic. As you test your workflow, the condition that evaluates as true is highlighted in green.

Each conditional statement has its own connector so you can connect different blocks and define separate control flows for each outcome.

Configure block settings

You can configure the following settings for Branch blocks.

Timeout after (ms)

The duration to wait before the block times out. Default is 10000.