<choice>

The <choice> element serves several purposes:

Attributes

fetchaudio The URI of the audio clip to play while the fetch is being done. If not specified, the fetchaudio property is used, and if that property is not set, no audio is played during the fetch. The fetching of the audio clip is governed by the audiofetchhint, audiomaxage, audiomaxstale, and fetchtimeout properties in effect at the time of the fetch. The playing of the audio clip is governed by the fetchaudiodelay, and fetchaudiominimum properties in effect at the time of the fetch.
fetchhint This attribute is not supported.
fetchtimeout (defaults to "fetchtimeout" global property value) The timeout for fetches. Must be specified with the appropriate time units (e.g., "120s" for 120 seconds).
maxage (defaults to "documentmaxage" global property value) Tells the platform the maximum acceptable age, in seconds, of cached documents.
maxstale (defaults to "documentmaxstale" global property value) Tells the platform the maximum acceptable staleness, in seconds, of expired cached documents.
accept (defaults to "exact") Override the setting for accept in <menu> for this particular choice. When set to "exact", the text of the choice element defines the exact phrase to be recognized. When set to "approximate", the text of the choice element defines an approximate recognition phrase.
dtmf The DTMF sequence for this choice. It is equivalent to a simple DTMF <grammar>, and DTMF properties apply to recognition of the sequence.
event Specify an event to be thrown instead of specifying a next.
eventexpr An ECMAScript expression evaluating to the name of the event to be thrown.
message A message string providing additional context about the event being thrown. The message is available as the value of the variable "_message" within the scope of the catch element.
messageexpr An ECMAScript expression evaluating to the message string.
next The URI of the next dialog or document.
expr Specify an expression to evaluate as a URI to transition to instead of specifying a next.

Notes

Exactly one of "next", "expr", "event", and "eventexpr" must be specified. Exactly one of "message" and "messageexpr" may be specified.


Example

<?xml version="1.0"?>
<vxml version="2.0">
  <menu id="maincoursea">
    <prompt>
      Please select an entree.
    <enumerate>
      For <value expr="_prompt"/>, say <value expr="_prompt"/>.
    </enumerate>
    </prompt>
    <choice next="#maincoursea1"> swordfish steak </choice>
    <choice next="#maincoursea2"> roast beef </choice>
  </menu>

  <menu id="maincoursea1">
    <prompt>
      You chose swordfish steak. Press 1 or say dessert to hear what's for dessert.
    </prompt>
    <choice next="#dessert" dtmf="1">Dessert</choice>
  </menu>

  <menu id="maincoursea2">
    <prompt>
      You chose roast beef. Press 1 or say dessert to hear what's for dessert.
    </prompt>
    <choice next="#dessert" dtmf="1">Dessert</choice>
  </menu>

  <form id="dessert">
    <block>
      <prompt>
        The dessert today is chocolate pie.
      </prompt>
    </block>
  </form>
</vxml>

The output of the above script would be:

Computer: Please select an entree. For swordfish steak, say swordfish steak. For roast beef, say roast beef.
Human: Roast beef.
Computer: You chose roast beef. Press 1 or say dessert to hear what's for dessert.
Human: Dessert.
Computer: The dessert today is chocolate pie.



Child Tags

<grammar>



Parent Tags

<menu>