Escalation mechanism

This page explains how escalation messages can be created and sent out after a period of inactivity. This guide is for interventions that coach the participant in multiple sessions. But in general, the core principles remain the same and the mechanism can be extended for any MobileCoach based intervention.

1-hour reminder on MobileCoach

Context: The patient started the intervention but did not finish it after one hour. After this period, the escalation mechanism kicks in, and the patient gets a reminder on the phone. This reminder does not appear in the chat.

However, some notifications are sent out when the conversational agent wants to communicate with the patient. These notifications appear as push notifications and are also then written in the chat.

Variables Widget

Create the following variables

$platform -> value = notSet

NOTE: To set the $platform variable to notSet you need to click on the Edit button. This should look like this:

Set platform to notSet

Micro Dialog Widget

Step 1: Enable the push notification on iOS devices

For Android device the authorisation to send push notifications is triggered automatically and does not require any extra effort of the Intervention team. However, on iOS this conversational turn needs to be added on day 1 (Session 1) of the intervention.


Please add the following text:

One important aspect ☝️
Please accept the following request that allows me to send you push notifications 🙏
We promise not to spam 😌

like this: es-enable-push-message

The overall conversation turn should look like this: es-enable-push-message-turn

The select one text being:

All right 👍:1
Wouldn't like to do that 😕:2

The answer to this question is saved into the variable $Session1Q1_permission.

One important thing is not to forget about setting the rule on the bottom of this page to: es-platform-ios-condition

If you want, you can also add an additional conversational turn to convince people to enable the push notification if they refused it in the first place. This could contain the following text:

But without these messages you will miss our sessions!
That would be a great pity 😣

The answer would of type select one and could be something like:

Okay, then. 👍:1

Then the rules would be the following:





Finally, you can add the conversational turn that will ask for permission on iOS systems. The text part should contain:


Please, make sure to tick the box called This message is a command (invisible for participant)

This should look like this: es-req-push-permission

Step 2: Session Initialisation

Before the intervention can be deployed, one needs to add another Micro Dialog widget called newSessionInit. This will be a very short micro dialogue since it will only contain a single decision point. However, this single decision point will initialise all the important variable for the intervention to run smoothly.

First create a new micro dialog by clicking on the New Dialog button on the bottom of the micro dialog page.

The following rules need to be created within one decision point:



Rule 1: es-session-init-3

Rule 2:

Create the variable $newSessionStartedYear and assign it to $systemYear


Rule 3:

Create the variable $newSessionStartedMonth and assign it to $systemMonth


Rule 4:

Create the variable $newSessionStartedDayOfMonthand assign it to $systemDayOfMonth


Rule 5:

Create the variable $newSessionStartedHourOfDay and assign it to $systemHourOfDay


Rule 6:

Create the variable $newSessionStartedMinuteOfHour and assign it to $systemMinuteOfHour


Rule 7:


This makes it possible to send the first message to the user when he/she opens the app since on the first day the patient could not already set the time when the conversational agent should come back to the patient.

Message Groups and Messages Widget

This parts enables the conversational agent to choose one out of three different notifications at random. For instance, it is possible to choose one reminder message out of three different reminder messages randomly. For this go into the Message Groups and Messages widget and click on New Group. Call this group 1hReminder and add three different reminder text message like this:


The texts could be:

Hi $participantName, The session is not yet finished. Would you be so kind as to finish today's session?
Hi $participantName, I am still waiting for your response. Thanks
Hi $participantName, I am still waiting for you. Best.

NOTE: Please do not forget to tick the checkbox This message will only be sent as push notification and NOT appear in the chat.


Rules Widget

Step 1: Add the Platform Rule in the USER INTENSION Rule

When the MobileCoach app is launched on the phone we get a user intention. In this user intention we need to specify if the phone is an android or iOS device. This should look like the following: es-rules-1

Create a new rule in the USER INTENSION section: $participantIntention text value equals platform like in the screenshot below:


