Page 1 of 1

How can I use a different grammar for one field?

Posted: Wed Sep 02, 2009 7:36 am
by soso
Hi,

I've a field and I would like to use a different grammar if the field is call directely or not.

Like example:

Code: Select all

<form id="main">

<field name="phone" cond="enter==true">
<grammar src="builtin:dtmf/digits?minlength=1;maxlength=255" />

<filled>

</filled>

</field>

<field name="card">

</field>

</form>

If then enter value equal to true, the user type 2 fields with star pound on the card field.

If the user don't input the phone field, the user type the card field and doesn't use the "star pound"!

How can I process?

Thanks.

clarification on your IVR application

Posted: Wed Sep 02, 2009 9:48 am
by support
Hi,

Could you please clarify what you mean by this statement?
If the user don't input the phone field, the user type the card field and doesn't use the "star pound"!
Does this mean that if there is a <noinput> for the "phone" field in your IVR, that it'll skip to the "card" field and user wouldn't be able to input "star pound" for this field?

Regards,
Plum Support

Posted: Wed Sep 02, 2009 9:56 am
by soso
Ok, I clarify my problem:

on a one field, i would like to use two grammars wich use star key and not star key.

For more specific: I want to use a dynamic grammar fiill by one variable.

If the user type the phone field, he can reprompt by press "*". If not (by a special procedure), the star key is not valid.

I hope to help you.[/code]

IVR code example for remote grammars

Posted: Wed Sep 02, 2009 12:31 pm
by support
Hi,

To implement what you're looking for, you would need to create two remote IVR grammars in your IVR code. The following IVR example demonstrates how you can do this:

dynamic.php

Code: Select all

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

<form id="main">

<field name="phone" cond="enter==true">
<grammar src="builtin:dtmf/digits?minlength=1;maxlength=255" />

<filled>

</filled>

</field> 

<field name="card">
<grammar srcexpr="phone=='true' ? 'creditcardstar.grxml' : 'creditcard.grxml'" type="application/srgs+xml" maxage="0"/>

<prompt>
Please enter your card number.
</prompt>

<filled>
<prompt>
You have entered <value expr="card"/>.
</prompt>
</filled>

</field>

</form> 
</vxml>
creditcardstar.grxml:

Code: Select all

<?xml version="1.0"?>
<grammar type="application/srgs+xml" root="ROOT" version="1.0" mode="dtmf">
      <rule id="ROOT" scope="public">
        <one-of>
            <item repeat="0-255">
              <ruleref uri="#digit"/>
            </item>
          <item> "* #" </item>
        </one-of>
      </rule>

      <rule id="digit" scope="public">
        <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>
        </one-of>
      </rule> 
</grammar> 
creditcard.grxml:

Code: Select all

<?xml version="1.0"?>
<grammar type="application/srgs+xml" root="ROOT" version="1.0" mode="dtmf">
      <rule id="ROOT" scope="public">
        <one-of>
            <item repeat="0-255">
              <ruleref uri="#digit"/>
            </item>
        </one-of>
      </rule>

      <rule id="digit" scope="public">
        <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>
        </one-of>
      </rule> 
</grammar> 
From this IVR example, if you look in the "card" field, you'll see that the IVR grammar is set up in this way:

Code: Select all

<grammar srcexpr="phone=='true' ? 'creditcardstar.grxml' : 'creditcard.grxml'" type="application/srgs+xml" maxage="0"/>
This means that if "phone" was set to true (or whatever special implementation you are using for phone), it will use creditcardstar.grxml (the grammar that allows the user to enter the star pound key) as the grammar and if "phone" is not true, it will use creditcard.grxml (the grammar that doesn't allow the user to enter the star pound key).

Regards,
Plum Support

Posted: Thu Sep 03, 2009 2:32 am
by soso
Hi,

Great !

Is it possible to use both separated files of grammars inline the dynamic.php file?

need remote grammars specifically for your IVR application

Posted: Thu Sep 03, 2009 8:31 am
by support
Hi,

Sorry, but for your IVR implementation, you would need to use two remote IVR grammars. You would not be able to add these IVR grammars inline to dynamic.php.

Regards,
Plum Support