Creating Custom Incidents

Let's take a look at how to create custom tasks and alerts not associated with any sensor or sensor location


thumbnail



SUMMARY:
  1. Microshare alerts
  2. Overview
  3. Create Share API for alert
  4. Verify Alert Creation
  5. Create alerts by custom location
  6. Create alerts by custom Alert type
  7. RecTypes

1. Microshare alerts


In the Microshare data pipeline, we process our IoT data (from sensors) into events and alerts, leading to a more responsive system where motion and environmental data are transformed into alerts and action data.

Alert data is the end of the process in the basic IoT pipeline, leading to a notification, a text message, or an email and leaving the customer to decide what to do next.

To learn more about incidents and alerts, please refer to the Incidents guide.

2. Overview


Alerts are primarily triggered by data streaming from a sensor. There might arise a necessity where we need to create custom alerts that are not associated with any sensor or sensor location, i.e. manually. These alerts can trigger an incident which can be acted upon by the customer.

Currently, alerts for a routing app are generated from a certain event generated by a sensor or the customer can create alerts associated to a sensor location. There yet isn’t a facility for customers to create custom alerts which are not associated to any sensor location.

To create custom alerts not associated with a sensor, we can use microshare’s API interface with postman to create a new share in a rectype. To get started with microshare’s API interface, refer to the Quick Start and Authentication guides.

3. Create Share API for alert


In the microshare api collection that you would have setup after following the api quickstart guide, select the “Create One Share” request. Under path variables, set the value for rectype as the rectype for the type of event alert you wish to create.

for eg. io.microshare.event.alert.feedback
thumbnail 1

This rectype can be an existing rectype or can be a new custom rectype of your choice. If the rectype is a custom rectype then you will need to configure a new bundler robot that will handle alerts from your new rectype. To create a new robot and configure it, refer to Robots Guide and Bundler Configuration

Next, in the Body tab of the request, select the raw format for the body, and write the body for the alert you wish to create in the format given below.

{ 
  "alert": "<alert_type>", 
  "change": 1, 
  "current": { 
    "sum": 1 
  }, 
  "event": "<event_type>", 
  "history": { 
    "sum": 0 
  }, 
  "label": "<label>", 
  "meta": { 
    "device": [ 
      "<location>"
    ], 
    "global": [ 
      "<organisation>"
    ], 
    "iot": { 
        "time": "YYYY-MM-DDThh:mm:ss.000Z",    
    }, 
    "source": [], 
    "usecase": "SF01" 
  }, 
  "solution": "<solution_type>" 
}

For sample bodies to create alerts for custom locations and alert types, refer sections 5 and 6


thumbnail 2

After adding your body and the appropriate rectype (eg. io.microshare.event.alert.feedback), hit send on the request and a new share should be added in the appropriate rectype. Next, verify whether the share has been created or not.

4. Verify Alert Creation


When you create one share of the new alert on the alert rectype, you will get a confirmation response body like so.
thumbnail 3

From this body, copy the url field. Next, open the “Get One Share” request and replace the selected part with the url you copied before.
thumbnail 4

Now hit send. You should see a response body like shown below, which should contain the body of the alert you created.
thumbnail 5

With this you can verify if your share has been created correctly, After a while, your new alert should be reflected in your routing app and this can be assigned to the respective personnel.

5. Create alerts by custom location


Example body to add alerts for custom location.

{ 
  "alert": "feedback", 
  "change": 1, 
  "current": { 
    "sum": 1 
  }, 
  "event": "clean", 
  "history": { 
    "sum": 0 
  }, 
  "label": "Label", 
  "meta": { 
    "device": [ 
      "Building B", 
      "Floor 2", 
      "Kitchen", 
      "Sink" 
    ], 
    "global": [ 
      "custom global tags"
    ], 
    "iot": { 
        "time": "YYYY-MM-DDThh:mm:ss.sssZ"
    }, 
    "source": [], 
    "usecase": "Usecase" 
  }, 
  "solution": "alert" 
} 

The above example demonstrates a request body for creating a share with a custom location tag with a known alert and event type. This location may not be associated with a sensor location and can be for an ad-hoc task for a particular location.

For handling custom locations, you will have to configure the respective bundler robot for the given alert rectype.

For eg. here, solution is alert and alert type is feedback so you can configure the existing robot for the rectype “io.microshare.event.alert.feedback” to handle the new location which is [“Building B”, “Floor 2”, “Kitchen”, “Sink”].

6. Create alerts by custom Alert type


Example Body for creating alert with custom alert type

{ 
  "alert": "trash", 
  "change": 1, 
  "current": { 
    "sum": 1 
  }, 
  "event": "full", 
  "history": { 
    "sum": 0 
  }, 
  "label": "Label", 
  "meta": { 
    "device": [ 
      "Building A", 
      "Floor 4", 
      "Room 1", 
      "Trash Can" 
    ], 
    "global": [ 
      "custom global tags"
    ], 
    "iot": { 
        "time": "YYYY-MM-DDThh:mm:ss.sssZ"
    }, 
    "source": [], 
    "usecase": "Usecase" 
  }, 
  "solution": "clean" 
} 

The above example demonstrates the creation of a task with a custom alert and event type. Here, the task is to empty the trash can.
thumbnail 7

This type of format can be used to assign ad-hoc tasks which may or may not be related to sensor alerts.

For alerts with custom alert and event types, a custom incident bundler robot has to be created and configured

7. RecTypes


The default recType for alerts is io.microshare.event.alert.(alertType) You can create shares of alerts in the same rectype or you can define your own custom rectype.

Custom rectypes can be defined in the format io.microshare.event.alert.(customAlertType)

For example: rectype = io.microshare.event.alert.refill
thumbnail 6

Bundler Configuration


For these new custom alerts to be registered in the routing app, a bundler robot has to be configured to handle your custom alerts. If the alert share is created in an existing recType, then you will need to update the existing bundler robot according to the alert based on the alert type or location. If you have created a new rectype for your custom alert share, then you will need to create a new incident bundler robot.

To configure A Bundler robot, refer to bundler configuration guide. To create a new robot, refer to Robots Guide and then refer to the bundler configuration for configuring the incident bundler robot.


Did this doc help you?


For further questions or support, please contact us at support@microshare.io

ms logo