Often, you will want to execute a step only if a certain condition is met. For example, you may want to send an email to a customer only if they have a valid email address.
You can use conditional steps in your workflow to achieve this.
There are two types of conditional steps: If/else
and Switch
.
The If/else
step allows you to execute a step or a group of steps only if a condition is met. If the condition is not met, you can execute another step or group of steps.
In the example above, we are using a regular expression to check if the email address is valid. If it is, the steps in the Then
branch will be executed. If it is not, the steps in the Else
branch will be executed.
The Switch
step similarly allows you to execute a step or a group of steps only if a condition is met. However, the Switch
step allows you to specify many conditions, and execute different steps for each condition.
Only the steps for the first condition that is met will be executed. If none of the conditions are met, no steps will be executed.
You can also specify a default branch, which will be executed if none of the conditions are met, by adding a condition with the value true
as the last branch.