Concepts
Conditions
Conditions are a way to control the availability of actions or action components (eg. notifications and tasks) during action execution.
Basic Principle
Conditions
are a way to control the availability of actions or action components (eg. notifications and tasks) during action execution. This allows for more complex and dynamic actions to be created.
For example, using the conditions
property of each task of an action, it is possible to only execute specific tasks based on each task's
conditions
. This also allows executing sequential tasks based on the result of previous tasks.
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
.
For actions, conditions can be used to make an action unavailable if certain conditions are not met. This can be useful for actions that should only be made available after specific data has been collected.
TL;DR: Conditions are an array of expressions with an implicit AND
between them. If any of the conditions evaluate to false
, the condition fails.
Usage
Conditions
need to be specified as an array to the top level of any action or action component (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
.
Actions
Action conditions are also evaluated for AI actions using GPT Chat Task. Only actions that pass the conditions will be available for the AI to execute.
Conditions
can be used to control the availability of an action. This can be useful for actions that should only be made available after specific data has been collected.
Here we have an AI action that is only available if the stub.data.flight_booking_made
is 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.