Thursday, March 1, 2007

Centralizing Asterisk Voicemail Services

* This posting assumes you are somewhat familiar with Asterisk. You should be able to setup Asterisk, register a few phones, and make calls inbetween them. You also should be familiar with interconnecting two or more Asterisk servers via SIP or IAX.

One of the challenges of deploying Asterisk in an enterprise with multiple locations is voicemail. If the local Voicemail() application is used at each site mailboxes will scattered across multiple servers. Users won't be able transfer voicemail to users outside of their server, several numbers will be needed to call in to retrieve voicemail, and if a web interface to retrieve voicemail is to be used several web addresses will need to be maintained. Additionally, if the WAN links are low bandwidth the backup of voicemail data to the main site could be very slow.

Centralizing voicemail services can help solve these problems. There is no configuration setting to have Asterisk utilize another server for voicemail services, but it can be easily configured through the dialplan. This question comes up from time to time on the listserv (once asked by me), so I figured I would document the solution I used.

The first step is to create connections from the various servers that need voicemail services to the server that will act as the centralized voicemail server. For a company with locations in Denver and Colorado Springs it will look something like the diagram below. It doesn't matter if you use IAX or SIP. There are plenty of "How To's" on how to trunk multiple servers together so I'm not going to re-invent that tutorial wheel.


Ok, now that you have your phone servers connected to the voicemail server it's time to tell the phone server to send unanswered or busy calls to the voicemail server. This is accomplished by making two small changes to the stdexten macro in extensions.conf.

Change this:

exten => s-NOANSWER,1,Voicemail(u${ARG1})
exten => s-NOANSWER,2,Goto(default,s,1)
exten => s-BUSY,1,Voicemail(b${ARG1})
exten => s-BUSY,2,Goto(default,s,1)


To this (I've named the IAX connection to the voicemail server "toVMail"):

exten => s-NOANSWER,1,Dial(IAX2/toVMail/u${ARG1})
exten => s-NOANSWER,2,Goto(default,s,1)
exten => s-BUSY,1,Dial(IAX2/toVMail/b${ARG1})
exten => s-BUSY,2,Goto(default,s,1)

We're now sending our busy and unanswered calls to the central voicemail server, but they have nothing to do once they get there. We need to create some extensions so we can
send the incoming calls to the Voicemail application. Put the following lines in extensions.conf of the voicemail server. Be sure to put them under the context that your server to server trunks are located in. I'm using a context called "incoming". Also note that I'm only using four digit extensions. Adjust for your application as needed.

[incoming]
exten => _bXXXX,1,Voicemail(${EXTEN}@default)
exten => _uXXXX,1,Voicemail(${EXTEN}@default)


Next an entry to allow people to call in and retrieve voicemail. I also put this under the "incoming" context and have designated the extension as 4000.

exten => 4000,1,VoiceMailMain(@default)

Be sure to setup the mailboxes you wish to host in voicemail.conf or by using the realtime architecture.

Lastly, don't for
get to setup your phone servers to send extension 4000 to the voicemail sever. Make some test calls to be sure everything is working.

Please note that the Message Waiting Indicator, aka MWI, will not work on your phones. Turning MWI on and off works between the phone and the server it is registered to. Never fear though, there are some tricks to make this happen that I'll go over in a later posting when I'm not so tired.

10 comments:

  1. Do you have to use a seperate voicemail server or could your Devner server do the voice mail for Denver and Colorado Springs?

    ReplyDelete
  2. Just thought I would say thanks for making this guide. I got our servers at work setup using this method.

    ReplyDelete
  3. A more elegent and scalable way to do this would be to use voicemail ODBC storage as outlined in http://www.voip-info.org/wiki/view/Asterisk+Voicemail+ODBC+storage

    ReplyDelete
  4. in response to anonymous posting, it depends on your application.

    Would you really want to use ODBC across vpn over the internet on dsl quality links? Doubt it.

    ReplyDelete
  5. i have a mwi problem. i want to use asterisk strictly as a voicemail box thats connected via a sip trunk to avaya ses box. the mwi signal is not showing up in any of the phones.

    the mwi signal works fine if the extension is created on the asterisk itself. so i know the voicemail portion is working properly. it's just not working like the way i want it to.

    any help is much appreciated.

    ReplyDelete
  6. have though about the idea of letting each server keep hosting there VM and instead of centraling the sevice figuring away for Dundi to lloup for other voicemail boxes so you can forward outside your local sever the messages
    Mikey M

    ReplyDelete
  7. Hi there!

    Will I be able to work with centralized directory ( http://www.voip-info.org/wiki/view/Asterisk+cmd+Directory ) in case I host VoiceMail on a separate machine? What should be the config, in your opinion?..

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. Memory sure is becoming cheaper these days. I'm curious as to when we will finally hit the ratio of 1c to 1 Gig.

    I'm quietly waiting for the day when I will finally be able to afford a 20 TB harddrive, hahaha. But for now I guess I will be satisfied with having a 16 GB Micro SD Card in my R4i.

    (Posted using SKu2 for R4i Nintendo DS.)

    ReplyDelete