Programme Step - Wait For

Programmes can be set to wait for an event to happen for the customer before continuing

It is similar to a wait until step, but it has additional functionality. Because it can also listen out for user events, it can, therefore, be allowed to 'wait indefinitely', which means that if the firing events never happen the programme would always be running.

How Long to Wait For

When using a JS / or a wait until static time type of wait on this step, you can also choose what should happen if these time frames are reached. For example, you may wish to STOP a programme if someone has NOT interacted with it by a certain time. 

As well as setting a specific amount of time to wait for, or waiting indefinitely, a Javascript function can be used to calculate the length of time the step should wait for. 

In the above example, the Time Function takes the programme data as a first parameter and module data from the data source: Booking Data Source as the second parameter (To learn more about Module Data, see Programme Modules). The function then uses a property of the module data 'timeUntilDeparture' to calculate the time to wait. This example function would ensure that the step would wait here until after the time of departure.

Reacting to Events

Another key feature of the wait for the step is the ability to set events that will trigger an action if they are raised. These actions are: Stop, Continue and Evaluate. 

Stop and Continue Actions:

An example is represented in the image below. Events and corresponding actions can be selected. For example, the programme can be set to stop if a certain action occurs.

In another example, let's say I want to wait two weeks until a certain action is performed and then I want to stop this program once this action has been taken, then this can also be achieved using wait for. 

For both stop and continue, a javascript function can be used to determine whether the chosen action will happen when the event occurs.

In the above example, the function takes four parameters: the programme data, the event data, the customer and the module data. The module data is from the data source: Most Recent Data Source, specified under Module Data Class (To learn more about Module Data, see Programme Modules). The data passed into the function can then be checked for some condition to determine whether the action will be taken. In the above case, if the function returned true, the programme would continue, otherwise, it would continue waiting. This same logic can be applied to the stop action.

Evaluate Action:

The evaluate action is to be used when there is also a 'Time Function' used to calculate the time the step will wait (described in the 'How Long to Wait For' section). If the action is set to Evaluate for a particular event, then when the event occurs, the step will re-evaluate that earlier javascript function to redetermine the time to wait. 

It is also possible to provide a javascript function with the event which returns a map of data you wish to pass to the Time Function when it is re-evaluated.

In the above example, the javascript function takes three parameters. These are the same as for the Stop and Continue actions but without the customer, thus, the module data is now the third parameter rather than the fourth (To learn more about Module Data, see Programme Modules). The function for Evaluate must return a JSON object containing any new data you wish to make use of in the Time Function. This data will then be merged into the programme data to be accessed from the Time Function.

Still need help? Contact Us Contact Us