VoiceXML Adventure Game
Next, we need to add handlers for the nomatch and noinput events using the methods specified in Page 4 of the previous tutorial.
<?xml version="1.0"?>
<vxml version="1.0">
<form>
<field name="answer">
<grammar> <![CDATA[
[
[dtmf-1 one] {<option "door1">}
[dtmf-2 two] {<option "door2">}
[dtmf-3 three] {<option "door3">}
[(touch the monkey)] {<option "monkey">}
]
]]>
</grammar>
<prompt> <audio>You are in a small room with three doors.</audio>
<pause>300</pause>
<audio>To open the first door, press or say 1.</audio>
<pause>300</pause>
<audio>To open the second door, press or say 2.</audio>
<pause>300</pause>
<audio>To open the third door, press or say 3.</audio>
</prompt>
<nomatch>
<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>
<listen/>
</nomatch>
<noinput>
<audio>What are you waiting for?</audio>
<pause>300</pause>
<audio>Press or say 1, 2, or 3.</audio>
<listen/>
</noinput>
</field>
<filled>
<result name="door1">
<audio>You see a large hungry monkey.</audio>
<reprompt/>
</result>
<result name="door2">
<audio>You see another room with three doors, a man, and his monkey.</audio>
<reprompt/>
</result>
<result name="door3">
<audio>You see a man scratching his monkey.</audio>
<reprompt/>
</result>
<result name="monkey">
<audio>No! Do not touch the monkey!</audio>
<reprompt/>
</result>
</filled>
</form>
</vxml>
Page 4 of 7
This article was originally published on December 1, 2002