VoiceXML Adventure Game - Mother of Perl | 5 | WebReference

VoiceXML Adventure Game - Mother of Perl | 5

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

VoiceXML Adventure Game

Adding Help

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"> 
  <form> 
	 <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">}
          ]
        ]]>
		</grammar> 
		<prompt> 
		  <audio>You are in a small room with three doors.</audio>
		  <pause>300</pause> 
		  <audio>Which one do you want to open?</audio> 
		</prompt> 
		<nomatch count="1"> 
		  <audio>Wrong door.</audio> 
		  <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> 
		  <listen/>
		</nomatch> 
		<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>
		  <listen/> 
		</nomatch> 
		<nomatch count="3"> 
		  <audio>Pretend you have a brain and press 1, 2, or 3.</audio> 
		  <listen/> 
		</nomatch> 
		<noinput count="1"> 
		  <audio>What are you waiting for?</audio>
		  <pause>300</pause> 
		  <audio>Press or say 1, 2, or 3.</audio> 
		  <listen/> 
		</noinput>
		<noinput count="2"> 
		  <audio>If you do not press 1, 2, or 3, 
		  I am going to kill the monkey!</audio> 
		  <listen/> 
		</noinput> 
		<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> 
		  <listen/> 
		</noinput> 
		<noinput count="4"> 
		  <audio>1, 2, or 3.</audio> 
		  <listen/> 
		</noinput> 
		<help> 
		  <audio>Why are you asking for help?</audio> 
		  <pause>300</pause>
		  <audio>Go away.</audio> 
		  <reprompt/> 
		</help> 
	 </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>

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


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

http://www.internet.com

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

URL: http://www.webreference.com/perl/tutorial/21/5.html