Upgrade 3CX to v18 and get it hosted free!

Asterisk Voicemail Notify for Support Numbers

Author image

I looked for a reference to do this for some time to replace the callout
feature in my old AVT voicemail.

I never found one, so I decided to dig in.

Here is my first run. It is in production, so unless I find a problem,
I am done.

Script set to run every 5 min. via cron.

This sets a lock file to prevent 2 scripts from running.
Check for a VM in our Emergency after hours support mailbox.
If found, it sends a numeric page to our rotating pager.
If no one has listened to the mail in 7 minutes, it calls a cell phone.
On this call, it connects directly to a prompt, then VoicemailMain with
the ext. already included.
If no one has listened to the mail in 7 minutes, it calls a second cell
phone.
On this call, it connects directly to a prompt, then VoicemailMain with
the ext. already included.
If no one has listened to the mail in 7 minutes, it calls the rotating
pager again.
This continues to loop until the VM is listened to.

isnotify.sh:
LOCKFILE=/tmp/5134outdial.lock
MESSAGEFILE=/var/spool/asterisk/voicemail/default/5134/INBOX/msg0000.txt
CALLFILE1=/tmp/5134outdial1.call
CALLFILE2=/tmp/5134outdial2.call
CALLFILE3=/tmp/5134outdial3.call
CALLUSER=asterisk
OUTGOING=/var/spool/asterisk/outgoing/

date

  1. echo lock file check

if [ -f $LOCKFILE ] && echo $LOCKFILE exists && exit 0
touch $LOCKFILE

function recip1 {
if [ -f $MESSAGEFILE ]
then
echo $MESSAGEFILE exists!
echo calling IS pager
echo Channel: ZAP/g0/1XXXXXXX892 >> $CALLFILE1
echo MaxRetries: 2 >> $CALLFILE1
echo RetryTime: 60 >> $CALLFILE1
echo WaitTime: 30 >> $CALLFILE1
echo Context: ext-local >> $CALLFILE1
echo Extension: 5681 >> $CALLFILE1
echo Priority: 1 >> $CALLFILE1
echo “CallerID: IT VoiceMail <XXXXXX5682>” >> $CALLFILE1
chown $CALLUSER:$CALLUSER $CALLFILE1
chmod 664 $CALLFILE1
echo “move”
echo moving $CALLFILE1 to $OUTGOING
mv $CALLFILE1 $OUTGOING
else echo No MV
rm -f $LOCKFILE
exit
fi
sleep 10m
recip2
}

function recip2 {
if [ -f $MESSAGEFILE ]
then
echo $MESSAGEFILE exists!
echo calling BerkHolz
echo Channel: ZAP/g0/1XXXXXXX083 >> $CALLFILE2
echo MaxRetries: 2 >> $CALLFILE2
echo RetryTime: 60 >> $CALLFILE2
echo WaitTime: 30 >> $CALLFILE2
echo Context: ext-local >> $CALLFILE2
echo Extension: 5682 >> $CALLFILE2
echo Priority: 1 >> $CALLFILE2
echo “CallerID: IT VoiceMail <XXXXXX5682>” >> $CALLFILE2
chown $CALLUSER:$CALLUSER $CALLFILE2
chmod 664 $CALLFILE2
echo moving $CALLFILE2 to $OUTGOING
mv $CALLFILE2 $OUTGOING
else echo No MV
rm -f $LOCKFILE
exit
fi
sleep 10m
recip3
}

function recip3 {
if [ -f $MESSAGEFILE ]
then
echo $MESSAGEFILE exists!
echo calling Gibson
echo Channel: ZAP/g0/1XXXXXXX061 >> $CALLFILE3
echo MaxRetries: 2 >> $CALLFILE3
echo RetryTime: 60 >> $CALLFILE3
echo WaitTime: 30 >> $CALLFILE3
echo Context: ext-local >> $CALLFILE3
echo Extension: 5682 >> $CALLFILE3
echo Priority: 1 >> $CALLFILE3
echo “CallerID: IT VoiceMail <XXXXXX5682>” >> $CALLFILE3
chown $CALLUSER:$CALLUSER $CALLFILE3
chmod 664 $CALLFILE3
echo moving $CALLFILE3 to $OUTGOING
mv $CALLFILE3 $OUTGOING
else echo No MV
rm -f $LOCKFILE
exit
fi
sleep 10m
recip1
}

recip1
rm -f $LOCKFILE

Dial Plan:
exten => 5681,1,Answer
exten => 5681,n,Wait(3)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(X)
exten => 5681,n,SendDTMF(#)
exten => 5681,n,Macro(hangupcall)

exten => 5682,1,Answer
exten => 5682,n,Wait(1)
exten => 5682,n,Macro(user-callerid)
exten => 5682,n,Playback(it-services)
exten => 5682,n,Macro(get-vmcontext,5134)
exten => 5682,n,VoiceMailMain(5134@${VMCONTEXT})
exten => 5682,n,Macro(hangupcall)


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.
Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.