Once you have create this first new rule, please add the following within the rule. The platform intention need to be set to the following: es-rules-3

Step 2: Add the 1-hour reminder rule in the DAILY BASIS RULE

In order to trigger the 1 hour reminder rule what we need to do is to add a rule in the Daily Basis Rules just before the day of the intervention is chosen. Note: The $sendMessagetomorrow rule might not be there in your intervention as this was a custom thing made by this specific group.

Create the initialize variables for 1h reminder functionality rule:


The rule look like the following: es-rules-5

This will make sure the variable are initialized properly before starting a new session. The Daily basis rule is run every day at 12:00 AM

The USER INTENTION rules should be set accordingly:


This new rules looks as followed and be named initialize variables for 1h reminder functionality rule: es-rules-ui-2

Step 3: Set the PERIODIC BASIS rules


Here instead of of an execution every 0 minutes something should be run periodically every 5 minutes. This is the goal of this section.

The important variable to set here is the variable $reminderAfter1hSent. The rules should look as followed:


Now you can move on to the second set of rules:



The idea here is that there should be a maximum one reminder for one session. Before the beginning of a session, the value is set to zero and then, if the reminder is triggered the variable is set to 1.

The text of the reminder is chosen randomly between three different variable (Please see the Group Message part)


To compute the amount of time that has passed between the last interaction of the patient with the app we need to set the following rule with the name calculate $participantInactiveInMinutes:


The javascript code to insert is the following one:

var now = new Date('$systemYear'*1, '$systemMonth'*1-1, '$systemDayOfMonth'*1, '$systemHourOfDay'*1, '$systemMinuteOfHour'*1);
var lastLogoutDateRaw = '$participantLastLogoutDate'.split(".");
var day = Number(lastLogoutDateRaw[0]);
var month = Number(lastLogoutDateRaw[1])-1;
var year = Number(lastLogoutDateRaw[2]);
var lastLogoutTime = '$participantLastLogoutTime'*1;
var hour = Math.floor(lastLogoutTime);
var min = Math.floor((lastLogoutTime * 60) % 60);
var lastLogout = new Date(year, month, day, hour, min, 0, 0);
var newLessonStarted = new Date('$newSessionStartedYear'*1, '$newSessionStartedMonth'*1-1, '$newSessionStartedDayOfMonth'*1, '$newSessionStartedHourOfDay'*1, '$newSessionStartedMinuteOfHour'*1);
if (newLessonStarted.getTime() > lastLogout.getTime()){
dt2 = newLessonStarted;
} else {
dt2 = lastLogout;
var diff =(dt2.getTime() - now.getTime()) / 1000;
diff /= 60;
diff = Math.abs(Math.round(diff));
var x = { 'participantInactiveInMinutes' : diff};

If this script cannot be copy-pasted please make sure the following variable exist:


After this the following rules need to be implemented:


this window could also look like the following:


Then create the condition that send a reminder after one hour:




The computation here is: $reminderAfter1hFrequency + 1

Finally do this:



  • Step 1: Message groups and messages
    • Implement the messages (Enable the push notification on iOS devices)
    • Randomization (Chose a random reminder/ notification text out of several options )
    • Only a push and not a normal message
  • Step 2: Mico dialogues
    • newSessionInit
      • Initialize time variables
      • Initialize session variable “\$interventionStatus” to “session-started”
      • First session push notification
    • Goodbye message
      • Set session variable “\$interventionStatus” to “session-finished”
  • Step 3: Execution on a daily basis
    • Sending the “newSessionInit” dialog
  • Step 4: Execution on a periodic basis
    • Reset reminder: if session finished, set ​\$reminderAfter1hSent as 0. If session started (i.e ongoing and not done)
      • If the 1 hour reminder is not sent for this session
        • If inactive for > 60 minutes
          • Send reminder
          • Set the ​\$reminderAfter1hSent as 1.
  • Step 5: Execution on intention
    • Go intention: send “newSessionInit” for the first session.