Section 14.4. Voice Mail and IVR


14.4. Voice Mail and IVR

Voice mail and interactive voice response systems have always been soft-driven, because they embody business logic. They need to be customizable in ways that a traditional phone switch doesn't. Consequently, voice mail and IVR have been at home on the microcomputer server for a lot longer than call switching has been. Early IVR and voice mail software packages ran on Solaris, OS/2, and Windows NT.

The voice mail/IVR server would be connected to the PBX by dedicated trunks, usually a T1 interface or a handful of FXO/FXS links. The PBX would assign those trunks special extensions, and when a caller needed voice mail or IVR function, his station would be bridged with the trunk connected to the voice mail/IVR server. In some cases, especially on very high-end chassis, the voice mail/IVR and PBX would be housed in one unit.

Today, the IVR and PBX systems are both soft-driven and can therefore be maintained at the same place. Dedicated trunks are no longer needed to link PBX to IVR as long as you choose a platform that integrates them on the same server, unless you design it so they're housed separately for load-management or logistical reasons.

Asterisk offers built-in IVR functions, which are issued in extensions.conf or through the Asterisk Gateway Interface. Probably the most oft-used IVR application in Asterisk is its remarkably powerful voice mail system, Comedian Mail.

14.4.1. Project 14.3. Build a Custom Voice Mail System

14.4.1.1 What you need for this project:
  • Asterisk

One of Asterisk's most compelling features is its voice mail server. In fact, you could use Asterisk voice mail as a transition piece as you move your current PBX to VoIP. Chances are good that Asterisk offers more voice mail functionality than your current voice mail system, anyway. Once you transitioned your voice mail to Asterisk, you would be only a dial-plan away from having a full call manager online and ready to handle calls.

But since we've covered call management quite a bit already, let's concentrate solely on voice mail. In Asterisk, the voice mail system is configured by the /etc/asterisk/voicemail.conf file. Like the dial-plan in extensions.conf , the voice mail configuration file establishes contexts. Each voice mail box exists within a certain context, allowing logical separation of subscriber groups, say, on a system that hosts voice mail for several different businesses.

Like extensions.conf , voicemail.conf can use include directives to encompass the content of other files, as long as they contain settings that are valid for the voice mail serverand not some other module. As is the convention elsewhere in Asterisk, the voicemail.conf file begins with a [general] section that defines settings that apply to the entire voice server.

In this project, we'll be customizing Asterisk's voice mail config in order to make it email newly recorded voice messages to different peoples' inboxes. We'll also be customizing the content of the voice mail announcement message that is sent when new voice mails are received.

To get started, let's establish a couple of voice mailboxes in voicemail.conf :

 [default]     201 => 201,John Lennon,jl@oreilly.com,,attach=yestz=mountain     202 => 202,George Harrison,gh@oreilly.com,,attach=nosaycid=yes 

Now, take a look at the format that defines the syntax of this config:

   mailbox   =>   pin   ,   user_name   ,   user_email[   ,   user_pager_email][   ,   option(s)]   

The alphanumeric mailbox must be unique within the voice mail context but can be duplicated elsewhere in the voice mail configuration. The pin is the DTMF string that will be required in order for the subscriber to retrieve messages by phone. The user_name and user_email settings tell the server how to address email-forwarded messages. The user_pager_email setting gives the server a secondary email address that's intended for use with email- interfaced paging and cell phone text messaging networks. Finally, the options setting is a string of pipe-limited options that are outlined in Table 14-1.

Table 14-1. Asterisk voice mail box options

Option

Description

Possible values

tz

Defines the time zone for this subscriber so that timestamps can be localized

Any time zone configured in /usr/share/zoneinfo

attach

Specifies whether or not to attach the sound file of the voice mail message when notifying by email

yes; no

callback

Specifies the dial-plan context to which callers are returned after they've left a message for this subscriber

default

dialout

Specifies the dial-plan context in which subscribers exist if they dial an extension from within the voice mail application

default

operator

Specifies whether or not the user can return to the operator extension by dialing 0 (zero) within the voice mail application

yes; no

review

Specifies whether or not callers to this subscriber can review (listen to and approve or rerecord) messages

yes; no

saycid

Specifies whether the caller ID number of the person who left the message should be announced when the message is played by the subscriber

yes; no


14.4.1.2 Turn on email notification

Enabling notification of new voice mail messages by email is as simple as three steps. First, edit the servermail and fromstring settings in the [general] section of voicemail.conf so that notification messages will come from an appropriate email address like voicemail@yourcompany.com. Second, make sure the local mail routing agent (sendmail) is operational on the voice mail server. Third, enter the email address of each subscriber into her mailbox declaration in voicemail.conf .

14.4.1.3 Attach voice mail sound files to email notifications

Adding attach=yes to the options string in a mailbox declaration will cause recorded messages to be forwarded (as attachments) to the email addresses associated with that mailbox. There's really only one thing you can customize here, and that's the format in which the recorded sounds are encoded. You have three choices wav49 , wav , and gsm . WAV49 is highly compressed and compatible with most client desktops, so it's the recommended format for emailing. Unless you're doing some further processing with an SMTP agent after the message that requires it is sent, there's no reason to use WAV or GSM.

14.4.1.4 Customize the email notification message

The template for the notification email is stored in the ${emailbody} variable, defined in voicemail.conf or one of its includes. You just have to define it. Feel free to mix in any of these system variables while you're at it:



VM_NAME

The name of the subscriber for whom the message was left



VM_DUR

The duration, in seconds, of the message



VM_MSGNUM

The number of the message relative to the subscriber's mailbox



VM_MAILBOX

The mailbox number of the subscriber



VM_CALLERID

The caller ID string for the caller who left the message



VM_DATE

The date and time the message was left, relative to the time zone specified in voicemail.conf for this subscriber

Consider the following emailbody declaration:

 emailbody=Hello ${VM_NAME},\n\nThere is a new voice mail message in mailbox number ${ VM_MAILBOX}. It was left on ${VM_DATE} from ${VM_CALLERID}. To listen to this message, dial 1000 from your desk phone or 216-524-0071 from an outside phone.     \n\nThanks,\nThe voicemail System 

This message would appear more or less as follows , when used to send a voice mail notification:

 Hello John Lennon,     There is a new voicemail message in mailbox number 201. It was left on 7/3/05 12:42:42 from (440) 365-1964. To listen to this message, dial 1000 from your desk phone or 216-524-0071 from an outside phone.     Thanks,     The Voicemail System 

The \n token, common in Unix, starts a new line. If the recorded message were actually attached to the email, we would need to use a different message template, indicating that.

14.4.1.5 Connect the dial-plan to voice mail

Once the voice mail server is set up the way you want it, connecting it to the dial-plan is a snap. First, establish an extension where subscribers can retrieve their messages and manage their mailboxes. This example attempts to plug in the extension number of the caller in order to forgo a prompt to enter their mailbox number, assuming the extension and mailbox numbers match:

 ; extensions.conf     [default]     ...     exten => 1000,1,Voicemailmain(${CALLERIDNUM}) 

If the caller ID doesn't match any mailbox, the subscriber will have a chance to enter his mailbox number. Next , make sure that some extensions trigger the voice mail application:

 ; extensions.conf     [default]     ...     exten => 201,1,Dial(SIP/201,30)     exten => 201,2,Voicemail(201) 

In this case, extension 201 will attempt to ring SIP peer 201 for 30 seconds. If there's no answer, the voice mail greeting for mailbox 201 will be played and the caller will have an opportunity to record a message.

14.4.1.6 Web access to voice mail

Asterisk includes a Perl CGI script ( vmail.cgi ) that you can use to give your voice mail subscribers access to their mailboxes via the Web. This is great for road warriors who may not have direct telephony access to the phone system while they're out and about. By placing the script in Apache's cgi-bin script path and making it executable by the web user, this script works fine for a plain- vanilla install of Asterisk. Figure 14-1 shows what it looks like from a web browser.

Figure 14-1. Asterisk's vmail.cgi allows web-based access to voice mail

14.4.2. Project 14.4. Create Custom Sounds to Interact with Callers

