Branch

Use branch to route notifications through different workflow routes based on conditions

Branch is an if/elseif/else step used to route notification through different paths in a workflow based on conditions. Some common usecases could be to send multi-step reminder to users until payment is made and route notification on different paths based on user properties.

You can add upto 10 branches in a workflow. The First branch satisfying the condition in the order will be executed.


How branch works?

There are 2 types of branches: Condition branch, Default branch

  1. Condition branch - User proceeds through this branch when a condition is met. The condition can be applied on user properties, tenant properties and input trigger payload. You can add upto 9 condition branches. If 2 branches satisfies the condition, the first branch in the order will be executed.
  2. Default branch - This is the fallback branch which is executed if no condition branch results in truthy value.

Constructing a condition

You can add conditions on data payload passed in the trigger, user properties and brand properties. A condition is a combination of 3 parts: Data type, Key, operator and Value.

  1. Data type - data types available in the workflow. Currently, you can apply condition on data passed in your event properties or workflow trigger. We'll be adding support for other data types - actor, recipient, tenant soon.
  2. Key - It is the variable key in your data input to apply condition on.
  3. Operator - you can use any of the below operators to compare key and value:
OperatorDescription
==key is equal to value. This is a case sensitive check.
!=key is not equal to value. This is a case sensitive check.
>key is greater than value. can be applied to integers, float values or epoch timestamps
> =key is greater than or equals to value. can be applied to integers, float values or epoch timestamps
<key is less than value. can be applied to integers and float values
<=key is less than or equals to value. can be applied to integers and float values
containskey should be a substring or list item of an array.
not containskey should not be a substring or match any list item of an array.
is emptyevaluates to true if the key is missing, is an empty string or has null value.
is not emptykey should be present and should not be an empty string or null value

  1. Value - Value can be fixed or dynamic (evaluated based on workflow input payload). Dynamic values are helpful when the comparison value is dynamic for each user. For example, in case of payment reminder, the payment due date could vary for each user and is part of your trigger data. You can add condition in this case as current_date >= payment_due_date (where both timestamps are in epoch).

Fixed values

Fixed values can be added as:

  • string - enclose within double inverted commas as "string"
  • number - 1, 1.2
  • boolean - true, false

Dynamic values

You can add input payload key directly as key with no prefix. All other properties should start with their respective $ prefix. Here's a list of variables supported in workflow engine:

VariableJSONNET formatDescription
Input Payloadkeydata passed in your event or workflow trigger.
Actor$actor.keyproperties of actor in your workflow trigger. In case of event, distinct_id works both as actor and recipient.
Recipient$recipient.keyproperties of recipient in your workflow trigger. In case of event, distinct_id works both as actor and recipient, unless override recipient is set in workflow trigger settings. In case of override recipient, properties of overriden recipient is picked.
Brand / Tenant$brand.keyproperties of the tenant passed in workflow trigger.

Adding Multiple Conditions in a single branch

You can combine multiple conditions in a branch with AND, OR operator.

  • AND - all conditions separated by AND should be true for the evaluation to pass.
  • OR - Evaluation will pass if any of the conditions separated by OR is true.

If you have a condition (a or b) and c, you can construct it as (a and b) or (b and c).