Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.29 menu

Element type

menu

Attributes

accept (2.0) | dtmf | id | scope

Parents

vxml

Children

PCDATA | audio | catch | choice | enumerate | error | help | noinput | nomatch | prompt | property | value

Description

A menu is simple dialog where fixed choices are presented to the user and based on the user's response a transition to another dialog or VoiceXML document takes place.

DTD

<!ELEMENT menu
  (%audio; | choice | %event.handler; | prompt | property)* >
<!ATTLIST menu
  id             ID        #IMPLIED
  scope          %scope;   'dialog'
  %accept.attrs;
  dtmf           %boolean; 'false' >

Language model

03fig29.gif

Attributes

  • accept : (exact | approximate)

    New to VoiceXML 2.0, this attribute can be set to exact (by default) or approximate. It specifies how the grammar recognition should handle each choice element. Individual choice elements can override this setting.

  • dtmf : boolean

    If true, the menu will auto-number choices with a sequential number, unless a choice has an assigned dtmf value. So for dtmf="true", the first choice would get a dtmf="1", the second choice would get "2", and soon.

  • id : ID

    The identifier of the menu. It allows the menu to be a target of a goto or submit.

  • scope : (dialog | document)

    Specifies whether this menu will have local or global scope.

Children

  • choice elements

    Representing the menu choices.

  • prompt and audible elements

    To be rendered to the user upon visiting this menu.

  • event.handler elements

    To remain active while executing this menu.

  • property elements

    To set system properties for the duration of this menu's execution.

Examples

In Example 3-33,

  • The menu element's attribute accept="approximate" enables recognition of partially matching phrases.

  • The element <property name="inputmodes"value="voice"/> sets recognition to voice only.

  • The enumerate elements are shorthands for automatically listing the choice elements. The prompt will be rendered as "Welcome to our gift shop. Select from one of the following departments: Home and Office, Travel and Outdoor, Health and Fitness."

  • Four events are handled: noinput, nomatch, error, and help.

Example 3-33 Voice recognition driven menu

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <menu accept="approximate">
    <property name="inputmodes" value="voice">
    <prompt>
      Welcome to our gift shop. Select from one of
      the following departments:
      <enumerate/>
    </prompt>
    <choice next="http://www.example.com/giftshop/vxml/home.vxml">
      Home and Office
    </choice>
    <choice next="http://www.example.com/giftshop/travel.vxml">
      Travel and Outdoor
    </choice>
    <choice next="http://www.example.com/giftshop/health.vxml">
      Health and Fitness
    </choice>
    <noinput>Please say one of <enumerate/>.</noinput>
    <nomatch>
      Couldn't understand, please say one of <enumerate/>.
    </nomatch>
    <error>An error has occurred <exit/>.</error>
    <help>
      The gift shop has four departments. To proceed, you must say
      <enumerate/>.
    </help>
  </menu>
</vxml>

In Example 3-34,

  • The element <property name="inputmodes"value="dtmf"/> sets the recognition mode to dtmf only.

  • The enumerate elements use the built-in variables _prompt and _dtmf. Depending on the specific platform implementation, the prompt could be rendered as “Welcome to our gift shop. Select from one of the following departments: for Home and Office press 1, for Travel and Outdoor press 2, for Health and Fitness press 3, for Help press 9.,”

  • A choice element with dtmf="9" is added to detect the user pressing "9" and to throw a help event.

  • Four events are handled: noinput, nomatch, error, and help.

Example 3-34 DTMF driven menus

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <menu>
    <property name="inputmodes" value="dtmf"/>
    <prompt>
      Welcome to our gift shop.
      Select from the following departments:
      <enumerate>for <value expr="_prompt"/> press
      <value expr="_dtmf"/></enumerate>.
    </prompt>
    <choice dtmf="1"
            next="http://www.example.com/giftshop/vxml/home.vxml">
      Home and Office
    </choice>
    <choice dtmf="2"
            next="http://www.example.com/giftshop/travel.vxml">
      Travel and Outdoor
    </choice>
    <choice dtmf="3"
            next="http://www.example.com/giftshop/health.vxml">
      Health and Fitness
    </choice>
    <choice dtmf="9"> <throw event="help">Help</choice>
    <noinput>Please select from the following.
      <enumerate>
        For <value expr="_prompt"/> press <value expr="_dtmf"/>.
      </enumerate>
    </noinput>
    <nomatch>Couldn't understand.
      <enumerate>
        For <value expr="_prompt"/> press <value expr="_dtmf"/>.
      </enumerate>
    </nomatch>
    <error>An error has occurred <exit/>.</error>
    <help>
      The gift shop has three departments. To proceed you must
      <enumerate>
        press <value expr="_dtmf"/> for <value expr="_prompt"/>.
      </enumerate>
    </help>
  </menu>
</vxml>

In Example 3-35,

  • The menu element's attribute id="departments" allows this menu to be referred to from a goto or submit element (not shown).

  • The menu element's attribute dtmf="true" will automatically assign sequential DTMF keys for each choice, so we don't have to set each choice element's dtmf attribute to a value.

  • The menu element's attribute scope="document" makes the menu active throughout the document, which means that anywhere in the document, when a “1,”, “2,”, “3,”, or “9,” key is pressed one of the four choices is activated. By default this value is set to dialog, which limits the scope to the dialog (or in this case, the menu).

  • The prompt is changed to read from an audio file <audiosrc="http://www.example.com/giftshop/audio/departments.wav">.

  • The attribute dtmf="9" is still used to override the automatic assignment of a DTMF key for this choice.

  • Four events are handled: noinput, nomatch, error, and help.

Example 3-35 A modified DTMF menu

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version=1.0">
  <menu id="departments" dtmf="true" scope="document">
    <property name="inputmodes" value="dtmf"/>
    <prompt>
      <audio
       src="http://www.example.com/giftshop/audio/departments.wav"/>
    </prompt>
    <choice next="http://www.example.com/giftshop/vxml/home.vxml">
      Home and Office
    </choice>
    <choice next="http://www.example.com/giftshop/travel.vxml">
      Travel and Outdoor
    </choice>
    <choice next="http://www.example.com/giftshop/health.vxml">
      Health and Fitness
    </choice>
    <choice dtmf="9">
      <throw event="help"/>Help
    </choice>
    <noinput>Please select from the following.
      <enumerate>
        For <value expr="_prompt"/> press <value expr="_dtmf"/>
      </enumerate>
    </noinput>
    <nomatch>Couldn't understand.
      <enumerate>For <value expr="_prompt"/> press
        <value expr="_dtmf"/>
      </enumerate>
    </nomatch>
    <error>An error has occurred <exit/></error>
    <help>The gift shop has three departments. To proceed you must
      <enumerate>press <value expr="_dtmf"/> for
        <value expr="_prompt"/>
      </enumerate>
    </help>
  </menu>
</vxml>
  • + Share This
  • 🔖 Save To Your Account