I wanted to see some alerts that occur in my Productions in a Mobile Device, I came across Pushover.net recently that although has an upfront cost $5 you can send as many messages as you like after that, there is a 7 day free trial to check it out.
To Integrate this with a production I did the following.
Create an account and set up a device on https://pushover.net/
Record the following API Keys from the web site on the main page you will see
Your User Key example: ueh3t7478foi3ruf2ogb3syu4fs34s
You then need to create an application I set
Name : Cache
Type : Application
And left the oter settings blank.
This will give you a
API Token/Key example: auh000es1aaaa7ddeb3i4jfkgwswero
I then created this class to add an operation to the production, replace your Key, token and device name into
Do httprequest.SetParam("token","auh000es1aaaa7ddeb3i4jfkgwswero") Do httprequest.SetParam("user","ueh3t7478foi3ruf2ogb3syu4fs34s") Do httprequest.SetParam("device","motogplay")
Class TrustDev.TrustMon.Operations.PushOverSender Extends Ens.BusinessOperation { Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter"; Property Adapter As EnsLib.HTTP.OutboundAdapter; Parameter INVOCATION = "Queue"; Method OnD03Alert(pReq As TrustDev.TrustMon.Messages.Alert, Output pResp As %String) As %Status { Set Message = "Server = <b>"_pReq.ServerName_"</b>" Set Message = Message _ "Alert Code = "_pReq.EventDescription Set title = pReq.EventCode_" : Priority "_pReq.EventAlertValue Set httprequest = ##class(%Net.HttpRequest).%New() Set httprequest.SSLConfiguration = "pushover" Set httprequest.Https = $$$YES Set httprequest.Server = "api.pushover.net" Set httprequest.Location = "/1/messages.json" Set httprequest.ContentType = "application/x-www-form-urlencoded" Do httprequest.SetParam("token","auh000es1aaaa7ddeb3i4jfkgwswero") Do httprequest.SetParam("user","ueh3t7478foi3ruf2ogb3syu4fs34s") Do httprequest.SetParam("device","motogplay") Do httprequest.SetParam("title",title) Do httprequest.SetParam("html",1) Do httprequest.SetParam("message",Message) Do httprequest.Post(,0) set stream = httprequest.HttpResponse.Data while 'stream.AtEnd { Set pResp = stream.Read($$$MaxStringLength) } Quit $$$OK } XData MessageMap { <MapItems> <MapItem MessageType="TrustDev.TrustMon.Messages.Alert"> <Method>OnD03Alert</Method> </MapItem> </MapItems> } }
The message I pass into this class is the following, but you could adapt this to your own requirements.
Class TrustDev.TrustMon.Messages.Alert Extends Ens.Request { Property SiteName As %String; Property ServerName As %String; Property ServerId As %Integer; Property ProductionName As %String; Property EventDateTime As %DateTime; Property EventCode As %String; Property EventItem As %String; Property EventCodeId As %String; Property EventDescription As %String(MAXLEN = 50, TRUNCATE = 1); Property EventValue As %Double; Property EventValueUnits As %String; Property EventSD25 As %Double; Property EventAlertValue As %Double; Property EventAlertNow As %Boolean; Property ErrorCode As %String; Property EventValue2 As %Double; Property EventValue3 As %Double; Property EventValue4 As %Double; Property EventValue5 As %Double; }
Your going to need a empty SSL Client Configuration
In Ensemble go to System > Security Management > SSL/TLS Configurations
Click Create New Configuration
Name it Pushover and leave all the other fields as default and click save
On a Production add a new Operation using the class TrustDev.TrustMon.Operations.PushOverSender
In the basic settings set
HTTP Server = https://api.pushover.net/1/messages.json
In Connection Setting set the SSL Configuration to pushover, as created above
Uncheck SSL Check Server Identity
This should now be working, click Actions -> test and add some values to the Request Details and you should get your first notification through.
Good Luck! :)
Thank you, Mark!
Here is also a similar article by @Tamara Lebedeva where Ensemble is being used to deliver push notifications for mobile devices.
Good article.
If you have BO with one message route in message map you can remove the message map altogether and name your method OnMessage - it would be called automatically.
Hi Mark, interesting stuff as usual.
Does your implementation go on to take advantage of the notification priorities? I'm just thinking of what benefits could be gained for alerting on-call staff to issues.
Hi Julian
To send a priority to pushover you need to add
Do httprequest.SetParam("priority", pReq.EventPriority)
set the value between -2 and 1, if you want to set it to Emergency Priority (2) you will also need to send retry and expire parameters like this
Do httprequest.SetParam("retry", pReq.EventRetry)
Do httprequest.SetParam("expire", pReq.EventExpire)
Do httprequest.SetParam("priority", pReq.EventPriority)
The defaults for Expire is 60 and retry 3600
I added these values to the inbound message pReq As TrustDev.TrustMon.Messages.Alert
Property EventPriority As %Integer [ InitialExpression = 0 ];
Property EventRetry As %Integer [ InitialExpression = 60 ];
Property EventExpire As %Integer [ InitialExpression = 3600 ];
Hi Mark.
After throwing in an if statement for the Priority variation and some other local tweaks I have this working perfectly, so thank you for sharing.
I also added the Token and User Key as a setting to be set from the Operation within Ensemble.
It would be good to catch up outside of the Intersystems forums sometime soon.
Cheers!
For anyone interested in adding the Token and User Key
So I included before the method:
And then the http request parameter became:
This leaves the token and user key to be configured within Ensemble via the Management Portal: