This is topic vxml infinite prompt loop in forum Newbies at VoiceXML Forum Community Message Board.


To visit this topic, use this URL:
http://www.voicexml.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=3;t=000138

Posted by wsoo (Member # 3631) on June 14, 2006, 05:44 PM:
 
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>


 
Posted by mheadd (Member # 3181) on June 15, 2006, 10:53 AM:
 
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 ]
 
Posted by wsoo (Member # 3631) on June 20, 2006, 12:42 PM:
 
Thanks! It works using the script that you suggested.
 
Posted by Valerie (Member # 3702) on August 08, 2006, 01:44 PM:
 
I dont understand step 3 described above by mheadd. What is the logic behind it?

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




Powered by Infopop Corporation
UBB.classicTM 6.3.1.2