api-title-rules.png

As information from end points is consumed into MachineShop, it can be analyzed in real-time for specific events or conditions. An advanced rules engine configured via RESTful API's using a JSON is available to manage these rules as required. Notification methods are available including: http, tcp, SMS, email, and even control actions.

 

Rules are evaluated in near real-time in order to insure fast response of events to customer applications. There is no required interaction from your application for the rules to be evaluated; these are all part of the services within IQ.

Representative samples of API’s available within our Rules and Event Management services:

/rules

Description: Rules are defined using JSON that will indicate if-then-else actions to be taken on a single or multiple data_sources. The rule is evaluated on each report of the data collection subscription for any/all of the data_sources.

Available command actions include: SMS, email, tcp message, web service call (http/https). In addition, any MachineShop service could also be called as part of an action. For example, your application could define a rule that, when triggered, sent a specific command back to a data_source to change its behavior.

Rules can also be defined that are dependent on the trigger of other rules. IN this way you can have dependent rules at multiple levels to create complex rule events and actions.

Example: POST /rulesView

{
    "devices":[], "device_instances":["359464036002587"],  
    "rule": { 
    "description": "Speed greater than 65",  "active": "true", 
    "condition":          {
      "type":"less_than_rule_condition", 
    "property":"battery_percentage", "value":"85" }, 
     "then_actions":   [ {  "type":"SMS_rule_action", "send_to":"+18015551212", "priority":"1" }],   "else_actions": [
{
    “type”:”email_rule_action”,
    “send_to”: test@machineshop.io”,
    “priority” : “1”,
    } ]  }
}

This POST is used to define a rule for a device 359464036002587 such that if its patter percentage is < 85 it will send an SMS to a specified number. Otherwise, it will send an email to test@machineshop.io. This device will send an SMS every time a report is received that meets the specified condition. It will send an email to the reports that do not meet this condition.

GET /Rules

Example: GET /data_source_types View

[
[
  {
    "_id": "54ca4e336db0c9e06700025d",
    "active": true,
    "created_at": "2015-01-29T15:13:55Z",
    "data_source_ids": [
      "54b0236b6db0c93f580003b4"
    ],
    "data_source_type_ids": [],
    "delayed_actions": [],
    "deleted_at": null,
    "description": "Greg Test Rule",
    "downstream_rule_id": null,
    "else_actions": [
      {
        "_id": "54d1353b50e7b033cf000415",
        "created_at": "2015-02-03T20:53:15Z",
        "deleted_at": null,
        "priority": 1,
        "send_to": "test@machineshop.io",
        "updated_at": "2015-02-03T20:53:15Z",
        "type": "email_rule_action"
      }
    ],
    "last_run_status": "pass",
    "plain_english": "If battery_percentage is less than 85.0 then send a SMS to +14698772398. Otherwise send an email to test@machineshop.io.    This rule applies to these device instances: 359464036002587.",
    "then_actions": [
      {
        "_id": "54d1353b50e7b033cf000414",
        "created_at": "2015-02-03T20:53:15Z",
        "deleted_at": null,
        "priority": 1,
        "send_to": "+14698772398",
        "updated_at": "2015-02-03T20:53:15Z",
        "type": "sms_rule_action"
      }
    ],
    "updated_at": "2015-02-03T20:53:15Z",
    "user_id": "54a6025050e7b0d4de0008f7",
    "rule_condition": {
      "_id": "54d1353b50e7b033cf000413",
      "created_at": "2015-02-03T20:53:15Z",
      "deleted_at": null,
      "parent_or_sibling_key": null,
      "parent_or_sibling_value": null,
      "property": "battery_percentage",
      "rule_id": "54ca4e336db0c9e06700025d",
      "updated_at": "2015-02-03T20:53:15Z",
      "value": 85,
      "type": "v1/less_than_rule_condition"
    }
  }
]

MachineShop’s Ecosystem

Join the growing network of organizations leveraging Connected Services

Get Started
As Seen in