Alert messages

In inspection rules, you can configure alert messages that are sent to external recipients if the rule conditions are met. You can use simple text or standard message formats, such as JSON, and include metadata, such as rule results and confidence scores.

When you create or update an inspection rule, you can set up alert messages that are published to an MQTT topic. An alert message can also be sent to a phone number through the Twilio messaging service. If the rule conditions are met when an inspection is completed, the alert message is sent. You can create alert messages by using simple text, such as Inspection failed, or more complex formats, such as JSON, which is commonly used in MQTT messaging.

Alert messages in Maximo® Visual Inspection Edge are Go templates, which are text files that can create simple or complex content. These templates allow the inclusion of inspection metadata, such as context, result, or trigger metadata, in messages. Metadata from the Maximo Visual Inspection server that allows alert message recipients to access images in the Maximo Visual Inspection application can be included. Metadata variables that you include in alert messages must be enclosed in double braces, for example {{result }}.

Context metadata

Context metadata variables, such as InspectionName, StationName, DeviceName, and ModelUUID, can be included in alert messages. Use the following notation to refer to these variables: .context.Metadata.<variable name>

For example, to create a JSON message that outputs the name of the current inspection and a fail result, enter the following text in the Alert message field:

{
    "Inspection" : "{{.context.Metadata.InspectionName}}",
    "Result" : "fail"
}

The following context metadata variables can be used:

  • .context.Metadata.InspectionUUID
  • .context.Metadata.Inspection
  • .context.Metadata.Station
  • .context.Metadata.DeviceUUID
  • .context.Metadata.Device
  • .context.Metadata.MVIVersion
  • .context.Metadata.ModelUUID
  • .context.Metadata.MVIBaseUrl

Rule result and image metadata

You can also include metadata variables in the rule result, such as Name, Result, and ObjectLabel. Use the following notation to refer to these variables: .result.<variable name>

For example, to create a JSON message that outputs the name of the current inspection and the result of the current rule, enter the following alert message text:

{
    "Inspection" : "{{.context.Metadata.InspectionName}}",
    "Result" : "{{.result.Result}}"
}

You can also reference the name of the image that the rule processes by using the following notation: .image.ID

For example, if Maximo Visual Inspection Edge is installed in the /opt/ibm/vision-edge directory, you can reference the image in an alert message by including the following URL:

https://<hostname>/opt/ibm/vision-edge/images/{{.context.Metadata.InspectionUUID}}/{{.image.ID}}

The following rule result and image metadata variables can be used:

  • .result.Name
  • .result.Result
  • .result.ObjectLabel
  • .result.ObjectCount
  • .result.FilteredResults.Score
  • .result.FilteredResults.Label.Name
  • .result.FilteredResults.Rectangle.Min.X
  • .result.FilteredResults.Rectangle.Min.Y
  • .result.FilteredResults.Rectangle.Max.X
  • .result.FilteredResults.Rectangle.Max.Y
  • .image.ID

Trigger metadata

If an MQTT topic is configured in the inspection's Single-shot trigger field and the incoming trigger messages are in JSON format with metadata, the metadata variables can be used in alert messages. Use the following notation to refer to these variables: .trigger.<variable name>

For example, if an incoming trigger message contains the following text:

{
    "object" : "widget",
    "serial_id" : "152637"
}
You can include the trigger metadata variables in your alert message by entering the following message text:
{
    "inspection":"{{.context.Metadata.Inspection}}",
    "rule":"{{.result.Name}}",
    "result":"{{.result.Result}}",
    "object_type" : "{{.trigger.object}}",
    "serial_num" : "{{.trigger.serial_id}}"
}

By using this example for an inspection that is named Engine check and has a single rule that is named widget rule, the following alert message might be sent:

{
    "inspection":"Engine check",
    "rule":"Widget rule",
    "result":"Fail",Validate and check for completeness iconc
    "object_type" : "widget",
    "serial_num" : "152637"
}

Maximo Visual Inspection server metadata

After images are sent from Maximo Visual Inspection Edge to Maximo Visual Inspection, their unique image and data set IDs are returned to Maximo Visual Inspection Edge in metadata variables. These variables can be included in alert messages so that the message recipient can open the image in the Maximo Visual Inspection application. Use the following notation to refer to these variables: .mvidata.<variable name>

For example, if you deploy the Maximo Visual Inspection and Maximo Monitor applications in IBM® Maximo Application Suite and then integrate Maximo Visual Inspection Edge with Maximo Monitor, you can send alerts to Maximo Monitor devices that include links to open the images in the Maximo Visual Inspection application. For more information, see Integrating Maximo Visual Inspection Edge with Maximo Monitor.

The following Maximo Visual Inspection server metadata variables can be used:

  • .mvidata.DatasetID
  • .mvidata.ImageID

For more information about Go templates, see template.

Alert message templates

Note: Starting in Maximo Visual Inspection Edge 9.0, creating alert message templates is supported.

Administrators can create alert message templates to define the structure and format of the MQTT and Twilio alert messages that are sent from edge devices.

When you configure rules in an inspection configuration, you can select an alert message template when you create a Twilio or MQTT type message.