14.4.2.1 What you need for this project:
  • Asterisk

  • A sound recording application (optional)

  • SoX (http://sox. sourceforge .net)

Interactive voice response is the backbone of voice mail, but there's so much more you can do with it. You could replace pen-and-paper time cards and punch clocks. You could use it to perform billing functions, such as collecting a credit card number and storing it in a database. But in order to make all these things cohesive to the caller (the user), your user interface will have to be customized. This means using, and making, sounds.

14.4.2.2 Use a prerecorded sound for a simple paging routine

We'll start with a quick little dial-plan tool that allows us to send quick emails. This will allow us to use one of Asterisk's prerecorded sounds. In this example, we'll build a basic numeric pager. It will screen an incoming call, record the caller's phone number, and email it to an SMTP recipient with instructions to " please call" the number.

 exten => *89,1,Read(PhoneNoallison7/enter-phone-number1010)     exten => *89,2,System('echo Please call ${PhoneNo}.  mail   user   @oreilly.com')     exten => *89,3,Playback(thank-you)     exten => *89,4,Hangup(  ) 

You may also notice output like this in Asterisk's verbose console log when the Read( ) command captures the dialed digits, in accordance with the first priority of extension *89:

 VERBOSE[1122993344]     --User entered '5552345678' 

The Read( ) command plays the enter-phone-number.gsm file and then stores the 10 digits entered in the ${PhoneNo} variable, which is used at the next priority in a shell command (via the System( ) command) that sends a brief email message to @oreilly.com"><user>@oreilly.com.

14.4.2.3 Use your own sounds in IVR

If you can record WAV or AIFF files, you can make custom IVR prompts. These formats must be converted into GSM-encoded files, though, to work with Asterisk. It's better to record the prompts directly into GSM encoding rather than recording in WAV and then encoding to GSM. But not all sound recording applications support GSM out of the box, so you might need to record in one step, and convert to GSM, using the Unix application SoX, in another step.

In Windows, you can use the trusty Windows Sound Record application to create WAV files. On the Mac, you can use a sound recorder like Audiocorder (http://www.blackcatsystems.com) to create AIFF files. Either way, once you record the sounds, you'll have to convert them using SoX, the Unix SOund eXchange application.

14.4.2.4 Converting sounds using SoX

Using SoX for this task couldn't be any easier. This example converts an AIFF file called announce.aif into GSM encoding, merely by specifying the file extension ( .wav ) in the output filename:

 #  sox announce.aif announce.gsm  

SoX can do plenty of cool things. It can change the sampling rates, equalization, length (of time), and encoding of the output, too. In fact, a full-rate, high-fidelity sample (say, 44,000 Hz) wouldn't be a very good idea in an IVR app, so you could trim it down to size by resampling it into 8 kHz:

 #  sox -r8000 44KHzfile.aif 8KHzfile.gsm  

There also wouldn't be much sense in using stereo samples, so those can be made single-channel sounds:

 #  sox -c1 stereo.aif mono.aif  

Finally, you could boost the volume of a quiet sample with the -v option, followed by a decimal value that represents an increase in volume if it's greater than 1, or a decrease in volume if it's lower than 1:

 #  sox -v1.5 quiet.gsm louder.gsm  

14.4.2.5 Use soxmix to put background music into an announcement

The soxmix application can mix two sound files into a single file. This could be useful for combining background music with a voice recording. The mix of sound levels between the two source files is determined using SoX's "average" algorithm. Before mixing the two files, you can adjust their volume levels, as shown earlier. Here's a simple example of soxmix:

 #  soxmix music.gsm holdmessage.gsm combined.gsm  

Sounds for Business and Pleasure

"One moment please..." ( one-moment-please.gsm )

"That party is busy; please hold..." ( busy-please-hold.gsm )

"Enter an extension..." ( enter-ext-of-person.gsm )

Also included are a few that are suitable for, well, nonbusiness use:

"All your base are belong to us!" ( all-your-base.gsm )

"This is not the extension you're looking for..." ( jedi-extension-trick.gsm )

"We're off gambling..." ( gambling-drunk.gsm )


14.4.2.6 Record IVR announcements using Asterisk instead of a sound recording app

You can use Asterisk to record GSM files by configuring the dial-plan itself to record your channel into a sound file. This is accomplished using the Monitor( ) command. Consider the following dial-plan snippet:

 exten => *50,1,SetVar(pathname=/var/lib/asterisk/sounds/)     exten => *50,2,Read(FileNamebeep4)     exten => *50,3,Monitor(wav,${pathname}${FileName}.wav)     exten => *50,4,Read(foobeep1)     exten => *50,5,StopMonitor(  )     exten => *50,6,System('sox ${pathname}${FileName}.wav-in.wav ${pathname}${FileN$     exten => *50,7,Playback(${FileName})     exten => *50,8,System('rm -f ${pathname}${FileName}.wav-*') 

This novel little snippet is designed to record your voice when you dial *50. It stores the recording in a WAV file, converts it immediately to GSM using SoX, plays it back for you, and then deletes the WAV file originally used to record the call. To use it, call *50, listen for the beep, and enter a four-digit DTMF string. This will be used for the filename. As soon as you enter four digits, you'll hear a second beep. Now, begin speaking. When finished, dial any digit. The file is automatically saved and converted, and you should hear it play back immediately. Once finished, the unconverted files used to record the call are deleted.

You'll won't hear any DTMF tones in the recording as long as you use a phone with out-of- band signaling, such as SIP Info .




Switching to VoIP
Switching to VoIP
ISBN: 0596008686
EAN: 2147483647
Year: 2005
Pages: 172

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