pushover app

Questions, problems, and other issues for Ascendis Caller ID that aren't covered by the other forums.
Post Reply
samsungpower
Posts: 49
Joined: Tue May 22, 2012 4:40 pm

pushover app

Post by samsungpower »

First of all I must say great software, it has been running without any problems, it just works. Now down to the question we have currently been using the sendmail command in the advanced action script area to send out notifications to text us when a emergency call has come in with the caller information like this example:

Code: Select all

  SendMail('911', 'xxxxxxxxxx@vmobile.ca', 'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number,
 ' on ' + CallInfo.DateTimeStr + ' in ' + CallInfo.City); // Josh Text  
The problem is sometime there is a large amount of delay before we will receive text to our iphones or ipads this maybe because it has to be sent to the phone carrier and convert to a text message before sending out but not sure. Because apple has a pretty locked down system I haven't seen a way to send a iMessage from a windows computer that will not jeopardize time. Not knowing about the in's and out's about the language this software uses will the pushover app work with one of there API Libraries codes located at https://pushover.net/faq to be able to integrate into the advanced action script like we do right now with SendMail? If not does anybody have any other suggestions to send a notication to a Apple devices that works within the scripts? In the past we have had problems with Skype and would not like to go in that direction. Thanks
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Re: pushover app

Post by Bill Root »

I'm assuming the email delay is caused by your outgoing mail server or the receiving mail servers. As such, I can't think of anything Ascendis Caller ID could do to speed it up. You can log Ascendis Caller ID's email interactions to the Activity Log (Options window, Mail page) to verify this.

