0

i want to create a vxml application in which, the machine asks the user for employee code and then checks it against a database. this can be done three times only. 1) ask the user for employee code 2) find corresponding name for the code 3) if the code is invalid, ask the user to try again (this can be done three times only

<?xml version="1.0" encoding = "UTF-8"?> 
<vxml version="2.1" xml:lang="en-IN"  xmlns="http://www.w3.org/2001/vxml" application="lang_select.vxml">
<var name="stop" expr="stop+1"/>
<var name="count" expr="1"/>
<form id="ecode">
        <field name="employee" type="digits?minlength=04;maxlength=04">
            <prompt count="1" cond="lang=='2'">
                Please say your four digit employee code.
            </prompt>
            <prompt xml:lang="hi-IN" count="1" cond="lang=='1'">
                अपने चार अंकों कर्मचारी कोड कहिए
            </prompt>
            <prompt count="2" cond="lang=='2'">
                please try saying your four digit employee code again.
            </prompt>
            <prompt count="2" xml:lang="hi-IN" cond="lang=='1'">
                फिर से अपने चार अंकों कर्मचारी कोड कह के प्रयास करें.
            </prompt>
            <prompt count="3" cond="lang=='2'">
                Your employee code is written on your I-card. please say or enter your four digit employee code.
            </prompt>
            <prompt count="3"  xml:lang="hi-IN" cond="lang=='1'">
                आपका एंप्लायी कोड आपके ई-कार्ड पे लिखा है. अपने चार अंकों कर्मचारी कोड बोलिए या दर्ज करें.
            </prompt>
            <filled>
            <var name="inc_count" expr="count+1"/>
            </filled>
        </field>
    </form>
    <form id="retry">
        <field name="confirm" type="boolean">
            <prompt cond="lang=='2'&& count &lt; 3"> <!-- the machine will ask the user only thrice for confirmation -->
                you have entered <value expr="employee"> as your employee code. Is it correct?
            </prompt>
            <prompt cond="lang=='1' && count &lt; 3" xml:lang="hi-IN">
                 आप ने प्रवेश किया है <value expr="employee">. क्या यह सही है?
            </prompt>
            <grammar xml:lang="hi-IN" version="1.0"></grammar>
            <filled>
                <if cond="confirm=='2'">  <!-- if the user has given an incorrect employee code -->
                    <clear namelist="employee confirm"/>
                    <goto next="#ecode">
                <elseif cond="confirm=='1'"/> <!-- if the user has given correct employee code -->
                    <submit next="database.jsp" namelist="employee" method="get" /><!--<connect to database --> 
                <elseif />
                <prompt cond="lang=='2'"> the employee code you entered is invalid, please try again later.</prompt>
                <prompt cond="lang=='1'" xml:lang="hi-IN">  आपके द्वारा दर्ज कर्मचारी कोड अमान्य है, बाद में पुन: प्रयास करें.  </prompt><!--if the value of confirm is undefined --> 
                </if>
            </filled>
            <block>
                <if cond="stop=='4'">
                    <prompt cond="lang=='2'"> the employee code you entered is invalid, please try again later.</prompt>
                    <prompt cond="lang=='1'" xml:lang="hi-IN">  आपके द्वारा दर्ज कर्मचारी कोड अमान्य है, बाद में पुन: प्रयास करें.  </prompt>
                </if>
                <prompt cond="lang=='2'">  Thank you for calling! </prompt>
                <prompt cond="lang=='1'" xml:lang="hi-IN">  फोन करने के लिए धन्यवाद!  </prompt>
            </block>
        </field>    
    </form>
 </vxml>
adirocks27
  • 31
  • 1
  • 2
  • 7

1 Answers1

0

You will count repetitions yourself in the same way you are already doing it in your example. You will handle all possible errors in a catch block:no input, no match, and data error (your application custom event to handle invalid entries). Something along the lines:

<form>
    <catch event="nomatch noinput app.dataerror">
        <assign name="app_count" expr="app_count + 1"/> <!-- define it beforehand -->
        <if cond="app_count &lt; max_count/>">
            Please try again.
        <else/>
            Maximum number of attempts exceeded.
            <!-- Do something here -->
            <submit namelist="..." next="..."/>
        </if>
        <reprompt/>
    </catch>

    <field name="cardNumber" type="digits?length=16">
       Please enter a card number.</field>

    <subdialog name="res" namelist="cardNumber" src="..." method="post">
       <filled>
          <if cond="res.status == 'success'">
             <log> Card number input success </log>
             <submit next="..." method="post"/>
          <else/>
             <log> Card number input data error <value expr="res.status"/></log>
             <clear namelist="cardNumber res"/>
             <throw event="app.dataerror"/>
          </if>
              </filled>
      </subdialog>
</form>

You may add prompts with count attribute too.

dmitri
  • 3,183
  • 23
  • 28