VoiceXML Forum Community Message Board


Post New Topic  Post A Reply
my profile | register | search | faq | forum home
  next oldest topic   next newest topic
» VoiceXML Forum Community Message Board   » Newbies   » vxml infinite prompt loop

 - UBBFriend: Email this page to someone!    
Author Topic: vxml infinite prompt loop
wsoo
Junior Member
Member # 3631

Rate Member
Icon 1 posted June 14, 2006 05:44 PM      Profile for wsoo   Email wsoo   Send New Private Message       Edit/Delete Post   Reply With Quote 
Hello,

I am new to Voice XML. I wrote a testing dtmf menu and users can select the "*" key to play the menu again. The problem is, it creates an infinite loop. Is there a way to code it, so after the third try, the code would forward the call to the operator or disconnect it or event throw an event?

Thanks,

Wing Lok Soo

Here is the code:
code:
<?xml version="1.0"?>
<%@ page language="java" contentType="text/xml;charset=UTF-8"%>
<%@ taglib uri="netui-tags-vxml.tld" prefix="vxml" %>

<vxml:vxml version="2.0">
<vxml:form id="rootMenuForm">
<vxml:field name="icecreamField">
<vxml:grammar xmllang="en-US" root="ROOT" version="1.0" tagformat="swi-semantics/1.0" mode="dtmf">
<vxml:rule id="ROOT" scope="public">
<vxml:ruleref uri="#menu"/>
</vxml:rule>
<vxml:rule id="menu">
<vxml:one-of>
<vxml:item> 1 </vxml:item>
<vxml:item> 2 </vxml:item>
<vxml:item> * </vxml:item>
</vxml:one-of>
</vxml:rule>
</vxml:grammar>
<vxml:prompt timeout="5s">
Please select from the following options:
If you want ice cream, press 1,
otherwise press 2,
To hear the menu again, please press the star key
</vxml:prompt>
<vxml:prompt count="2">
Please listen to the menu carefully.
If you want ice cream, press 1,
otherwise press 2,
To hear the menu again, please press the star key
</vxml:prompt>

<vxml:nomatch>
Did you enter correctly?
<vxml:reprompt/>
</vxml:nomatch>

<vxml:nomatch count="3">
I could not find your selection.
Good-bye
<vxml:disconnect/>
</vxml:nomatch>


<vxml:noinput>
I did not hear your selection.
<vxml:reprompt/>
</vxml:noinput>

<vxml:noinput count="3">
Okay, you did not make any selections, Good-bye
<vxml:disconnect/>
</vxml:noinput>

<vxml:filled>
<vxml:if cond="icecreamField == 1">
okay, tell me what you favourite ice cream is.
<vxml:goto expr="favouriteIcecreamForm"/>
<vxml:elseif cond="icecreamField == 2"/>
What kind of dessert do you want?
<vxml:goto expr="otherDessertForm"/>
<vxml:elseif cond="icecreamField == \"*\""/>
<vxml:reprompt/>
<vxml:else/>
<vxml:throw event="nomatch"/>
</vxml:if>
<vxml:clear namelist="icecreamField"/>
</vxml:filled>

</vxml:field>
</vxml:form>
</vxml:vxml>


Posts: 2 | Registered: Jun 2006  |  IP: Logged
mheadd
Member
Member # 3181

Member Rated:
4
Icon 1 posted June 15, 2006 10:53 AM      Profile for mheadd   Author's Homepage   Email mheadd   Send New Private Message       Edit/Delete Post   Reply With Quote 
Sure, just use some JavaScript to increment a counter each time the field is filled and check the counter when the caller decides to hear the menu again.

In your VoiceXML document, create some new children of the <vxml> element to instantiate a counter variable and to set up a handler for a transfer event.
code:
 
<var name="counter" expr="0"/>

<!-- You'll need to create a separate form called "transfer" to do the actual call transfer -->
<catch event="doTransfer">
<goto next="#transfer"/>
</catch>

Now, add a block as a child of your form element that checks the value of the counter variable. If it is equal to 3, then throw the doTransfer event.
code:
 
<form id="rootMenuForm">

<block name="checkCounter">
<if cond="counter==3">
<throw event="doTransfer"/>
</if>
</block>

<field name="icecreamField">

...

</field>
</form>

Finally, in your conditional logic, where you check what the caller entered, change the logic when a caller enters '*'.
code:
 
<elseif cond="icecreamField== "*"/>
<assign name="counter" expr="counter+1"/>
<clear namelist="icecreamField"/>
<goto nextitem="checkCounter"/>
<else/>

By clearing the field variable, you are telling the Form Interpretation Algorithm to revisit the field again. By making the checkCounter <block> the target of the <goto>, you will ensure that your counter variable gets checked before the FIA revisits the field.

Hope this helps.

[ June 15, 2006, 10:55 AM: Message edited by: mheadd ]

--------------------
Mark
VoiceinGov.org
http://www.voiceingov.org

Posts: 45 | Registered: Jun 2005  |  IP: Logged
wsoo
Junior Member
Member # 3631

Rate Member
posted June 20, 2006 12:42 PM      Profile for wsoo   Email wsoo   Send New Private Message       Edit/Delete Post   Reply With Quote 
Thanks! It works using the script that you suggested.
Posts: 2 | Registered: Jun 2006  |  IP: Logged
Valerie
Junior Member
Member # 3702

Rate Member
Icon 1 posted August 08, 2006 01:44 PM      Profile for Valerie   Author's Homepage   Email Valerie   Send New Private Message       Edit/Delete Post   Reply With Quote 
I dont understand step 3 described above by mheadd. What is the logic behind it?

Valerie
http://www.thecorrect.com
http://www.submitboy.com

Posts: 2 | Registered: Aug 2006  |  IP: Logged


All times are Eastern  
Post New Topic  Post A Reply Close Topic    Move Topic    Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:

Contact Us | VoiceXML Forum



Powered by Infopop Corporation
UBB.classicTM 6.3.1.2