Using DTMF for Menu Navigation
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.
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.