Rules and actions form a powerful way of making your application dynamic and provide you with a simple way of building logic. A rule is essentially a sort of trigger, there are several kinds of rules which are triggered under different circumstances. We will look each of them below. A rule can be associated with one or more actions, and an action is something that happens when a rule triggers. Just like with rules there are several kinds of actions.

For example, in an ordering-system application we want to send an email to the customer when an order has been shipped. We can accomplish that by creating a rule that triggers when an order-record changes status from ‘PENDING’ to ‘SHIPPED’. The rule would be connected to a SendMail action that will send an email to the customer.

Data Change

Rules that trigger on data changes are used to react to users creating, editing or deleting records within the app. A data change rule may trigger before or after the change has been applied. A rule that triggers before the change has been applied can modify or even reject the change.

Webhook

Rules that trigger on an incoming REST request can be used to perform actions at-will or to react to external input. They can be used to trigger rules directly from a user interface which normally does not have access to server side data.

A REST rule will be triggered any time the platform receives a REST request on the URL endpoint configured in the rule. For example a rule with the endpoint ‘myrule’ created in an app called MyApp would react to requests to the URL:

http://apps.appivo.com/api/app/MyApp/service/myrule 

These rules can also be triggered by using a script in a user interface and calling context.invokeService with the name of the rule.

Schedule

You can create rules that trigger according to schedule. This can for example be used to continually send push notifications to users that have not interacted with the app and tell them that they need to do so.

Email

You can set up rules that trigger on incoming email as each application gets its own email-address (in fact it’s each application/tenant-combination that gets its own email-address). This allows for creating simple types of integrations that users or remote system send email to feed data into your application.

Message

You can also set up rules that trigger when a message arrives on a topic on the application message-bus. This can be used to support real time interactivity in application user interfaces or to handle data or commands received from IoT-devices.