VoiceXML Adventure Game - Mother of Perl | 4 | WebReference

VoiceXML Adventure Game - Mother of Perl | 4

To page 1To page 2To page 3current pageTo page 5To page 6To page 7
[previous] [next]

VoiceXML Adventure Game

Handling Events

Next, we need to add handlers for the nomatch and noinput events using the methods specified in Page 4 of the previous tutorial.

Example 3.

<?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>

To page 1To page 2To page 3current pageTo page 5To page 6To page 7
[previous] [next]

https://www.internet.com

Produced by Jonathan Eisenzopf
All Rights Reserved. Legal Notices.
Created: March 8, 2001

URL: https://www.webreference.com/perl/tutorial/21/4.html