Home > Articles > Web Services > XML

  • Print
  • + Share This

Easy Menu Enumeration

Menus also support a convenient way to automatically assign dtmf keys and create prompts based on the choice elements that appear in your document. For developer convenience, when using enumerate, you have access to two related variables, _dtmf and _prompt, which acquire values based on the internal enumeration over all the choice elements (see Listing 4).

Listing 4 The VoiceXML enumerate element

 1 <menu id="mainmenu" dtmf="true">
 2  <prompt>
 3   Welcome. Your choices.
 4   <enumerate>
 5    press <value expr="_dtmf"/>, for <value expr="_prompt"/>.
 6   </enumerate>
 7  </prompt>
 8  <choice next="#world">world</choice> 
 9  <choice next="#sports">sports</choice> 
 10  <choice next="#people">people</choice> 
 11 </menu>

When the above menu is executed, the user hears the following:

Welcome. Your choices. Press 1 for world. Press 2 for sports. Press 3 for people.

As you’ll see in subsequent articles in this series, the capability to autogenerate prompts based on the actual choice elements that follow an enumeration opens the door to creating templates for voice menus and delivering menus dynamically from a server. All that’s needed is the insertion of choice elements, and your VoiceXML is ready to go.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.