Have code. Will travel.

Setting up voicemail in Asterisk

In order to make a better product, we need to add a little "expected" functionality to Banana Phone; namely, voicemail.

Voicemail in Asterisk is fairly straightforward to setup. It comes with the standard features one might expect: password logins, save/delete, etc. Plus, we can add our own functionality to it, because Asterisk is good for it like that.

Add in some more sound files

We'll start by downloading the set of sound files that Asterisk needs to make it's voicemail system work. Start by ssh'ing into our Banana Phone server as the 'banana' user and navigate to the 'asterisk_resources/sounds' directory we created.

cd ~/banana_phone/asterisk_resources/sounds

Now run this wget command to download the standard set of Asterisk sound files from the Asterisk web site. They will be tarred up, so we'll uncompress them too.

[general]
; Formats for writing Voicemail
format=wav49|gsm|wav
;
; Who the e-mail notification should appear to come from
serveremail=asterisk
;serveremail=asterisk@linux-support.net
; Should the email contain the voicemail as an attachment
attach=no
; Maximum number of messages per folder. If not specified, a default value
; (100) is used. Maximum value for this option is 9999. If set to 0, a
; mailbox will be greetings-only.
maxmsg=100
; Maximum length of a voicemail message in seconds
maxsecs=180
; Minimum length of a voicemail message in seconds for the message to be kept
; The default is no minimum.
minsecs=3
; Maximum length of greetings in seconds
;maxgreet=60
; How many milliseconds to skip forward/back when rew/ff in message playback
skipms=3000
; How many seconds of silence before we end the recording
maxsilence=7
; Silence threshold (what we consider silence: the lower, the more sensitive)silencethreshold=128
; Max number of failed login attempts
maxlogins=8
;
; Move heard messages to the 'Old' folder automagically. Defaults to on.
moveheard=yes
; Set the date format on outgoing mails. Valid arguments can be found on the
; strftime(3) man page
;
; Default
emaildateformat=%A, %B %d, %Y at %r
; 24h date format
;emaildateformat=%A, %d %B %Y at %H:%M:%S
;
; Default for pager use
pagerdateformat=%A, %B %d, %Y at %r
;
sendvoicemail=yes ; Allow the user to compose and send a voicemail while inside
;
;
[zonemessages]eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
pacific=America/LosAngeles|'vm-received' q 'digits/at' H N 'hours'military=Zulu|'vm-received' q 'digits/at' H N 'hours''phonetic/z_p'european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
;
;
[banana-vm]PhoneHandset=> 3333,Montel Williams,,tz=pacific|maxmsg=30
;
;

This is minimal configuration for voicemail in Asterisk. You can look at the settings individually if you so desire and see what each one does. The lines we want to look at are lines 54 and 55.

On line 54, we are naming a voicemail box called "banana-vm", similar to how we name contexts in extensions.conf.

On line 55, we associate this voicemail box with our 'PhoneHandset' endpoint. We then set a voicemail password, a name for the person using the mailbox, and some extra options for timezone and how many messages the box can hold.

You can check to see that your voicemail is setup properly by jumping into the Asterisk debug console and reloading the voicemail configuration.

asterisk -rvvvvv
voicemail reload

Edit extensions.conf

Now we will adjust extensions.conf to allow for two things:

Let us dial into our voicemail menu from the phone to hear/delete/save voicemails

Have calls go to voicemail if the phone doesn't get answered

Have a look at the following snippet from this new extensions.conf. Notice the changes we've made on just a few lines of our dialplan:

On line 2, we've added a new extension to the PhoneHandset context, 222. Then on line 3, we add in the VoiceMailMain app and reference "@banana-vm", the voicemail box we setup in voicemail.conf.

This lets us dial "222" from our phone and will drop us into the voicemail menu. To record a voicemail greeting, dial 222, wait for the prompt to enter the password, and

Check out line 24. After the Dial command, if the phone isn't picked up, it will then push the call to the voicemail box defined for PhoneHandset, which points to "banana-vm"

Conclusion

So now Banana Phone has voicemail.

My grandma did say it'd be nice if she had a way of seeing if any new messages were waiting for her. I thought that might be a good chance for me to test out this idea I had for text message notifications of waiting voicemails at home, but that's another tutorial all together.