Getting Started Connect Your Systems Set Up Data-Driven SMS Alerting

Set Up Data-Driven SMS Alerting

time to complete
20 minutes

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:

Below is ObjectScript code that generates the text message. Credentials such as the API key have been removed from this sample, but you can try a compiled version of this code by using your InterSystems Learning Lab:

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
            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", 
            set pResponse = ##class(Ens.Response).%New() 
        catch ex
            set tSC = ex.AsStatus()
        return tSC

Create a purposely failing business service

  1. First, make sure you have an instance of InterSystems IRIS and an ObjectScript IDE ready to go. Sandbox settings will appear below after you log in and launch a sandbox.
    Need InterSystems IRIS?
    Get a free, online development sandbox here. Log in with your InterSystems login account, or register for one below.
  2. Once sandbox provisioning is completed, open the -- cannot display value - please provision a sandbox.
  3. Click Interoperability > Configure > Production. If there is not already a production, add one by clicking New. Give the production a package name and instance name.
  4. Click the + next to Services to create a new business service.
  5. Enter the following values and click OK.
    Service ClassEnsLib.File.PassthroughService
    Service NameFailingHospitalService
    Enable NowUnchecked
  6. Select the service you just created and navigate to Settings on the right side.
  7. 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.
  8. 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.
  9. Click Apply.

Create the SMS Alert business operation

  1. Click the + next to Operations and enter the following values:
    Operation ClassHospital.TextMessageAlert
    Operation NameEns.Alert
    Enable NowUnchecked
  2. Open the settings for this Business Operation and enter the following values:
    Mobile > ToPhoneNumber Your phone number including country code, no dashes. For example, 19999999999
  3. Click Apply.


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.