Quantcast
Channel: [ N O C T E R N I T Y ] » dial plan
Viewing all articles
Browse latest Browse all 3

Playing with Asterisk (4/?) – Voice mail

$
0
0

Even in the context of a home set-up, voice mail is a "must-have" feature. My idea is to have a set of voicemail boxes - one per person, and a global "family" mailbox. Ideally, local phones / softphones should be able to access the corresponding mailboxes (the mailbox of the phone's owner and the family mailbox) without having to type a password, but other mailboxes should still be available with an identifier and passwords on all internal phones.

Basic set-up

Before trying to do that, I created a simple set-up that only worked for one of the test lines, and always required credentials to access. The first thing to configure is the voice mail application itself. I had to re-enable the app_voicemail.so module, and write a configuration file for the application (aptly named voicemail.conf). I also wanted email notifications with the message attached. Finally, I noticed the options of having the system force setting greeting messages and password when initially logging in, and that seemed interesting. Here is the resulting configuration file.

[general]
format=wav49|gsm|wav

serveremail=phones@nocternity.net
fromstring=Téléphonie
attach=yes
emaildateformat=%A, %d %B %Y at %H:%M:%S
sendvoicemail=yes
charset=UTF-8

maxmsg=100
maxsecs=180
minsecs=3 
maxgreet=90
maxsilence=2 
silencethreshold=128

moveheard=yes
review=yes
forcename=yes
forcegreetings=yes

maxlogins=3
minpassword=4 

[zonemessages]
; Empty

[default]
1 => 1,Emmanuel Benoît,tseeker@nocternity.net

I left the zonemessages section empty, because I really don't care about that feature; as for the password, it is set to "1" on my user in order to cause the voice mail application to force me to set it when I connect to it.

The next thing to configure was the dial plan. I had to modify one of the extensions for the internal phones in order to have it fall back on the voice mail when necessary. I initially used the following configuration:

exten => 100,1,Dial(${DIAL_TEST1},10,tT)
	exten => 100,n,Voicemail(1@default)
	exten => 100,n,Hangup()

The new argument to Dial() simply indicates the maximal ringing time before falling back to the voice mail. In this case, "ring for 10 seconds and fall back to the voice mail if there is no response".

I also had to add an extension that would give users (namely, me) access to their voice mail:

exten => 666,1,VoiceMailMain()
	exten => 666,n,Hangup()

Finally, I modified the voice mail fall-back  in order to play either the "busy" greeting or the "unavailable" greeting, depending on the Dial() application's result. This took me a while to figure out due to the somewhat twisted syntax.

exten => 100,1,Dial(${DIAL_TEST1},10,tT)
		exten => 100,n,Voicemail(1@default,${IF($["${DIALSTATUS}" = "BUSY"]?b:u)})
		exten => 100,n,Hangup()

Note about voice mail notifications

I tried setting up voice mail notifications for the SIP clients, by adding the following to their section in the sip.conf file:

mailbox=1@default

However, linphone does not appear to support this (it causes a warning on Asterisk's side), and the other free (not as in beer) softphones I tried had a tendency to blow up in my face.

General set-up

I needed to make quite a few changes in order to implement the idea I mentioned in this post's introduction.

Voice mail fall-backs for all phones

First, having a voice mail fall-back for all phones. In order to do that without the configuration becoming a copy-pasted mess, I had to learn about macros, which are basically dial plan sections which can be invoked from other areas of the dial plan. Here's the macro I used for the voice mail fall-back:

[macro-internal-call]

exten => s,1,Dial(${ARG1},10,tT)
	exten => s,n,Voicemail(${ARG2}@default,${IF($["${DIALSTATUS}" = "BUSY"]?b:u)})
	exten => s,n,Hangup()

This macro takes two arguments: the phone(s) to dial, and the voice mail box to fall back to. It then needs to be used in place of the internal phones' extensions:

exten => 100,1,Macro(internal-call,${DIAL_TEST1},1)
exten => 101,1,Macro(internal-call,${DIAL_TEST2},1)
exten => 102,1,Macro(internal-call,${DIAL_TEST3},2)

(I'd added box #2 and #9 in the meantime.) I also had to "emulate" that family voice mail box. I simply added the following extension:

exten => 999,1,Macro(internal-call,${DIAL_TEST1}&${DIAL_TEST2}&${DIAL_TEST3},9)

... which will cause all phones to ring when dialed, and fall back on mailbox #9.

Password-less access to voice mail

The next step was to allow clients to access their own voice mail, as well as the global one, without password. I started by changing the contexts for SIP clients to something that corresponds to their owners in sip.conf:

; ...

[test1](test-template)
        context=phones-tseeker
        ;...

[test2](test-template)
        context=phones-tseeker
        ;...

[test3](test-template)
        context=phones-ju
        ;...

Of course, I then needed to define these contexts in the dial plan. However, I wanted to avoid having to copy/paste common configuration; this is where the include thing comes in. It allows the extensions listed in another section to be considered. The modified extensions.conf looked somewhat like this:

[phones-tseeker]

        include => tests
        include => phones

[phones-ju]

        include => tests
        include => phones

[tests]

        ; Various 8378-prefixed tests here

[phones]

exten => 100,1,Macro(internal-call,${DIAL_TEST1},1)
; etc...

exten => 666,1,VoiceMailMain()
        exten => 666,n,Hangup()

Finally, I added the lines allowing direct access to the voice mail to each "owner-specific" section:

[phones-tseeker]

        include => tests
        include => phones

exten => 700,1,VoiceMailMain(1@default,s)
        exten => 700,n,Hangup()
exten => 701,1,VoiceMailMain(9@default,s)
        exten => 701,n,Hangup()

[phones-ju]

        include => tests
        include => phones

exten => 700,1,VoiceMailMain(2@default,s)
        exten => 700,n,Hangup()
exten => 701,1,VoiceMailMain(9@default,s)
        exten => 701,n,Hangup()

Some thoughts for later

I think it would be best if all internal numbers were prefixed with something that is not associated with outgoing calls at all. The "star" key seems like a decent prefix. In addition, it would be a good idea to make the various extensions and voice mail box numbers a little more rational and consistent.

Related Images:

Gallery not found. Please check your settings.

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images