enumerate element
VoiceXML 2.0
Creates a template for choices in a menu.


<enumerate />



The enumerate element allows you to specify a template that is applied to each choice in a menu or to each option in a field. You can access the prompt and DTMF key assigned to the current choice or option by using the Platform-defined _prompt and _dtmf variables.
You must set the dtmf attribute to true on the menu to access the _dtmf variable within the template.

The following example uses a menu to prompt the user for an action. The enumerate element includes a template that presents the user with the DTMF key and the allowable phrase for each choice in the menu. A regular expression is used to remove special grammar characters from the prompt before playing them back to the user via the TTS engine.

<?xml version="1.0"?>
<vxml version="2.1"
  <var name="iTries" expr="0"/>

  <catch event="event.askagain">
      <break time="800ms"/>
      <assign name="iTries" expr="iTries+1"/>
      <goto next="#get_command" />

  <menu id="get_command" dtmf="true">
      <if cond="0 == iTries">
         Welcome home.
         <break time="200ms" />
            To <value expr="_prompt.replace(/[\?\(\)]/g, '')"/>, 
            press <value expr="_dtmf"/>, 
            or say <value expr="_prompt.replace(/[\?\(\)]/g, '')"/>.
            <break time="200ms"/>
         What else would you like to do?

    <choice next="#heater">(turn on the heater)</choice>
    <choice next="#lights">(turn on the lights)</choice>
    <choice next="#slippers">(fetch my slippers)</choice>
    <choice next="#nothing">(?do nothing)</choice>

      Sorry, I didn't understand you. 
      <reprompt />

      Sorry. I didn't hear you. 
      <reprompt />


  <form id="heater">
    <block>turning on the heater 
       <throw event="event.askagain"/>

  <form id="slippers">
    <block>fetching your slippers 
       <throw event="event.askagain"/>

  <form id="lights">
    <block>turning on the lights 
       <throw event="event.askagain"/>

  <form id="nothing">

[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers