VoIPowering Your Office with Asterisk: SOHO VoIP, Part 4


In Parts 1, 2 and 3, we set up Asterisk as a PBX for four PSTN lines. We set up incoming and outgoing calling and restricted outgoing calls to authorized users only. Our fine example users Alrac, Stan and Ollie still need voice-mail. Our mission today is to give it to them.

Setting Up Voice-mail
Voice-mail is configured in /etc/asterisk/voice-mail.conf. The values you want are mailbox_number
=> password, username
, plus optional e-mail, phone, or pager, because Asterisk can forward voice-mails or notifications to almost any device. Usually the mailbox number is the same as the extension number, but it can be anything you want&#151a different number or even a name:

[local-vm-users]
250 => 1234,Alrac Smith,alrac@fooindustries.net
251 => 3456,Stan Laurel,stan@fooindustries.net
252 => 4567,Ollie Hardy,ollie@fooindustries.net
While you’re editing voice-mail.conf, set
servere-mail=asterisk to whatever is appropriate for your server. This is what will appear in the “send” line when Asterisk e-mails users voice-mail notifications.

Another popular option is attach=yes, which will attach a sound file of the voice-mail message to e-mail. This can also be configured on a per-user basis, like this:

250 => 1234,Alrac Smith,alrac@fooindustries.net|attach=yes

Next, you need to change extensions.conf by adding the new voice-mail boxes to each user. This builds on the example from Part 3 article. We’ll use our old friend Alrac to illustrate:

[local-users]
exten => 250,1,Dial(SIP/alrac,10,r)
exten => 250,2,Voice-mail(u250@local-vm-users)
exten => 250,dial+101,Voice-mail(b250@local-vm-users)
This introduces a number of new options. “10” means the line will ring for ten seconds before going to the next priority. “r” tells Asterisk to play a ringing sound.

“u250@local-vm-users” sends the caller to voice mailbox 250 if there is no answer and plays the “unavailable” message, using the [local-vm-users] voice-mail context.

“b250@local-vm-users” sends the caller to voice mailbox 250 on a busy signal and plays the “busy” message. Asterisk comes with prefab “unavailable” and “busy” messages, or users can record their own.

There is a quirk of numbering in the Dial application; it sends callers to priority n+ 101 on a busy signal. Specifying “Dial” saves you the hassle of trying to figure out the correct value, which as your configuration files expand, becomes a real pain.

Any messages left by callers are stored in /var/spool/asterisk/voice-mail/[context]/[mailbox]/INBOX/.

Retrieving messages
You need to set up an extension in
extensions.conf so users can fetch their messages. This example sets up extension 500 for fetching voice-mail, using the Voice-mailMain application. Users will have to dial 500, then enter their mailbox numbers and passwords:

exten => 500,1,Voice-mailMain()
Then just follow the prompts.

Recording Voice-mail Greetings
Most folks want their own customized, personal voice-mail greeting. No problem, because the Voice-mailMain application handles this as well. Again, just dial in and follow the prompts.

Recording Custom Prompts
Even though Asterisk comes with hundreds of sound files for every possible occasion (/var/lib/asterisk/sounds/), you’ll still want to record your own every now and then. There is a whole subculture of avid telephony sound aficionados who use all manner of sophisticated software and hardware, and they know things like every digital music file format in existence, kilohertzes and megahertzes, compression, sampling rates, normalization and all kinds of stuff. While it’s fun and useful to know as much as your average professional sound engineer, it’s not necessary when all you want to do is record Asterisk prompts.

All you need is a telephone with decent sound quality, like a good hardphone, a legacy analog phone, a good microphone and sound card, or a good-quality USB headset and the Asterisk Record application. First configure an extension in under the [local-users] context in extensions.conf for recording new sound files:

;record new voice files
Exten => 501,1,Wait(2)
Exten => 501,n,Record(/tmp/asterisk-recording:gsm)
Exten => 501,n,Wait(2)
Exten => 501,n,Playback(/tmp/asterisk-recording)
Exten => 501,n,wait(2)
Exten => 501,n,Hangup
Pick up a phone and dial 501. After two seconds you’ll hear a beep. Record your message, and then poke the pound key when you’re finished. Asterisk will then play back the new file. You may re-record it as many times as you like, until it has reached a state of suitable shiny perfection, though you’ll have to re-dial the extension to re-record. This is very simple and works fine for a lot of folks; next week we’ll add refinements and more user options.

Then you need to copy the file into its permanent home. This can be
/var/lib/asterisk/sounds/, or a directory of your own choosing like
/var/lib/asterisk/sounds/koolkustomsounds/, or wherever you like:

# cp /tmp/asterisk-recording:gsm /var/lib/asterisk/sounds/maingreeting.gsm

In our next couple of installments we’ll learn the quick way to play Asterisk sound files, more ways to update custom prompts and how to create a nice automated attendant to answer and route incoming calls.

ResourcesVoIPowering Your Office with Asterisk: SOHO VoIP; terminology explained
VoIPowering Your Office with Asterisk: SOHO VoIP part 2; connecting legacy PSTN lines to Asterisk, inbound calling
VoIPowering Your Office with Asterisk: SOHO VoIP, Part 3; setting up outbound calls safely
VoIP-Info.org
NANPA: North American Numbering Plan Administration

Adapted from voipplanet.com.

Do you have a comment or question about this article or other small business topics in general? Speak out in the SmallBusinessComputing.com Forums. Join the discussion today!

Previous article
Next article

Must Read

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends, and analysis.