I ran into a issue recently as I needed to setup a call out system for my wife’s vet practice. The system needed to call the on-call veterinarian after a message was left on the PBX.
I had originally set their office up with a FreePBX installation, but there was echo on the line and other issues that I wasn’t prepared to try to troubleshoot. We use a SpoTel device at home so I knew that it would have the echo cancellation technology built into the device.
On the old PBX I was able to write PHP scripts to do my bidding which involved sending SMS messages when voicemail messages were left. The Dr’s did not particularly like that implementation since they preferred the system called them to notify of messages. A phone call does have a certain urgency to it that is not easily re-produced with an SMS ding.. :)In the end I picked up a SpoTel ipPBX02 (same device as I am using at home) but pre-configured for use with 2 Bell lines. I believe this meant that the two PSTN ports were FXO ready. The device sells for $275 and in my opinion (together with a good VOIP provider) is well worth the money. Their office uses VOIP phones (Polycom 601’s) through out, so that meant the device did not need to have any FXS ports to connect to standard analog phones.
With the SpoTel device, it runs ucLinux which is a very bare bones operating system. I did find that it had basic shell (not bash) so at least I knew that it would have some programming ability; though likely painful.
In the end the setup went like this…
- Added a call out to a shell script on the externnotify directive within the [general] block in voicemail.conf
- The called script determined the extension based on the passed parameters from the externnotify, then called the appropriate Dr’s script
- The Dr’s script
- first checked to ensure there was a message waiting
- no message, exit the script
- setup a lock file to make sure that it was running in an exclusive state
- forked a call to the Dr’s phone and bridged that call to an extension on the PBX
- extension details added to extension_additional.conf
- slept for 10 minutes and started on the first step above
- first checked to ensure there was a message waiting
- Once connected to the Dr, the system told them that it was the call notify system calling then directed them to their voicemail account for validation
[general] externnotify=/var/lib/misc/system_notify.sh
#!/bin/sh CONTEXT=$1 EXTENSION=$2 VM_COUNT=$3 if [ "$2" == "372" ] then sh /var/lib/misc/amanda_notify.sh elif [ "$2" == "272" ] then sh /var/lib/misc/robin_notify.sh fi
robin_notify.sh
#!/bin/sh LOCKFILE="/tmp/272outdial.lock" MESSAGEFILE="/var/spool/asterisk/voicemail/default/272/INBOX/msg0000.txt" if [ -f $LOCKFILE ] && echo $LOCKFILE exists && exit 0 then touch $LOCKFILE fi if [ -f $MESSAGEFILE ] then asterisk -rx "originate SIP/trunk_2/16135551212 extension 5272@" else rm -f $LOCKFILE exit fi sleep 600 sh /var/lib/misc/robin_notify.sh rm -f $LOCKFILE exit
[notify-callback] exten => 5272,1,Answer exten => 5272,n,Wait(1) exten => 5272,n,Background(/storage/sounds/record/CallNotify) exten => 5272,n,VoiceMailMain(272@default) exten => 5272,n,Macro(hangupcall)
Note the line asterisk -rx “originate SIP/trunk_2/16135551212 extension 5272@” which actually does the heavy lifting for us. cuLinux does not support the ability to fork, so this callout to asterisk directly solves the problem for us.
The call is made on the SIP trunk, and then passed to extension 5272.
Looking at extensions_additional.conf we can see how the flow is within Asterisk. It pushes out the CallNotify recorded message to let the Dr. know that they are being called, then directs to the Dr’s voicemail box to have them login. Once the Dr. listens to the message (or whatever) the system is free to hangup the call.
So far there have been no issues and all has worked without issue – and at a major cost saving to their office.
Script chunks as files:
Asterisk-scripts.zip