menu
menu element
Presents a list of choices to the user and transitions to the chosen information.
Syntax
<menu
accept = "string"
dtmf = "boolean"
id = "string"
scope = "document_dialog"
/>
Attributes
accept |
One of the following values:
approximateThe user utterance need only match a sub-phrase of the grammar fragment in order for a recognition match to occur.
exactThe user utterance must match every word of the grammar fragment in order for a recognition match to occur.
|
dtmf |
One of the following values: |
id |
Required. The name of the menu, which can serve as an anchor to jump to. |
scope |
One of the following values:
dialogThe menu's grammars are active only in that menu.
documentThe menu's grammars are active within any dialog in the same document. If the document is specified as the application root document, the grammar is active in all application documents.
|
Parents
Children
audio, catch, choice, data, enumerate, error, help, noinput, nomatch, prompt, property, script, value, var
Remarks
The menu element is a convenient shorthand version for a form that prompts the user to make a choice and then transitions to a different state based on that choice. The menu element uses the prompt element to present a list of choices to the user. Each option in the list is mirrored in a choice element as a speech or DTMF grammar fragment. If the user's input matches the grammar fragment, the Platform navigates to the location specified by the next or expr attribute or fires the event specified by the event attribute of that choice element.
The dtmf attribute of a choice element overrides the DTMF value supplied by the containing menu element.
The Tellme VoiceXML interpreter supports recording during recognition within a menu element in Revision 3 and later. For further information, see the utterance recording tutorial.
Examples
The following example offers a menu with three choices. The grammar fragment specified for each choice element corresponds to item from the prompt list. To hear a sports report, the user can press 1 or say "e s p n sports" or just "sports." To hear a news report, the user can press 2 or say "caltech news" or just "news." To hear a weather report, the user can press 3 or say "bay area weather" or just "weather."
<?xml version="1.0"?>
<vxml version="2.1"
xmlns="http://www.w3.org/2001/vxml">
<catch event="event.myapp.quit">
<exit />
</catch>
<var name="sUrlWeather" expr="'#weather_report'"/>
<!-- only say welcome the first time -->
<form id="intro">
<block>
Welcome
<goto next="#read_news"/>
</block>
</form>
<menu id="read_news" dtmf="true">
<prompt>
Say E S P N sports, weather, Caltech news, or quit.
</prompt>
<!-- demo the next attribute -->
<choice next="#sports_report" accept="approximate">(e s p n) sports</choice>
<choice next="#news_report">?caltech news</choice>
<!-- demo the expr attribute -->
<choice expr="sUrlWeather">[(bay area)] weather</choice>
<!-- demo the event attribute and explicit dtmf -->
<choice event="event.myapp.quit" dtmf="0">quit</choice>
<catch event="nomatch noinput help">
<reprompt />
</catch>
</menu>
<form id="sports_report">
<block>
Sports!
<break size="medium"/>
The New York Giants will win the Superbowl next year!
<goto next="#read_news"/>
</block>
</form>
<form id="weather_report">
<block>
Weather.
<break size="medium"/>
It will be mostly clear and sunny today.
<goto next="#read_news"/>
</block>
</form>
<form id="news_report">
<block>
California News! <break size="medium"/>
An earthquake in Northern California
caused damages in the billions.
<goto next="#read_news"/>
</block>
</form>
</vxml>