(Finally got it working!) Trying to install caller notification popup on Mac (multi-OS program)

In the past I have used the Nerd Vittles U-Rang II for popup notifications on a PC. This had its issues (if Asterisk was restarted for any reason then it wouldn’t work until the client was restarted) but worked well enough. The problem is that although he promised a version for Mac OS X nearly a year ago, it hasn’t been forthcoming. Therefore I decided to look into another option. What I found was this:


Now, I thought at first that this would work like the NV client, particularly since it shows you lines to add to manager.conf (which of course would be manager_custom.conf in FreePBX. Goes to show that I reall should read the whole page first. Actually, what you have to do to make this work is install a module in Asterisk, THEN the client will work (except that I still need to figure out how to properly integrate it into FreePBX). For anyone else wanting to do this, here’s what you have to do from the command prompt:

cd /usr/src

wget http://mezzo.net/asterisk/app_notify-1.0.tgz (if using 1.2 branch of Asterisk, otherwise if using 1.4 branch then http://mezzo.net/asterisk/app_notify-2.0rc1.tgz is the address to wget, or whatever is newest in the 2.0 series)

tar -xzf app_notify-1.0.tgz (or whatever version you got)

cd app_notify-1.0 (or whatever version you got)

make install

Restart Asterisk or load the application module with:
load app_notify.so
(I went to the Asterisk CLI and did a restart when convenient just to make sure I wouldn’t interrupt any calls)

You also have to install the client on your Mac and configure it. To just receive notifications (not use the dialer function - I’m only trying to tackle one problem at a time) you go to System Preferences | Other | Asterisk (yes they call their client “Asterisk” in the preference panel). Under “Notifier” I suggest you turn on Growl notifications if you have Growl installed, and turn off “Speak announcement” - that is a cool feature, but it only worked once for me, then I got no notifications thereafter until I turned “Speak announcement” back off.

There also a bug where you enter the server address. You have to click the plus (+), then click in the location where the server address should be, and then a text box should appear which SHOULD allow you to enter the address. What I found was that the keyboard input routine was really screwy and that I got a bunch of extra characters. If that happens to you, just “blind type” the correct address (don’t look at the screen, watch the keyboard as you type). If you have typed it correctly, it will be in its correct form at the END of a string of garbage characters. Highlight all the characters other than the correct ones using the mouse, then right-click and select “cut”, and you should be left with the correct server address. Yes, I know that’s a screwy way to do it, but whatever works… EDIT: It occurs to me that you could probably just open up a text editor or a new message in your e-mail program, type in the correct IPaddress, select and copy it using Option+C, and then paste it into the field using Option+V. If that happens to create an extraneous character, then use the method mentioned above to delete it.

What this module does is give you the ability to insert a statement in the Asterisk dialplan that will send a notification to a particular IP address or system when a particular event happens. It appears the event could be anything but the client is set up to parse a string in a particular format. They show the following examples inserted into an Asterisk dial plan:

exten => s,1000,Notify(${CALLERID(num)}|${CALLERID(name)}|${EXTEN}/sunnybook)
exten => s,1001,Notify(${CALLERID(num)}|${CALLERID(name)}|${EXTEN}/windfeebook)
; ^ ^
; the 2 pipes are necessary. they don’t mean ‘OR’.

Now in FreePBX you don’t usually get that kind of control over the dial plan, and also it seems that referring to a machine by name doesn’t work (EDIT: That’s because it resolves these by doing a DNS lookup. If you don’t have your local machines mapped in some way, for example entries in the /etc/hosts file, then the names won’t resolve. But using /etc/hosts kind of defeats the purpose anyway, because the entries there will be wrong if the target computer gets a new IP address). Just as a test, I put the following into extensions_custom.conf:

;Notify test
exten => *105,1,Notify(${CALLERID(num)}|${CALLERID(name)}|${EXTEN}/
exten => *105,n,Hangup

(The second statement is probably unnecessary, I just included it to clear the connection). Now, what happens when I dial *105 is I get a Growl popup that shows the calling extension and called extension. So anytime someone dials *105 I get notified, as long as my computer doesn’t get assigned a new IP address by the router’s DHCP server.

Obviously, this isn’t too useful as it sits, So what I need help from the community and/or developers on is as follows:

What I would IDEALLY like to do is insert a line into the dialplan that would execute after the final determination was made as to which extension(s) will ring, and if an extension on a predefined list is called, it would send a notification to the IP address associated with that extension. I say IP addess because I’m not sure how they are using names in the above context. The Mac does have a name assigned to the machine, but using that doesn’t seem to work. EDIT: Now I realize it’s just doing a DNS lookup, as I mentioned above.


After way more effort than this should have taken, I found a way to make this work, sort of. This assumes that the computer’s IP address doesn’t change. I had a false start here because I originally attempted to use the Dialplan Injection module to add the extra code, and that introduced issues that were not present when I simply put the desired code in extensions_custom.conf.

So here’s how I did it:

For each extension I wanted to monitor, I edited the existing follow-me for the extension. If you don’t have a follow-me set up already, create one for each extension you want to monitor. Note that if you already have a certain configuration of Follow-Me set up, it might be necessary to move some or all of those details to a Ring Group to make this work, and use the Ring Group as the destination of the Follow-Me. For the sake of simplicity I’ll assume a simple setup where you don’t already have a Follow-Me set up for the extensions you want to monitor.

Create a Follow-Me for the extension, make the ring strategy firstnotonphone, set the ring time to whatever you want, and make the Destination if no answer whatever you want (probably the extensions’s voicemail). In the Follow-Me List put two entries. At the top put the extension number with four asterisks in front of the number and a pound sign (hash mark for you Brits) on the end. On the next line, just put the extension numer itself. So let’s say you’re doing this for extension 525, you’d have these two entries:


Save this but don’t do a configuration reload just yet.

Next go to etc/asterisk/extensions_custom.conf and, somewhere under the [from-internal-custom] context insert these two lines:

exten => ****525,1,Notify(${CALLERID(num)}|${CALLERID(name)}|525/
exten => ****525,n,Busy

Change the boldfaced items to the proper extension number and/or IP address of the computer to receive the notifications.

If you want notifications for more than one extension, repeat the above for each extension you want to monitor. If you want the notifications to go to more than one computer, just duplicate the topmost line of the custom context addition as many times as you need to, changing only the target IP address.

Don’t forget to reload the configuration when you are finished, and test the result.

You could use any number that no one is likely to dial in place of ****(number) but I chose that because that’s absolutely undialable from most Linksys/Sipura equipment, and few people are likely to dial four *'s in a row anyway. Also, it’s not likely to inadvertently match anything in your existing dialplan, and using ****+ extension number lets you see immediately which extension the custom dialplan fragment is associated with. And you do have to use the ending # in the Follow-Me definition or it just gets skipped over (is that a bug? I have no idea).

The syntax used in the “Notify” line works fine under Asterisk 1.2.x (and later), despite any impression to the contrary you may have from reading the original docs.

I had originally tried to do this using a Dialplan Injection. That is NOT the way to go, because it adds on some extra lines that in this case are deadly to the proper functioning of this added dialplan fragment. Add the lines in extensions_custom.conf

Keep in mind that that the IP address is static - you have to use the one assigned to the machine that is to receive the notifications (not unless that’s the IP of your machine), and if it ever changes you’ll have to edit extensions_custom.conf and change it to match the new IP. Many routers try to keep giving the same IP address to the same piece of equipment, but often that fails after a power interruption or major network reconfiguration. Of course, you could assign the computer a static IP address, if you have sufficient control over the network. Or maybe YOU can figure out how to get computer names to work in that field, because I had no luck at all there.

I did it this way because I don’t have any external extensions in my Follow-Me - this is just a home system and the two extensions in the follow-me group sit right next to each other. In another application, you’d want to think about what you put in the Follow-me and in what order (and also in the ring group, if you must use one of those), and not blindly copy what I did above!

This still is not what I’d consider an elegant solution - it’s a workaround at best. I wish FreePBX had better support for inserting a line or lines into the dialplan just prior to ringing an extension, but I’m not exactly what you call a great programmer (I can maybe hack out a really short Perl program, but it might take me a couple of days) so any mods to FreePBX will have to be left to someone more knowledgeable.

I don’t have time to read your whole post but it seemed like you were trying to find a way to inject a line of code into an autogenerated dialplan. If that is the case, the answer is that you can splice a line in to the dialplan. Take a look at pinset module, you will see how it splices a call to it’s own macro in the outbound route macros, or I think cidlookup does the same into ext-did. It would require writing a simple module to do what you want but that is not really all that hard.

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

Yes, I would like to inject a line of code into an autogenerated dialplan, but the first question I would have is where to insert it - basically I need a way to execute that line of code just prior to ringing an extension, and I don’t understand what FreePBX is doing well enough to know where such a line might go. And beyond that, writing modules is still way beyond my abilities (even if I knew how, they’d be in perl, so you wouldn’t want them).

I guess what I’m wishing is that FreePBX had a “hook” (maybe an include) in it somewhere that would allow the user to go out and execute some custom code just prior to ringing an extension. You have these “includes” in other places in the FreePBX dial plan, and it could even be made optional in the extension setup - have a checkbox that, if checked, generates something like #include extnumber_custom.conf (where extnumber is the actual extension number) in the dial plan, just before the dialplan line that rings the extension. That would actually allow for a lot of customization that’s not now possible.

The other way something like this could be accomplished would be to make it part of the follow-me and ring group setup pages. In this case maybe you could have a text box on those pages, where users could specify a line for inclusion in the dial plan just prior to executing the follow-me or ring group. If the text box were left blank nothing would be added, otherwise the line in the text box would be inserted verbatim into the dial plan. So the user could add ONE line to the dial plan, or could add an #include for multi-line processing, or whatever. Obviously this would be an advanced feature but it would make life a lot easier for the non-programmers in the user base.

(Edited to delete irrelevant paragraph)

The method I had included in my original post was unnecessarily complicated, so I’ve gone back and edited the original message to include the much simpler workaround.