text
stringlengths
0
152
CHAPTER 16
Introduction to Interactive Voice Response
One day Alice came to a fork in the road and saw a Cheshire cat in a tree. “Which road do I
take?” she asked.
“Where do you want to go?” was his response.
“I don’t know,” Alice answered.
“Then,” said the cat, “it doesn’t matter.”
—Lewis Carroll
The term Interactive Voice Response (IVR) is often misused to refer to an automated
voice attendant, but the two are very different things. The purpose of an IVR system
is to take input from a caller, perform an action based on that input (commonly, look‐
ing up data in an external system such as a database), and speak a result to the caller.
The purpose of an automated attendant (which we covered in Chapter 14) is to route
calls. Originally, an IVR didn’t even need to be a telephone system. Anything that
took input from a human and spoke back a result fell with the realm of an IVR. Tra‐
ditionally, IVR systems have been complex, expensive, and annoying to implement.
Asterisk changes all that.
Components of an IVR
The most basic elements of an IVR are quite similar to those of an automated attend‐
ant, though the goal is different. We need at least one prompt to tell the caller what
the IVR expects, a method of receiving input from the caller, logic to verify that the
caller’s response is valid input, logic to determine what the next step of the IVR
should be, and finally, a storage mechanism for the responses, if applicable. We might
think of an IVR as a decision tree, although it need not have any branches. For exam‐
ple, a survey may present exactly the same set of prompts to each caller, regardless of
289
what choices the callers make, and the only routing logic involved is whether the
responses given are valid for the questions.
From the caller’s perspective, every IVR needs to start with a prompt. This initial
prompt will tell the caller what the IVR is for and ask the caller to provide the first
input. We discussed prompts in the automated attendant in Chapter 14. Later, we’ll
create a dialplan that will allow you to better manage multiple voice prompts.
The second component of an IVR is a method for receiving input from the caller.
Recall that in Chapter 14 we discussed the Background() and WaitExten() applica‐
tions for receiving a new extension. While you could create an IVR using Back
ground() and WaitExten(), it is generally easier and more practical to use the Read()
application, which handles both the prompt and the capture of the response. The
Read() application was designed specifically for use with IVR systems. Its syntax is as
follows:
Read(variable[,filename[&filename2...]][,maxdigits][,option][,attempts][,timeout])
The arguments are described in Table 16-1.
Table 16-1. The Read() application
Argument
variable
prompt
Purpose
The variable into which the caller’s response is stored. It is best practice to give each variable in your IVR a
name that is similar to the prompt associated with that variable. This will help later if, for business reasons or
ease of use, you need to reorder the steps of the IVR. Naming your variables var1, var2, etc., may seem
easy in the short term, but later in your life cycle it will make fixing bugs more difficult.
A file (or list of files, joined together with the & character) to play for the caller, requesting input. Remember
to omit the format extension on the end of each filename.
maxdigits The maximum number of characters to allow as input. In the case of yes/no and multiple-choice questions,
it’s best practice to limit this value to 1. In the case of longer lengths, the caller may always terminate input
by pressing the # key.
290
|
Chapter 16: Introduction to Interactive Voice Response
Argument
options
Purpose
s (skip)
Exit immediately if the channel has not been answered.
i (indication)
Rather than playing a prompt, play an indication tone of some sort (such as the dialtone).
n (no answer)
Read digits from the caller, even if the line is not yet answered.
attempts
The number of times to play the prompt. If the caller fails to enter anything, the Read() application