Set Up Data-Driven SMS Alerting

InterSystems IRIS™ Interoperability makes it easy to keep track of business services and notifies you if important processes fail through customized SMS alert operations. For example, say your IT team monitors the data routing of mission critical hospital administration content. Staff coverage, call code status, and status updates about the location of providers and contents all must work seamlessly in order to ensure that patients get the necessary care at all times.

InterSystems IRIS can monitor the flow of data through these processes and send alerts should something not go as expected, such as an overload of messages to a process queue, a business process not receiving messages for too long, or a business operation receiving a bad response message. Through rulesets for message routing, InterSystems IRIS can send SMS alerts to the only the IT specialist responsible for the failing business service. That way, on-call surgeons or providers can get SMS alerts corresponding to different patient states, while the on-call IT administrator can be notified of systems issues automatically.

In this exercise, we will build the business operation that processes that message and then sends it to the SMS Gateway service. 

Below is a simple text message alert processor based on the EnsLib.HTTP.OutboundAdapter, which can send text alerts via an SMS gateway service. Typically, all that is needed to send an HTTP Post to the gateway service is the destination phone number, a source phone number, credentials, and the URL.

The code below is based on the Anveo gateway, which has the following interface:

https://www.anveo.com/api/v1.asp?apikey=YOURAPIKEY&action=sms&from=FROMPHONE&destination=DESTINATIONPHONE&message=MYMESSAGETEXT

Below is ObjectScript code that generates the text message:

Class Hospital.TextMessageAlert Extends Ens.BusinessOperation
{
Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter";

// this forces the settings for the adapter to display no matter what

Property Adapter As EnsLib.HTTP.OutboundAdapter;

Parameter INVOCATION = "Queue";

/// The phone number that receives the text message alert
Property ToPhoneNumber As %String;

/// The phone number that generates the text message alert
Property FromPhoneNumber As %String;
Parameter SETTINGS = "ToPhoneNumber:Mobile";

/// The alert notification
Method SendAlert(pRequest As Ens.AlertRequest, Output pResponse As Ens.Response) As %Library.Status
{
    set tSC = $$$OK
    try 
    {	  
        set txtmessage = "An alert from course ISC1065 was generated from "_pRequest.SourceConfigName_" at "_pRequest.AlertTime
        set txtmessage = txtmessage _ ". Please respond to the issue." // _pRequest.AlertText
        set destination = ..ToPhoneNumber
        set action="sms"
        set apikey = "<Your API Key" 
        set from = "<Your Anveo phone number"
        set tSC = ..Adapter.Get(.httpResponse,"message,destination,action,apikey,from",txtmessage,destination,action,apikey,from)
        set pResponse = ##class(Ens.Response).%New() 
    }
    catch ex
    {
        set tSC = ex.AsStatus()
    }
    return tSC
}
}

Create a purposely failing business service

  1. First, navigate to the InterSystems Management Portal. Click Interoperability > Configure > Production.
  2. Click the + next to Services to create a new business service.
  3. Enter the following values and click OK.

    Service Class

    EnsLib.File.PassthroughService

    Service Name

    FailingHospitalService

    Enable Now

    Unchecked

  4. Select the service you just created and navigate to Settings on the right side.
  5. Add path/notRealPath in the File Path section. Here we are telling the business service to look in a fake file path for data to consume, which will trigger an error.
  6. Still in Settings, scroll down to the Alerting Control section and check Alert On Error. This will tell the interoperability production to look for a business process or operation called Ens.Alert, which we will create next, and pass a message to it. Note that the InterSystems IRIS Interoperability engine looks for a process or operation called Ens.Alert and sends alert requests to that operation.

Create the SMS Alert business operation

  1. Click the + next to Operations and enter the following values:

    Operation Class

    Hospital.TextMessageAlert

    Operation Name

    Ens.Alert

    Enable Now

    Unchecked

  2. Open the settings for this Business Operation and enter the following values:

    Enabled

    Checked

    HTTP Server

    www.anveo.com

    URL

    /api/v1.asp

    Mobile > ToPhoneNumber

    Your phone number including country code, no dashes. For example, 19999999999

Test

You have now created an SMS business operation. The code behind this implements the code displayed above, but with real credentials. To test it, double-click the FailingHospitalService business service and click Enable. This will trigger an alert that passes a message to your operation. In a few moments, you will receive an SMS on your phone.