Page 1 of 1

Takes any answer?

Posted: Tue Jul 24, 2012 7:54 pm
by goochalba
Hi,

I am trying to set up a simple pin number authentication. And I have the following code

Code: Select all

<vxml version="2.0">
  <form id="getpin">
    <field name="pinnumber" type="digits">
      <grammar type="application/x-jsgf" mode="voice">
        8210
      </grammar>
      <prompt>
        Please say your login code.
      </prompt>
      <filled>
        <assign name="UserID" expr="'2'"/>
        <submit next="menu.jsp" namelist="UserID"/>
      </filled>
      <nomatch>
          You have entered an invalid pin. Try again.
          <reprompt/>
      </nomatch>
    </field>
  </form>
</vxml>

But it seems to take any answer and not just my pin. Any idea what I might be doing wrong?

Thanks!

Re: Takes any answer?

Posted: Wed Jul 25, 2012 10:22 am
by support
Hi,

You are using two grammars: the built in "digits" grammar and your own x-jsgf grammar. The "digits" grammar will accept all digits. To fix this, use only your own x-jsgf grammar.

Regards,
Plum Support

Re: Takes any answer?

Posted: Thu Jul 26, 2012 10:47 am
by goochalba
Ah ok I see. I was thinking that I had to make my grammar of a specific type. But I guess it doesnt matter it is smart enough to take input as digits. But lets say I had a custom grammar and I wanted them to say
"Eight thousand two hundred and ten"
versus
"Eight"
"Two"
"One"
"Zero"
?

And thanks so much for helping me resolve this!

Re: Takes any answer?

Posted: Thu Jul 26, 2012 2:12 pm
by support
Hi,

The current code that you have, once you remove the built-in digits grammar (type="digits"), that'll take care of the case where you want the user to say, "Eight thousand two hundred and ten".

The following code example can be used for the case where you want the user to say, "eight two one zero":

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>

<vxml version="2.0">
  <form id="getpin">
    <field name="pinnumber" type="digits?length=4">
      <prompt>
        Please say your login code.
      </prompt>
      <filled>
        <if cond="pinnumber==8210">
          <prompt>
            That's the correct pin.
          </prompt>
        <else/>
          <prompt>
            That pin is incorrect.
          </prompt>
          <clear namelist="pinnumber"/>
          </if>
      </filled>
      <nomatch>
          You have entered an invalid number of digits. Try again.
          <reprompt/>
      </nomatch>
    </field>
  </form>
</vxml>
Hope this helps.

Regards,
Plum Support