Conditional logic is a powerful feature of the Tray.io workflow editor. It can be used to ask key questions whose answers will then determine what path your workflow will take.
Tray has two key conditional logic connectors:
The Boolean connector can ask simple true/false questions such as 'did the new customer opt-in to marketing?' or 'is it more than 3 months since we last contacted this person?'
The Branch connector can be used to set multiple pathways depending on multiple different outcomes being picked up from your data. For example you may receive support tickets of 3 or 4 different types and want to set paths for each one to notify the relevant people to take appropriate action.
The Boolean connectorCopy
The following example shows using Recurly (a subscription billing management tool) to find inactive accounts.
This loops through each individual account and the boolean step checks if its state is 'inactive':
The Branch connectorCopy
The branch connector is essentially a 'switch statement' generator.
So it allows you to take actions based on multiple possible conditions.
To illustrate we can look at the following payload:
If we want to extract these answers into a simple list such as:
Then we can do this using a script connector with a switch statement:
Or we could loop through the answers and use the Branch connector to replicate a switch statement.
Each time we 'push' the answer using the Data storage 'append to list' operation.
After all answers have been looped through, we can then use the Data storage 'get value' operation to retrieve the final list: