*Update* Please do not use this with Asterisk 1.4 unless you are able to work out the changes needed to it from the help of the others in this thread. If someone wants to do testing on and post a working modified version for use with 1.4 please PM me.
--------
I have been working on a way to have voicemail call my cell phone when a new voicemail is left in my mailbox. I have something that seems to work very good for my use and if anyone else is interested here it is. Please post any improvements you can think of or if you have any problems with it. I am using this as my way to learn asterisk so it may not be pretty and I would love some input from those with experience.
It should be pretty easy to get going. Just paste it into extensions_custom.conf and add the include for custom-vm-notify context to the from-internal-custom context. Then to set up vm notification press *26 and follow the prompts.
[code];**VM Notify Start**
;This is for adding the ability to have asterisk call the user's cell phone when
;a new voicemail is recorded in their mailbox. It is still being tested and needs
;some voice prompts recorded to make it sound better.
;Installation: just copy the text between **VM Notify start** and **VM Notify End**
;and past it into extensions_custom.conf then put "include => custom-vm-notify"
;under the [from-internal-custom] context to enable *26
;the [macro-vm] replaces the one in extensions.conf to make it check if the user has
;VM Notify enabled. The only difference is the "exten => h,1,Macro(vm-notify,${ARG1})"
;line. If the [macro-vm] changes in future versions of freePBX/Trixbox then it needs
;to be copied here to replace this one with the exten h line staying the same.
;Change log
;8-9-06: added a repeat of message when called and short pauses after a button is pressed
;9-29-06: changed gotoif to test for null better
;11-7-06: changed retrytime to 60 seconds
[custom-vm-notify]
; Dial *26 to enable or disable Voicemail Out-calling
exten => *26,1,Answer()
exten => *26,2,Playback(please-enter-your&extension)
exten => *26,3,Read(vmextension,then-press-pound)
exten => *26,4,Set(phonenumber=${DB(vmnotify/${vmextension})})
exten => *26,5,Gotoif($["foo${phonenumber}" = "foo"]?20:10)
exten => *26,10,Playback(enabled&telephone-number&is-set-to)
exten => *26,11,SayDigits(${phonenumber})
exten => *26,12,Background(to-enter-a-diff-number&press-1&or)
exten => *26,13,Background(press-2&for&disabled)
exten => *26,20,Playback(disabled)
exten => *26,21,Background(press-1&for&enabled)
exten => 1,1,Playback(enter-phone-number10)
exten => 1,2,Read(phonenumber,then-press-pound)
exten => 1,3,Set(DB(vmnotify/${vmextension})=${phonenumber})
exten => 1,4,Playback(enabled&telephone-number&is-set-to)
exten => 1,5,SayDigits(${phonenumber})
exten => 1,6,Hangup()
exten => 2,1,DBdel(vmnotify/${vmextension})
exten => 2,2,Playback(disabled)
exten => 2,3,Hangup()
exten => t,1,Hangup()
[macro-vm-notify]
exten => s,1,Set(phonenumber=${DB(vmnotify/${ARG1})})
exten => s,2,Gotoif($["foo${phonenumber}" = "foo"]?0:10) ;see if this vmbox has out-calling enabled
exten => s,10,HasNewVoicemail(${ARG1}) ;check for new voicemails first
;now build a .call file and then move it into the spool
exten => s,111,SetVar(spooldir=/var/spool/asterisk)
exten => s,n,System(echo "Channel: Zap/g0/"${phonenumber} > ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "MaxRetries: 1" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "RetryTime: 60" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "WaitTime: 30" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "Context: macro-vm-notify" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "Extension: vmcall" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "Priority: 1" >> ${spooldir}/${ARG1}.call)
exten => s,n,System(echo "Setvar: vmext="${ARG1} >> ${spooldir}/${ARG1}.call)
exten => s,n,System(mv ${spooldir}/${ARG1}.call ${spooldir}/outgoing/)
;This is where the .call file starts from
exten => vmcall,1,Answer
exten => vmcall,n,NoOp( Waiting for Answer )
exten => vmcall,n,WaitForSilence(2000)
exten => vmcall,n,NoOp( Hello )
exten => vmcall,n,Goto(talk,1)
;Somebody answered or we timed out let them know it's a voicemail
exten => talk,1,Wait(1)
exten => talk,n,Background(this-is-the-voice-mail-system)
exten => talk,n,Background(to-log-in-to-voice-mail)
exten => talk,n,Background(press-1)
exten => talk,n,Background(or)
exten => talk,n,Background(to-hang-up)
exten => talk,n,Background(press-2)
;Wait a little bit then repeat the message
exten => talk,n,Wait(3)
exten => talk,n,Background(this-is-the-voice-mail-system)
exten => talk,n,Background(to-log-in-to-voice-mail)
exten => talk,n,Background(press-1)
exten => talk,n,Background(or)
exten => talk,n,Background(to-hang-up)
exten => talk,n,Background(press-2)
;drop them into the voicemail system
exten => 1,1,Wait(1)
exten => 1,n,VoiceMailMain(${vmext}@default)
;they don't want to talk to us
exten => 2,1,Wait(1)
exten => 2,n,Playback(vm-goodbye)
exten => 2,n,Hangup
;They must be ignoring us
exten => t,1,Hangup
; copied macro-vm from extensions.conf so we could add the h extension to start the notify
;
[macro-vm]
exten => s,1,Macro(user-callerid)
exten => s,n,Set(VMGAIN=${IF($["foo${VM_GAIN}"!="foo"]?"g(${VM_GAIN})":"")})
exten => s,n,Goto(s-${ARG2},1)
exten => s-BUSY,1,NoOp(BUSY voicemail)
exten => s-BUSY,n,Macro(get-vmcontext,${ARG1})
exten => s-BUSY,n,Voicemail(${ARG1}@${VMCONTEXT}|b${VMGAIN}) ; Voicemail Busy message
exten => s-BUSY,n,Goto(exit-${VMSTATUS},1)
exten => s-DIRECTDIAL,1,NoOp(DIRECTDIAL voicemail)
exten => s-DIRECTDIAL,n,Macro(get-vmcontext,${ARG1})
exten => s-DIRECTDIAL,n,Voicemail(${ARG1}@${VMCONTEXT}|${VM_DDTYPE}${VMGAIN})
exten => s-DIRECTDIAL,n,Goto(exit-${VMSTATUS},1)
exten => _s-.,1,Macro(get-vmcontext,${ARG1})
exten => _s-.,n,Voicemail(${ARG1}@${VMCONTEXT}|u${VMGAIN}) ; Voicemail Unavailable message
exten => _s-.,n,Goto(exit-${VMSTATUS},1)
exten => o,1,Background(one-moment-please) ; 0 during vm message will hangup
exten => o,n,GotoIf($["foo${FROM_DID}" = "foo"]?from-pstn,s,1:from-pstn,${FROM_DID},1)
exten => a,1,Macro(get-vmcontext,${ARG1})
exten => a,n,VoiceMailMain(${ARG1}@${VMCONTEXT})
exten => a,n,Hangup
exten => exit-FAILED,1,Playback(im-sorry&an-error-has-occured)
exten => exit-FAILED,n,Hangup()
exten => exit-SUCCESS,1,Playback(goodbye)
exten => exit-SUCCESS,n,Hangup()
exten => exit-USEREXIT,1,Playback(goodbye)
exten => exit-USEREXIT,n,Hangup()
exten => t,1,Hangup()
exten => h,1,Macro(vm-notify,${ARG1}) ; this will start the vm-notification macro when the call is done
; get the voicemail context for the user in ARG1
;**VM Notify End**
[/code]
Member Since:
2006-05-31