Branch function

Learn more about the branch workflow function within Knock's notification engine.

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 true.

Branching by a recipient plan type

Adding conditions to branches

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 and or 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.

The default branch

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.

Terminating branches

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.

Managing branches

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
💡
Note: the default branch cannot be deleted or re-ordered.

Debugging branches

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.

Debugging a workflow run with a branch step

Frequently asked questions