1. Concepts
  2. Conditions

Concepts

Conditions

Conditions are a way to control the flow of action steps (eg. notifications and tasks) during action execution.

Basic Principle

Stubber is a finite state machine. A stub starts in a specific state, in which it has actions to specific actions. Running an action can change the state of the stub to another state, but it does not have to. Each action will go through the following steps:

  • Collect information from fields.
  • Run the tasks.
  • Send out the notifications.
  • Calculate and record all metrics.
  • Update the state if required.

Using conditions, it is possible to only execute specific parts of the aforementioned steps, depending on the conditions set up for the action in the template.

For instance, 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:

loading...

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.

loading...

Notifications

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.