Concepts
Conditions
Conditions are a way to control the flow of action steps (eg. notifications and tasks) during action execution.
Basic Principle
Conditions are available on various parts of Stubber to control the flow of action steps (eg. notifications and tasks)
For example using conditions
, it is possible to only execute specific tasks, depending on the conditions
set up for the action
in the template
.
Also for notifications, you can have two notifications
on an action, one for email and one for Whatsapp, and then run only one of them depending on whether the stub.data.communication_channel
is whatsapp
or email
.
Usage
Conditions
need to be specified as an array to the top level of any step (eg task
or notification
) that you want it to apply to.
An example conditions
array:
The step containing the conditions
array will only be ran if all conditions inside it evaluate to true
.
Tasks
Tasks
are a common area in Stubber for using conditions. It can be used to only run a task
if the execution of a specific previous task
executed successfully.
Here we have two tasks
, an apicall
and a savedata
. We use conditions to only save the data if the apicall
task ran successfully.
Notifications
Conditions in Stubber allow you to send notifications based on specific criteria, ensuring that only the relevant notification method is used. This makes the process flexible and responsive to the chosen communication channel.
Example:
You can set up conditions to trigger either an email or WhatsApp notification based on the communication channel selected for the action.
- stub.data.communication_channel = "email"
In this example, if the communication channel is set to "email," only the email notification will be triggered. If the condition evaluates to another channel, such as WhatsApp, the email notification will not be sent, and instead, the WhatsApp notification will be executed.
Notification Flow:
Create two notifications for an action—one for email and one for WhatsApp.
The system checks the condition:
- If stub.data.communication_channel = "email", only the email notification is sent.
- If stub.data.communication_channel = "whatsapp", only the WhatsApp notification is sent.
This ensures that notifications are aligned with the user's preferred communication method.
Inner Workings
Each condition
inside the conditions
array is evaluated with jsonata. If any of the conditions evaluate to false
, the step will be skipped.