As far as using Pushover, I looked at their API and successfully made an action send to it by using cURL to talk to their server. ("curl is a command line tool and library for transferring data with URL syntax..."; http://curl.haxx.se/)

Here is the advanced action script:

Code: Select all

/////////////////////////////////////////////////////////////////////////////
// Pushover.dws
//
// Sends a message using the Pushover.net service
//
// For information on using the Pushover API, please see:
//  https://pushover.net/api
//
// THIS ACTION USES cURL.  IF YOU DON'T HAVE IT INSTALLED, DOWNLOAD IT FROM:
//  http://www.paehl.com/open_source/?download=curl_741_0_ssh2_ssl.zip&PHPSESSID=0923f37a6f42c3e53d8c5fcb1247a0fe
// (Or download a different version from elsewhere.  You probably need a version including SSL.)
// Unzip it to a folder on your path or your Ascendis Caller ID Program Files folder.
//
// NOTE: A result of 0 from the cURL command does NOT mean Pushover sent the message.
//
// 2015-03-08 WTR - created
/////////////////////////////////////////////////////////////////////////////
//LANGUAGE=DWS


///////////////////////////////////////////////////////////////////////////
// CONFIGURATION
///////////////////////////////////////////////////////////////////////////

// set APP_TOKEN to your application token from Pushover
const APP_TOKEN = '<your Pushover application token>';

// set USER_KEY to your user key from Pushover
const USER_KEY  = '<your Pushover user key>';

// change this to point to your certificate authority bundle file
// To create the file, download mk-ca-bundle.vbs from the Curl repository on GitHub&#58;
//  https&#58;//raw.github.com/bagder/curl/master/lib/mk-ca-bundle.vbs
// You may have to run it as an administrator.
//const SECURITY = '--cacert "C&#58;\Path\to\ca-bundle.crt"';

// INSECURE ALTERNATIVE TO CERTIFICATE AUTHORIZATION
// WARNING&#58; this is insecure because it disables security certificate validation
const SECURITY = '-k';	// INSECURE

// If TITLE is blank, your application name &#40;on Pushover&#41; will be used
const TITLE = 'Call Received';
//const TITLE = '';


var 
  message &#58; String;

// change this to the desired message
message &#58;= 'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number;


///////////////////////////////////////////////////////////////////////////
// CODE
// You shouldn't have to change anything beyond this point.
///////////////////////////////////////////////////////////////////////////

var title_arg &#58; String;
if TITLE = '' then
  title_arg &#58;= ''
else
  title_arg &#58;= ' --form-string "title=' + TITLE + '"';

var curl_args&#58; String;
curl_args &#58;= SECURITY + 
             ' --form-string "token=' + APP_TOKEN + '"' +
             ' --form-string "user=' + USER_KEY  + '"' +
             title_arg +
             ' --form-string "message=' + message + '"' +
             ' https&#58;//api.pushover.net/1/messages.json';
LogActivity&#40;'Sending to curl&#58; ' + curl_args&#41;;

var result&#58; Integer;
result &#58;= RunWait&#40;'curl', curl_args&#41;;

LogActivity&#40;'Result of sending Pushover message=' + IntToStr&#40;result&#41;&#41;;

if result <> 0 then
  ShowMessage&#40;'Could not send Pushover message&#58; error code ' + IntToStr&#40;result&#41;&#41;;
Caveats:
  • The script above requires some customization to work. At a minimum you have to change the APP_TOKEN and USER_KEY constants.
  • The script currently tells cURL NOT to validate the server certificate. In theory you can fix this by changing the alternate SECURITY constant and using it. However, I did not get this working on my system.

Finest regards,
Bill Root
Ascendis Software LLC
samsungpower
Posts: 49
Joined: Tue May 22, 2012 4:40 pm

Post by samsungpower »

Thanks Bill sorry for all the hard work I should of known it wouldn't be a simple fix. To add more the one user could we separate with a comma like this

Code: Select all

/////////////////////////////////////////////////////////////////////////// 
// CONFIGURATION 
/////////////////////////////////////////////////////////////////////////// 

// set APP_TOKEN to your application token from Pushover 
const APP_TOKEN = 'your Pushover application token - first user' , 'your Pushover application token - second user'; 

// set USER_KEY to your user key from Pushover 
const USER_KEY  = 'your Pushover user key - first user' , 'your Pushover user key - second user'; 
Or would we have to copy the code out for each staff member?
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Post by Bill Root »

I doubt you can specify more than one user per API call. I think the easiest solution is to use Pushover's Delivery Groups:
http://updates.pushover.net/post/581726 ... ery-groups

If you set up a delivery group on their site, you will get a group key that you can specify in the Ascendis Caller ID action instead of a user key. Then a single API call will send the message to all users in the group.

If that doesn't work for you for some reason, I can make the script handle multiple users by looping through them. But that would probably be harder for you to maintain. Also, I think a delivery group would get the messages to users faster.


Finest regards,
Bill Root
Ascendis Software LLC
samsungpower
Posts: 49
Joined: Tue May 22, 2012 4:40 pm

Post by samsungpower »

Bill, I been trying to figure out cURL and its language to add the ability of having custom sounds sent thru the pushover app.
As far as using Pushover, I looked at their API and successfully made an action send to it by using cURL to talk to their server. ("curl is a command line tool and library for transferring data with URL syntax..."; http://curl.haxx.se/)
My attempts to understand it failed miserably, here are a couple of modification to the original script.

Code: Select all

var title_arg &#58; String; 
if TITLE = '' then 
  title_arg &#58;= '' 
else 
  title_arg &#58;= ' --form-string "title=' + TITLE + '"'; 

var curl_args&#58; String; 
curl_args &#58;= SECURITY + 
             ' --form-string "token=' + APP_TOKEN + '"' + 
             ' --form-string "user=' + USER_KEY  + '"' + 
             title_arg + 
             ' --form-string "message=' + message + '"' +
             ' https&#58;//api.pushover.net/1/messages.json' +
             ' --form-string "sounds=bike"' + 
             ' https&#58;//api.pushover.net/1/sounds.json?token=&#40;my Pushover application token #&#41;';
and I thought it seems be missing reference to the string action for "sounds" so I tried something like this.

Code: Select all

var 
  message &#58; String; 
  sounds &#58; String;
 
  

// change this to the desired message 
message &#58;= 'Their is an Emerency Call from ' + CallInfo.Name + ' @ ' + CallInfo.Number + ' in ' + CallInfo.City; 
sounds &#58;= 'bike';
 
 




/////////////////////////////////////////////////////////////////////////// 
// CODE 
// You shouldn't have to change anything beyond this point. 
/////////////////////////////////////////////////////////////////////////// 

var title_arg &#58; String; 
if TITLE = '' then 
  title_arg &#58;= '' 
else 
  title_arg &#58;= ' --form-string "title=' + TITLE + '"'; 

var curl_args&#58; String; 
curl_args &#58;= SECURITY + 
             ' --form-string "token=' + APP_TOKEN + '"' + 
             ' --form-string "user=' + USER_KEY  + '"' + 
             title_arg + 
             ' --form-string "message=' + message + '"' +
             ' https&#58;//api.pushover.net/1/messages.json' +
             ' --form-string "sounds= ' + sounds + '"' + 
             ' https&#58;//api.pushover.net/1/sounds.json?token=&#40;my Pushover application token #&#41;';
am I starting to get closer or should I just give up. You can tell that I am not a programmer/coder but I try not let it stop me from learning.
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Post by Bill Root »

I think you're close. I don't have Pushover running anymore, but I looked at the API (at https://pushover.net/api) and it looks like the parameter for sound is named "sound". You have "sounds" in your code. Have you tried this?

Code: Select all

var curl_args&#58; String;
curl_args &#58;= SECURITY +
             ' --form-string "token=' + APP_TOKEN + '"' +
             ' --form-string "user=' + USER_KEY  + '"' +
             title_arg +
             ' --form-string "message=' + message + '"' +
             ' --form-string "sound=bike"' +
             ' https&#58;//api.pushover.net/1/messages.json';
Some notes:
  1. "https://api.pushover.net/1/messages.json" is only needed once. It's the URL (or web address) for submitting a message to Pushover.
  2. The "message" parameter ( --form-string "message=' + message + '"' ) is just one parameter. There is no functional relationship between the "message" parameter and the name "messages.json" in the URL.
  3. If you add other parameters as shown at https://pushover.net/api you should only have to add another line before the "json" line:

Code: Select all

             ' --form-string "&#91;parameter name&#93;=&#91;parameter value&#93;"' +
Computers are picky about what goes where (it's much easier to write programs that way, and it helps eliminate ambiguity) but you have the right idea. Keep trying!


Finest regards,
Bill Root
Ascendis Software LLC
samsungpower
Posts: 49
Joined: Tue May 22, 2012 4:40 pm

Post by samsungpower »

Maybe I was close but Bill you were exact.
If you add other parameters as shown at https://pushover.net/api you should only have to add another line before the "json" line:

Code:
' --form-string "[parameter name]=[parameter value]"' +
An add other parameters are also very useful add ons. Thank you for all your time and effort you have done.
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Post by Bill Root »

I'm very happy to hear it worked! Thank you.
Post Reply