Page 1 of 1

Multiple digit dtmf with grammar

Posted: Mon Jun 21, 2010 4:04 pm
by moose155
I am using grammar to determine a possible range of 13 choices -

<grammar type="application/x-jsgf" mode="dtmf" maxdigits="2">
( 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 )+
</grammar>

for single digit responses it works fine -

<filled>
<if cond="location==1">
<prompt>
You entered <value expr="location"/>.
</prompt>
</if>

This will evaluate to true if a 1 is pressed

<if cond="location==10">
<prompt>
You entered <value expr="location"/>.
</prompt>
</if>

But this if never evaluates to true if 10 is pressed

What am I missing

Re: Multiple digit dtmf with grammar

Posted: Tue Jun 22, 2010 8:26 am
by support
Hi moose155,

About your JSGF grammar, a couple of things:

1) The reason why the "10" never comes back as true is because the platform accepts the input as "1 0" (note the white space in between).

2) The "10", "11", and "12" will never be accepted as an input by the user. Instead, they would be seen as two separate entries of single digits.

3) Your grammar allows for incorrect inputs such as "99".

Instead, you should convert your JSGF grammar to an SRGS+XML grammar, since you only allow for 1 of 13 entries.

srgsgrammar.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form id="mainmenu">
  <field name="location">
    <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
      <rule id="ROOT">
        <one-of>
          <item>0</item>
          <item>1</item>
          <item>2</item>
          <item>3</item>
          <item>4</item>
          <item>5</item>
          <item>6</item>
          <item>7</item>
          <item>8</item>
          <item>9</item>
          <item>10</item>
          <item>11</item>
          <item>12</item>
        </one-of>
      </rule>
    </grammar>
      <prompt>
        Please enter a location.
      </prompt>
      <filled>
        <if cond="location==1">
          <prompt>
            You entered <value expr="location"/>.
          </prompt>
        <elseif cond="location==10"/>
          <prompt>
            You entered <value expr="location"/>.
          </prompt>
        <else/>
          <prompt>
            You entered <value expr="location"/>.
          </prompt>
        </if>
      </filled>
  </field>
</form>
</vxml>
Hope this IVR code helps you.

Regards,
Plum Support