< choice >

The <choice> element defines a menu item and serves several purposes:

  • Specifies a speech grammar fragment and/or a DTMF grammar fragment that determines when that choice has been selected.
  • Forms the <enumerate> prompt string with its contents.
  • Specifies the URI to go to when the choice is selected.
<choice
dtmf="DTMF sequence"
accept="exact" | "approximate"
next="URI"
event="event"
expr="ECMAScript_Expression"
fetchaudio="URI"
fetchhint="prefetch" | "safe"
fetchtimeout="time_interval"
maxage="time_interval"
maxstale="time_interval">
child elements
</choice>
dtmfThis attribute is the DTMF sequence for this choice. This attribute is optional.
acceptThe accept attribute overrides the setting for the accepted attribute in the <menu> element, with either exact or approximate values. This attribute is optional and defaults to exact. * exact – use exact to define the exact phrase to be recognized. * approximate – use approximate to define an approximate recognition phrase. A subset of the words in the phrase expression can be matched. For example, “Hello world” can be matched with “Hello world”, “Hello”, or “World”.
nextThe next attribute is the URI of the next dialog or document.
eventThis attribute throws a specified event. Next and expr attributes have precedence over this attribute.
exprThe expr attribute is an ECMAScript Expression that defines the URI to transition. The next attribute has precedence over this attribute.
fetchaudioThe fetchaudio attribute is the URI of the audio to play while waiting for the next document to be fetched.
fetchtimeoutThis attribute indicates the time interval to wait for an audio file to be fetched before playing the alternate content. This attribute is optional.
fetchhintThe fetchhint attribute defines when the audio file should be retrieved. This attribute is optional. * prefetch - the file can be fetched when the document is loaded. * safe - the file is fetched only when needed.
maxageThis attribute indicates the maximum time in seconds that this document will use this file before fetching another copy. This attribute is optional.
maxstaleThe maxstale attribute indicates the maximum time in seconds that this document will use the file that exceeded the maxage time. This attribute is optional.
<menu>
<audio>, <enumerate>, <grammar>, <value>
None.
The dtmf attribute must be specified.
<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
 <menu>
  <prompt> What do you want for drink, coffee or tea? </prompt>
  <choice dtmf="1" next="#getcoffee"> coffee </choice>
  <choice dtmf="2" next="#gettea"> tea </choice>
  <noinput> Please say coffee or tea </noinput>
  <nomatch> Please say coffee or tea </nomatch>
 </menu>
 <form id="getcoffee">
  <block>
   <prompt>Ok, here's your coffee</prompt>
  </block>
 </form>
 <form id="gettea">
  <block>
   <prompt>Ok, here's your tea</prompt>
  </block>
 </form>
</vxml>