VoiceXML Developer Series: A Tour Through VoiceXML, Part II

In Part II of A Tour Through VoiceXML, we're going to focus on building VoiceXML applications with menus that allow callers to make selections via DTMF tones and voice commands.

Welcome back. I hope you enjoyed the last article, which was
the first part of a tour through the entire VoiceXML 1.0 language.
In Part II, we're going to focus on building VoiceXML applications
with menus that allow callers to make selections via DTMF tones
and voice commands. The results of this article can be accessed live
by calling 510-315-6666.

Create voice menus with the <menu> element

Similar to HTML menu options, VoiceXML menus provide users with
lists of information that are selected with DTMF or voice commands.
The example below introduces a VoiceXML document than contains a
menu with three options preceded by a prompt.

When executed, the example above will play the prompt and wait for
the user to press a number on their keypad. Menus contain a
list of choices. In this menu, the choices are red, blue, and yellow. The
colors are selected by pressing the corresponding number on the phone keypad (1, 2, or 3).
When the DTMF tone that matches the dtmf attribute is recognized,
it will send the user to the VoiceXML document contained in the next
attribute of the choice element. Alternatively,
you can have the menu automatically assign DTMF tones to the menu choices by
setting the dtmf attribute of the <menu> element to true:

Now let's look at the next attribute of the choice element.
The first next attribute points to another VoiceXML document
named red.vxml. So when we press 9, the VoiceXML interpreter loads that document
and executes it. The linking mechanism that makes this work is quite like HTML links. In
fact, the #blue value of the next attribute inside the
second <choice> element points to an internal link in the same
document. The # notation for in-document references is the same as in HTML. In fact, the
third <choice> points to a reference inside a VoiceXML document
called yellow.vxml.

Recognizing voice commands in menus

We've learned how to browse menus with DTMF tones, but VoiceXML also
enables us to create grammars for each menu choice, which will recognize speech
instead of or in addition to DTMF. This is done by including a simple grammars
(compared to form grammars) inside the the <choice> element.

The <choice> elements in the example above contain words.
The choice is matched when the VoiceXML system recognizes one of the words
(red, blue, or yellow). We've also added the <enumerate />
element, which will synthesize the contents of the choices. So the user will hear:

What is your favorite color? red, blue, yellow.

The previous example only contains single word grammars, but menus may
contain multiple words and phrases. The interpreter will match any combination
of the phrase or words in the order that they occur. For example, the menu
below contains two words each. The first choice would be matched if the user said
place or order or place order.

When considering the words to include in the grammar for each choice, you should
follow a few rules. First, no word should occur in more than one choice. Second,
avoid using words that *sound* similar. These are words that contain similar or
identical phonemes (or the sounds that make up speech). For example, if one choice
contained the word mow and another choice contained more, the
speech recognition software will have a hard time differentiating between the two.
Use a synonym for more such as additional.

Finishing up

Technically, VoiceXML menus can be created very rapidly. Functionally, your
users will be familiar with the mechanics of menus, because they are very similar
to the majority of IVR applications that are in existance today.

A few other closing thoughts on menus. Include an id attribute
in the <menu> element in cases where you want to be able to
link to it from other sections or VoiceXML documents. Also, the scope
attribute, if set to document, will turn on the menu grammars for the
entire VoiceXML document. This technique can be use to create a global menu for
the document. Include the menu in your root VoiceXML document to make the menu
available to multiple VoiceXML documents.

Lastly, don't forget to try out the new live Voice Web site for VoiceXML Planet.
It's sparse right now, but it does include the big VoiceXML example contained in
the last article. Thanks for coming back. Let's keep talking and listening in
the next edition of the VoiceXML Developer.

About Jonathan Eisenzopf

Jonathan is a member of the Ferrum Group, LLC based in Reston, Virginia
that specializes in Voice Web consulting and training. He has also written
articles for other online and print publications including WebReference.com
and WDVL.com. Feel free to send an email to eisen@ferrumgroup.com regarding
questions or comments about the VoiceXML Developer series, or for more
information about training and consulting services.