Rule Builder

Description

An “If This Then That” widget, which will allow users to create simple conditional statements, called “IFs”, which will trigger other services such as SMS, Email etc.

OPTIONS

  • Name (String)
    • The title displayed within widget container
  • Allow Create (Boolean)
    • Specifies whether or not users are allowed to define new rules within the widget. If set to NO, the +Add New Rule link will NOT be displayed in the widget.
  • Allow Delete (Boolean)
    • Specifies whether or not users are allowed to create delete rules defined within the widget
  • Allow Edit (Boolean)
    • Specifies whether or not users are allowed to modify rules defined within the widget
  • Allow On/Off (Boolean)
    • Specifies whether or not users are allowed to enable/disable rules defined within the widget
  • Block Height (Integer)
    • Pre-defined block sizes
    • See Portal Overview for info on block size
  • Container Width (Integer)
    • The width of the widget container, expressed as a percentage from 0 to 100

Pre-Conditions

In order to create, modify, and delete rules, the user must belong to a role which was granted “system-level” access permissions in the ClearBlade Platform to create, update, and delete services and triggers.

USAGE

Upon creating a new RuleBuilder widget, the Rule Builder widget will be displayed without any rules since none have been created as of yet. Clicking the + Add New Rule link will allow you to create new rules. In order to Create rules, the Allow Create option for the RuleBuilder widget must be specified as YES.

When rules are created, they will be listed within the rule builder widget.

  • Clicking the button showing the rule name will allow you to modify the configuration of that rule. In order to Edit rules, the Allow Edit option for the RuleBuilder widget must be specified as YES.
  • Clicking the trash can icon to the left of the rule name will allow you to delete a rule. In order to Delete rules, the Allow Delete option for the RuleBuilder widget must be specified as YES.
  • Clicking the ON/OFF toggle will allow you to enable/disable a particular rule. In order to Enable/Disable rules, the Allow ON/OFF option for the RuleBuilder widget must be specified as YES.

Creating Rules

  1. In the RuleBuilderWidget, click the + Add New Rule link. A dialog will be displayed allowing you to provide a name for the rule and select the data source for the rule.

  2. Enter a descriptive name for the new rule

  3. Select the datasource for the rule (message is the only datasource currently supported). In the context of the RuleBuilder widget, a datasource refers to a ClearBlade Platform asset. Future datasources that may be supported include data collections, code services, users, devices, etc.

  4. Upon selecting the message datasource, you will be given the opportunity to specify the IF conditions under which the rule will be triggered. To specify the triggering conditions for the rule, specify values for the following fields:

    1. Topic - The messaging topic associated with the rule. Messages published to the specified topic will result in the rule being triggered.
    2. Variable - The name of a variable within the message payload
      For Example: color where the message payload is
      { alertLevel: “Error”, color: “red” }
    3. Operator - The comparison operator to use when comparing the Variable to a Value
    4. Value - The value of the Variable used with the comparison operator to determine whether or not the rule should be triggered.
  5. Multiple conditions can be joined together with AND and OR operators to produce sophisticated rule triggering conditions. Join conditions can be added to a rule by clicking the +Add Condition button.

  6. When all rule triggering conditions have been specified, click the Next button.

  7. Upon clicking the Next button, you will be able to define the actions (Then section) that will be triggered when the conditions entered in steps 3-5 are met.

The alert types currently supported are:

  • SMS - Send an SMS message to one or more mobile devices (Twilio is currently the only supported SMS provider)
  • E-mail - Send an email to one or more recipients (SendGrid is currently the only supported E-mail provider)
  • Service - Invoke a ClearBlade Platform code service

  1. Select an alert type, provide the appropriate values for the required fields, and click the Next button

  2. Upon clicking the Next button, an overview of the rule configuration will be displayed. If you are satisfied with the rule and wish to save it, click the DONE button. Otherwise, you can click the Edit buttons within the IF and THEN sections to go back and make changes to the respective conditions and alerts.

  3. Upon clicking Done, the rule will be displayed within the RuleBuilder widget.

Modifying Rules

Clicking the button showing the rule name will allow you to modify the configuration of that rule. In order to Edit rules, the Allow Edit option for the RuleBuilder widget must be specified as YES.

Deleting Rules

Clicking the icon to the left of the rule name will allow you to delete a rule. In order to Delete rules, the Allow Delete option for the RuleBuilder widget must be specified as YES.

Adding conditions to rules

While editing the IF section of a rule you can add additional conditions, joined by logical AND and OR operators, by clicking the + Add Condition button.

Deleting conditions from rules

Conditions can be deleted from rules by clicking the icon located in the bottom left corner of a condition.

Turning rules ON/OFF

Clicking the ON/OFF toggle will allow you to enable/disable a particular rule. In order to Enable/Disable rules, the Allow ON/OFF option for the RuleBuilder widget must be specified as YES.