We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

How can I use a different grammar for one field?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

How can I use a different grammar for one field?

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

clarification on your IVR application

Post 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
Last edited by support on Fri Jan 08, 2010 3:11 pm, edited 3 times in total.

soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Post 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]

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code example for remote grammars

Post 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
Last edited by support on Tue Feb 16, 2010 12:33 pm, edited 3 times in total.

soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Post by soso »

Hi,

Great !

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

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

need remote grammars specifically for your IVR application

Post 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

Post Reply