Creating Failover Voicemail

Ok Here is my scenario:
I currently have asterisk 1.6 connected to Exchange 2007 UM. When a extension doesn’t answer I use this custom config to send the caller to the exchange mailbox instead of the asterisk mailbox.

exten => s,1,NoOp(Entering custom-exchangevm for a call to ${DNID})
exten => s,n,Set(EXTTOCALL=50)
exten => s,n,NoOp(Sending to Voicemail box ${EXTTOCALL})
exten => s,n,SIPAddHeader(Diversion: ;reason=no-answer;screen=no;privacy=off)
exten => s,n,Dial(SIP/Exchange/999)
exten => s,n,Hangup

The issue for me is that Exchange 2007 UM goes offline every now and then and gives the “All circuits are busy” message to the caller and hangs up. So I’m wondering what can I add to this custom extension that will try the SIP/999 first then if its unavailable it will send them to the regular trixbox mailbox for the dialed extension.
Any insight would be great.



Simplest way is to use the devstate function, if you are on 1.4 there is a backport to this, then you can check the status of the sip peer before calling it and depending on state handle the call appropriately


I am running Asterisk 1.6 not 1.4. I imagine this feature is included since it was in a previous version. My problem is that I don’t know much about the commands. I have done everything through trial and error and what I’ve found on the internet. This particular custom extension code was found on another website and I tweaked it to work with my system. Really I don’t know where to begin. I figured it would just be a line or two in the custom extension to says “if call fails transfer to CALLEXT voicemail”.