February 28, 2021
Hot Topics:

VoiceXML Adventure Game

  • By Jonathan Eisenzopf
  • Send Email »
  • More Articles »

In most VoiceXML applications, you'll want to provide some help facility. Most people expect to get some kind of help when they press 0 on their phone, whether it be a live operator or automated assistance. In the example below, we've added a DTMF and voice grammar item that calls the help element in the document below.

Example 4.

<?xml version="1.0"?>
<vxml version="1.0">
<field name="answer">
<grammar> <![CDATA[
[dtmf-1 one first] {<option "door1">}
[dtmf-2 two second] {<option "door2">}
[dtmf-3 three third] {<option "door3">}
[(touch the monkey)] {<option "monkey">}
[dtmf-0 huh help what doh] {<option "help">}
<audio>You are in a small room with three doors.</audio>
<audio>Which one do you want to open?</audio>
<nomatch count="1">
<audio>Wrong door.</audio>
<audio>To open the first door, press or say 1.</audio>
<audio>To open the second door, press or say 2.</audio>
<audio>To open the third door,
press or say 3.</audio>
<nomatch count="2">
<audio>You fool! That is not a choice I am giving you.</audio>
<pause>300</pause> <audio>Press or say 1, 2, or 3.</audio>
<nomatch count="3">
<audio>Pretend you have a brain and press 1, 2, or 3.</audio>
<noinput count="1">
<audio>What are you waiting for?</audio>
<audio>Press or say 1, 2, or 3.</audio>
<noinput count="2">
<audio>If you do not press 1, 2, or 3,
I am going to kill the monkey!</audio>
<noinput count="3">
<audio>Ok. That's it. The monkey is dead and it's your fault because you did not choose 1, 2, or 3.</audio>
<noinput count="4">
<audio>1, 2, or 3.</audio>
<audio>Why are you asking for help?</audio>
<audio>Go away.</audio>
<result name="door1">
<audio>You see a large hungry monkey.</audio>
<result name="door2">
<audio>You see another room with three doors, a man, and his monkey.</audio>
<result name="door3">
<audio>You see a man scratching his monkey.</audio>
<result name="monkey">
<audio>No! Do not touch the monkey!</audio>

If you hadn't noticed, I also added multiple elements for the nomatch and noinput handlers.

Page 5 of 7

This article was originally published on December 1, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date