developer.com
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
New
 
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




See The Winners!




Developer Jobs

Be a Commerce Partner














 


Developer News -
Linux Vendors Head to the Cloud in Search of Cash    July 2, 2009
iPhone 3GS: Overheating Fears, OS Update Nears    July 1, 2009
PostgreSQL 8.4 Revs Up Database Admin, Security    July 1, 2009
PHP 5.3 Accelerates PHP    June 30, 2009
Free Tech Newsletter -

Tellme More
By Jonathan Eisenzopf

Go to page: Prev  1  2  3  4  5  6  7  Next  

Handling Events
Invalid Input

Handling forms requires more than simply gathering field input. If the user provides input that doesn't match the grammar, Tellme will look for the nomatch element. If it doesn't exist, the application will croak. The most common way to handle invalid input is to tell the user so and ask them for the information again.

<?xml version="1.0"?>
<vxml version="1.0" >
<form id="hello">
<field name="pin">
<grammar>
<![CDATA[
Four_digits
]]>
</grammar>
<prompt>Please enter your 4 digit pin code.</prompt>
<filled>
<submit next="http://www.webreference.com/cgi-bin/perl/20/pin.pl"/>
</filled>
<nomatch>Invalid pin code.
<reprompt/>
</nomatch>
</field>
</form>
</vxml>

In the example above, we are using one of the Tellme grammars, Four_digits, to regulate the input. The grammar contains rules that will cause the document to call the nomatch event unless the user enters four numbers via the phone keypad or by voice. The reprompt element repeats the last prompt, Please enter your 4 digit pin code after telling the user that they've entered an invalid PIN code. Tellme will keep reprompting the user as long as they keep entering invalid input.

Of course, if the user is repeatedly entering invalid input, giving them the same error message and prompt won't help the user any. In fact, it would be downright user unfriendly. This is why the nomatch element includes a count attribute that allows us to give the user a different warning message each time the nomatch event is called.

<nomatch count="1">Invalid pin code.
<reprompt/>
</nomatch>
<nomatch count="2">Please press or say exactly four numbers.
<reprompt/>
</nomatch>
<nomatch count="3">Too many attempts. Please call back another time. <exit/>
</nomatch>

Now, the second time the user provides bad input, we give them more specific instructions, "Too many attempts. lease call back another time." The third time the user provides bad input, we exit the program.

No Input

Like handling invalid input, it's also critical to handle no input. Tellme calls the noinput event when the user does not provide any input after a prompt has been played.

<?xml version="1.0"?>
<vxml version="1.0" >
<form id="hello">
<field name="pin">
<grammar>
<![CDATA[
Four_digits
]]>
</grammar>
<prompt>Please enter your 4 digit pin code.</prompt>
<filled>
<submit next="http://www.webreference.com/cgi-bin/perl/20/pin.pl"/>
</filled>
<noinput>
<reprompt/>
</noinput>
<nomatch>Invalid pin code.
<reprompt/>
</nomatch>
</field>
</form>
</vxml>

Like the nomatch element, if you don't handle the noinput event, your VoiceXML application will return an error when it's called. Also, like nomatch, you can set the count attribute so that a different message is played each time the user fails to provide input.

<noinput count="1">No PIN entered.
<reprompt/>
</noinput>
<noinput count="2">You must enter your PIN number to proceed.
<reprompt/>
</noinput>
<noinput count="3">Please press or say exactly four numbers.
</noinput>

If the noinput event is called more than 3 times, Tellme will continue to repeat the last noinput, "Please press or say exactly four numbers.", until the user provides some input.

Go to page: Prev  1  2  3  4  5  6  7  Next  


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Voice Archives






internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs