An action is an instruction that will be executed in the platform when it is called upon. An Action can only be triggered by a rule but can be associated with several rules so that several different triggers can result in the same action being performed. When creating an action there are certain variables that are available to you when you are creating your titles and messages.

Addressing Actions

When performing an action that will send some sort of message to users you have to specify to whom the message should be sent. This is done by using the addressing selection available on the action page. Selecting a role means that everybody with that role will be sent the message while selecting a user will send the message only specifically to that user. The record and previousRecord references are special in that they only apply under certain circumstances.

Email & SMS Actions

Both email and SMS actions are simply used to send SMSs and emails to users. They both support using the variables in order to get context specific information in the message and title (no title for SMS).

Push Actions

Push notifications are a great way to drive user interaction with your app and they support a lot of features. Push notifications can be used instead of SMSs and emails to send messages to users and are more direct than emails and cheaper than SMSs. The only limitation with push notifications is that they require you to create and distribute a hybrid app for your users. When defining a push notification you can decide what you want to push to the user. The most basic push notification includes only a message and a title. The title is also optional and will be defaulted to the application’s name if left empty. The message and title work in the same way as for emails and SMSs and use the same variables.

Push Buttons

Buttons in the push message are a great way to let the user instantaneously interact with the app or to send a user to a specific screen of the app when clicked. Buttons are defined by the text displayed on them and a script that will be executed once the user presses the button. If the app is not running when the user presses the button, it will be launched for the user and the script will then execute.

Push Badge

The badge is the number that is displayed on top of the app icon on an iOS device and in the bottom right corner of a push message on Android. The badge is a great way to tell the user that there is information waiting for them in the app. The value to be sent to users as the badge is determined by a script defined as the badge function and its return value will be used as the badge number.

Script Actions

Script actions are how you add custom logic to your applications. This is where you can handle REST requests that have triggered your rules, records, access control and many other things.

Action Variables

In the message and title fields and when addressing users, there are several variables accessible that relate to how the rule was triggered. The record reference is a reference to the record that was associated with triggering the rule. For example this could be the newly created record if the rule is setup to trigger on creation of a record. The previousRecord reference is only available with a rule that is set to react after data changes and is only available for addressing an action. The previousRecord reference could for example be used to access the old phone number when a user updates the phone number set on a model. Rules triggered by REST will pass along the data sent in the REST body to the action and this will be accessible in the record reference. The user that was responsible for the rule triggering is also accessible through the ‘user’ variable. Further, there are also variables that allow access to the host URL (‘hostURL’), the application config (‘app’) and locales (‘locale’).
All of these variables can be used in a template manner in the body and title. For example if you wish to include the first name and last name of the User that triggered the Rule in the title of a push you could write the following “{{user.firstname}} {{user.lastname}} triggered this!“. Similarly you might have a rule that reacts when a record of a certain model is updated and that model has a relation to the model user. In that case you could access that person’s email by writing the following “Contact info email – {{}}” (if the relation is called User).