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.
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.
Now Asterisk has the sound files it needs for us to use the VoiceMail app in our dialplan.
Move into the /etc/asterisk directory and change the name of the current voicemail.conf to voicemail.conf.bk.
Now create a new voicemail.conf
Paste to following into voicemail.conf:
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.
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"
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.
I was also interested in speech recognition . . .