Section 6.4. Voicemail

6.4. Voicemail

One of the most popular (or, actually, unpopular) features of any modern telephone system is voicemail . Naturally, Asterisk has a very flexible voicemail system. Some of the features of Asterisk's voicemail system include:

  • Unlimited password-protected voicemail boxes, each containing mailbox folders for organizing voicemail

  • Different greetings for busy and unavailable states

  • Default and custom greetings

  • The ability to associate phones with more than one mailbox and mailboxes with more than one phone

  • Email notification of voicemail, with the voicemail optionally attached as a sound file [*]

    [*] No, you really don't have to pay for this; and yes, it really does work.

  • Voicemail forwarding and broadcasts

  • Message-waiting indicator (flashing light or stuttered dial tone) on many types of phones

  • Company directory of employees , based on voicemail boxes

And that's just the tip of the iceberg! In this section, we'll introduce you to the fundamentals of a typical voicemail setup.

The voicemail configuration is defined in the configuration file called voicemail.conf . This file contains an assortment of settings that you can use to customize the voicemail system to your needs. Covering all the available options in voicemail.conf would be beyond the scope of this chapter, but the sample configuration file is well documented and quite easy to follow. For now, look near the bottom of the file, where voicemail contexts and voicemail boxes are defined.

Just as dialplan contexts keep different parts of your dialplan separate, voicemail contexts allow you to define different sets of mailboxes that are separate from one another. This allows you to host voicemail for several different companies or offices on the same server. Voicemail contexts are defined in the same way as dialplan contexts, with square brackets surrounding the name of the context. For our examples, we'll be using the [default] voicemail context.

6.4.1. Creating Mailboxes

Inside each voicemail context, we define different mailboxes. The syntax for defining a mailbox is:

   mailbox   =>   password   ,   name   [,   email   [,   pager_email   [,   options   ]]] 

Let's explain what each part of the mailbox definition does:



mailbox

This is the mailbox number. It usually corresponds with the extension number of the associated set.



password

This is the numeric password the mailbox owner will use to access her voicemail. If the user changes her password, the system will update this field in the voicemail.conf file.



name

This is the name of the mailbox owner. The company directory uses the text in this field to allow callers to spell usernames.



email

This is the email address of the mailbox owner. Asterisk can send voicemail notifications (including the voicemail message itself) to the specified email box.



pager_email

This is the email address of the mailbox owner's pager or cell phone. Asterisk can send a short voicemail notification message to the specified email address.



options

This field is a list of options that sets the mailbox owner's time zone and overrides the global voicemail settings. There are nine valid options: attach , serveremail , tz , saycid , review , operator , callback , dialout , and exitcontext . These options should be in option = value pairs, separated by the pipe character ( ). The tz option sets the user's time zone to a time zone previously defined in the [zonemessages] section of voicemail.conf , and the other eight options override the global voicemail settings with the same names .

A typical mailbox definition might look something like this:

 101 => 1234,Joe Public,jpublic@somedomain.com,jpublic@pagergateway.net,     tz=centralattach=yes 

Continuing with our dialplan from the last chapter, let's set up voicemail boxes for John and Jane. We'll give John a password of 1234 and Jane a password of 4444 (remember, these go in voicemail.conf , not extensions.conf ):

 [default]     101 => 1234,John Doe,john@asteriskdocs.org,jdoe@pagergateway.tld     102 => 4444,Jane Doe,jane@asteriskdocs.org,jane@pagergateway.tld 

6.4.2. Adding Voicemail to the Dialplan

Now that we've created mailboxes for Jane and John, let's allow callers to leave messages for them if they don't answer the phone. To do this, we'll use the VoiceMail( ) application.

The VoiceMail( ) application sends the caller to the specified mailbox, so that he can leave a message. The mailbox should be specified as mailbox @ context , where context is the name of the voicemail context. The mailbox number can also be prefixed by the letter b or the letter u . If the letter b is used, the caller will hear the mailbox owner's busy message. If the letter u is used, the caller will hear the mailbox owner's unavailable message (if one exists).

Let's use this in our sample dialplan. Previously, we had a line like this in our [internal] context, which allowed us to call John:

 exten => 101,1,Dial(${JOHN},,r) 

Now, let's change it so that if John is busy (on another call), it'll send us to his voicemail, where we'll hear his busy message (don't forget that the Dial( ) application sends the caller to priority n +101 if the dialed line is busy):

 exten => 101,1,Dial(${JOHN},,r)  exten => 101,102,VoiceMail(b101@default)  

Next , let's add an unavailable message that the caller will be played if John doesn't answer the phone within 10 seconds. Remember, the second argument to the Dial( ) application is a timeout. If the call is not answered before the timeout expires , the call is sent to the next priority. Let's add a 10-second timeout, and a priority to send the caller to voicemail if John doesn't answer in time:

  exten => 101,1,Dial(${JOHN},10,r)     exten => 101,2,VoiceMail(u101@default)  exten => 101,102,VoiceMail(b101@default) 

If we add these two new priorities and a timeout argument to the Dial( ) application, callers will get John's voicemail (with the appropriate greeting) if John is either busy or unavailable. A slight problem remains, however, in that John has no way of retrieving his messages. Let's remedy that.

6.4.3. Accessing Voicemail

Users can retrieve their voicemail messages, change their voicemail options, and record their voicemail greetings by using the VoiceMailMain( ) application. In its typical form, VoiceMailMain( ) is called without any arguments. Let's add extension 500 to the [internal] context of our dialplan so that internal users can dial it to access their voicemail messages:

 exten => 500,1,VoiceMailMain( ) 

6.4.4. Creating a Dial-by-Name Directory

One last feature of the Asterisk voicemail system we should cover is the dial-by-name directory . This is created with the Directory( ) application. This application uses the names defined in the mailboxes in voicemail.conf to present the caller with a dial-by-name directory of the users.

Directory( ) takes up to three arguments: the voicemail context from which to read the names, the optional dialplan context in which to dial the user, and an option string (which is also optional). By default, Directory( ) searches for the user by last name, but passing the f option forces it to search by first name instead. Let's add two dial-by-name directories to the [incoming] context of our sample dialplan, so that callers can search by either first or last name:

 exten => 8,1,Directory(default,incoming,f)     exten => 9,1,Directory(default,incoming) 

If callers press 8, they'll get a directory by first name. If they dial 9, they'll get the directory by last name.



Asterisk. The Future of Telephony
Asterisk: The Future of Telephony: The Future of Telephony
ISBN: B0026OR3OO
EAN: N/A
Year: 2001
Pages: 380

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net