A simple text messaging alert using an SMS gateway
Below is a simple alert processor based on the EnsLib.HTTP.OutboundAdapter to 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 whose interface is as follows:
Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter";
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,FromPhoneNumber:Mobile";
/// The alert notification
Method SendAlert(pRequest As Ens.AlertRequest, Output pResponse As Ens.Response) As %Status
set tSC = $$$OK
set txtmessage = "An alert was generated from "_pRequest.SourceConfigName_" at "_pRequest.AlertTime
set txtmessage = txtmessage _ ". Please respond to the issue." // _pRequest.AlertText
set destination = ..ToPhoneNumber
set credentials = "<user token>"
set from = ..FromPhoneNumber
set tSC = ..Adapter.Get(.pResponse,"message,destination,action,credentials,from",txtmessage,destination,action,credentials,from)
set tSC = ex.AsStatus()
For further information on alerting see the online course Setting Up Alerts.