Rules and Actions provide a powerful mechanism to make applications dynamic and a simple way of adding logic. The Rules and Actions section contains both rules and actions, which are typically used to model business logic within an app. Rules are the programmatic conditions that must be met to trigger an action. There are a number of actions available such as sending emails or executing scripts.

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.

Rule Types

Click the +New Rule button to add a new rule, and give it a unique name. A rule must have a triggering condition as follows:

  • Data Change
  • Schedule
  • Webhook
  • Message received
  • Email received

Data Change

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

Description of fields:

Fields
Description
Trigger
Use this field to change the rule trigger.
Condition
Condition defines the type of data change that triggers the rule. Conditions include options for triggering before or after a specified model is created, updated or deleted.
Trigger Criteria
Trigger criteria narrows the condition under which this rule an action can be added.
-Attribute
-Value
-Parameter
Trigger actions
Select an existing action to be executed if the rule conditions are met, or create a new action.

Schedule

Rules that trigger according to schedules can be created. Scheduling can be used to run batch processes or even to send push notifications to users.

Description of fields:

Fields
Description
Trigger
Use this field to change the rule trigger.
Schedule Type
Global
Schedule
Summary about the scheduled action.
Trigger actions
Select an action to be executed if the rule conditions are met, or create a new action.

Webhook

Rules that trigger on an incoming REST request are used to perform actions at will or that react to external inputs. They are used to trigger rules directly from a user interface which does not have access to server side data. A REST rule will be triggered any time the platform receives a request on the URL endpoint configured in the rule. 
For Example: a rule with the endpoint “myrule” created in an 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.

Description of fields:

Fields
Description
Trigger
Use this field to change the rule trigger.
HTTP Method
Select the appropriate HTTP method:
-GET
-POST
-PUT
-DELETE
Webhook Endpoint
Enter a name for the Webhook endpoint. To keep things simple, consider using the rule name or a shortened version of it.
Webhook URL
This is automatically generated based on the name of the app.
Trigger actions
Select an action to be executed if the rule conditions are met, or create a new action.

Message Received

The Developer can set up the 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.

Description of fields:

Fields
Description
Trigger
Use this field to change the rule trigger.
Queue
Messages can be destined for different queues, allowing the developer to process in different ways.
Trigger actions
Select an action to be executed if the rule conditions are met, or create a new action.

Email Received

Developers can configure rules that trigger on incoming email as each application has its own email address. This allows for creating simple types of integrations where users or remote systems can send email to feed data into an application. For multi-tenant scenarios, it’s important to note that an email address is generated for each application-tenant pair.

Description of fields:

Fields
Description
Trigger
Use this field to change the rule trigger.
Key
The key specified should match with the email address provided.
Email-address
This email address is automatically created for the app.
Trigger actions
Select an action to be executed if the rule conditions are met, or create a new action.





Up Next

No Topics.