Asterisk and Voicemail

From Ekiga
Jump to: navigation, search

Asterisk comes with a lot of good features. One of them is voicemail (”answering machine”). This means that if somebody calls you and you are either talking to somebody else or you are otherwise not available then Asterisk can answer on your behalf and give the calling party the possibility to leave a message for you. Furthermore you can configure Asterisk to send you an e-mail with the recorded message attached as a wav-file, so you don't have to check you (voice) mailbox regularly.

To top it all off all of this comes a standard with Asterisk. You do not to do anything else than start using it.

This how-to need to have done previous steps; it means you have to ensure Asterisk is connected to some VoIP Service like this: Connecting Asterisk to ekiga.net.

First you have to define a mailbox. This is done in Asterisk's voicemail.conf file:

[general]
; Choose a format to save voicemails as
format=wav
;
; if you set this to yes, the voicemail is attached as a file
; (so you can play it from your email directly,
; you may  want to turn this off if your email is on another
; server or limited for space or for various other reasons.
;
attach=yes
;
; Each mailbox is listed in the form
;  <mailbox>=<password>,<name>,<email>,<pager_email>
; if the e-mail is specified, a message will be sent when a
; message is received, to the given mailbox.
; If pager is specified, a message will be sent there as
; well.
;
[default]
101 => 1234,Bent,YOU@YOUR_EMAIL.TLD

Here, 101 is your extension number, 'Bent' is any name and 1234 is a password you use when you access the voice mailbox to check messages. How to access the mailbox will be covered later in this note.

Notice the attach=yes. This ensures that the voice message is also sent to you as an e-mail with the voice message attached, in this case as a wav file.


Asterisk has a macro facility. I will use that in the following to give an example of how to use it. It may seem as overkill in this example, but it will be very handy when you have several SIP clients attached to your Asterisk.

In order to use the mailbox we have just defined, we will modify the dial plan in extensions.conf.
First a section to define the macro. I'll throw a fairly advanced macro at you without going into too much detail about it. If you want more details about what is going on, consult the section on macros (pp 110 – 112) in the on-line book.

[macro-voicemail]
exten => s,1,Dial(${ARG1},20)
exten => s,2,Goto(s-$DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(u${MACRO_EXTEN})
exten => s-NOANSWER,2,Hangup()
exten => s-BUSY,1,Voicemail(b${MACRO_EXTEN})
exten => s-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-NOANSWER,1)

Basically, what the macro does is this: First it dials your number. Depending on the outcome of this (reported in the variable DIALSTATUS) it either calls the Voicemail application with the 'u' flag ('unavailable') set or the 'b' flag ('busy') set. This results in two different greeting messages depending on how you got here. When the caller has finished recording the message, the calls is terminated (Hangup).

In the dial plan proper (extensions.conf) you augment the [home] section to read:

[home]
exten => 101,1,Macro(voicemail,SIP/101)
exten => 102,1,Macro(voicemail,SIP/102)
exten => 103,1,Macro(voicemail,SIP/103)
exten => 600,1,Answer()
exten => 600,2,Playback(demo-echotest) ; Let them know what is going on                                        
exten => 600,3,Echo()                  ; Do the echo test
exten => 600,4,Playback(demo-echodone) ; Let them know it is over                                      
exten => 600,5,Hangup()

As you can see, all you need is one line per SIP client. Neat, isn't it? The above of course assumes that you have three SIP clients connected to your Asterisk.

The final touch would be to add a possibility to access the voice mailbox from your Ekiga. This is easily done: You add the following two lines to the [home] context in extensions.conf:

; Voicemail
exten => 8,1,VoiceMailMain(s${CALLERIDNUM})
exten => 8,2,Hangup

Now, if you dial '8' you will be met with a greeting from the Voicemail application and taken through a menu with several choices. Try it and be amazed. You can of course select any extension as the access number for the voicemail system.

Bent 19:34, 15 November 2006 (CET)

Personal tools