Using DTMF for Menu Navigation

One of the most common uses of DTMF is to allow users to navigate a menu of choices. You can use <menu> element to accomplish this navigation, as follows:
  1. Use the <menu> element for the main prompt. The menu prompt has two attributes: exact and approximate. Exact is the default and means the user must match every word of the grammar fragment in order for a recognition match to occur. See, Using DTMF.

  2. For each choice, insert a <choice> element.

  3. Specify the DTMF key associated with the item and the next place to jump to when the item is chosen.

You may also insert a grammar in the <choice> element. This insertion allows the user to select the item either by pressing the DTMF key or by speaking the grammar item.

As an example of a banking application, the script gives the caller the following three choices, and then instructs the caller to press “*” when finished:
  • For checking account balance, press 1.

  • For savings account balance, press 2.

  • For credit card balance, press 3.

In this example, the caller presses 3. The system informs the caller “Sorry, you don’t have a credit card account with us,” and again offers the caller the same three choices. The caller presses “*”, the system says “Thank you. Good-bye!” and ends the call.

Example, Using DTMF shows the scripting for the preceding banking application.

<menu id="main">
<prompt>
For checking account balance, press 1.
For savings account balance, press 2.
For credit card balance, press 3.
Press * when you are finished.
</prompt>
<!-- No termination character is necessary -->
<property name="termchar" value=""/>
<choice dtmf="1" next="CheckBalance.jsp">
checking account
</choice>
<choice dtmf="2" next="SavingBalance.jsp">
savings account
</choice>
<choice dtmf="3" next="#credit">
credit card
</choice>
<choice dtmf="*" next="#exit">
[finish goodbye bye]
</choice>
</menu>
<form id="credit">
<block>
Sorry, you don't have a credit card account with us.
<goto next="#main"/>
</block>
</form>
<form id="exit">
<block>
Thank you. Good-bye!
</block>
</form>

The preceding example:

Accepts both DTMF input and speech input. For example, rather than entering 2, a caller can also say “savings account” to check the savings account balance.

In addition to the <menu> and <choice> elements, VoiceXML also provides the <option> element, which you can use in a form for a similar purpose.