The branch function allows you to execute discrete branches of logic within your workflows using our powerful conditions builder to specify the criteria for when a branch should execute.
You can think about the branch function in Knock as an
if/else step, with the ability to add multiple
else if clauses. Each branch has access to the full workflow run scope to evaluate conditions. Knock will execute the first branch whose conditions evaluate to
Each non-default branch must have at least one condition for the branch function to be valid. Conditions are added through the conditions builder, which allows you to compose conditions via
or boolean operators. You can build conditions for branches that contain any of the types called out in the conditions documentation, including access to any messages previously generated within the workflow run.
For each branch step, a default branch must always exist, although the default branch does not need to contain any steps. When none of the preceding branches evaluate to
true, the default branch is executed.
Each branch in a branch function can optionally terminate the workflow. This can be useful to ensure that for certain cases you don't want the workflow to continue executing.
You can toggle the ability to terminate the branch by checking the "Exit the workflow at the end of the branch" under the conditions section.
Branches within your branch function can be:
- Renamed for clarity to give a visual indicator of when the branch executes
- Re-ordered to change the execution order
- Deleted, removing all steps inside of the branch
You can debug branch execution in the workflow debugger. During a workflow run for a workflow with branches, we'll highlight the specific branch paths that were executed to help you debug. We'll also highlight the conditions that led to why a particular branch was executed.
Yes, absolutely. You can nest delays, throttles, batches, and other branch steps inside of branches as well.
The maximum depth for branches is set at 5. If you have needs that go beyond this, please reach out to discuss.
The maximum number is currently 10 branches, including the default, per-branch function.
No, you cannot have step conditions on the branch step.