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

Grammars doesn't work

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

Grammars doesn't work

Post by soso »

Hi,

I've a problem with a grammars.

I woule like a grammars wich have :

- only numerics chars (0.9) x 255 and terminate by #,
- or only #,
- or only *#.

I create this rule but it doesn't work:

Code: Select all

  <rule id="confirm_msg" scope="public">
    <one-of>

      <item>
        <item repeat="0-255">
          <ruleref uri="#digit"/>
        </item>
        #
      </item>
     
      <item> * # </item>
      <item> # </item>
    </one-of>
  </rule>
The field is like this:

Code: Select all

        <field name="confirm_message" type="digits?maxlength=255">
            <grammar src="grammars/service.grxml#confirm_msg" type="application/srgs+xml"/>
        </field>
    
Can you help me?

Thanks by advance.

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

Post by soso »

The #digit rule is like this:

Code: Select all

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

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

IVR code to fix grammar issues

Post by support »

Hi,

The following IVR code should help you accomplish the IVR <grammar> that you desire:

grammar.php

Code: Select all

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

<vxml version="2.0">

<form>
  <field name="confirm_message">
    <grammar root="confirm_msg" type="application/srgs+xml" mode="dtmf">
      <rule id="confirm_msg" scope="public">
        <one-of>
            <item repeat="0-255">
              <ruleref uri="#digit"/>
            </item>
          <item> * # </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>

    <prompt>
      Please enter some digits.
    </prompt>
    <filled>
      <if cond="confirm_message=='* #'">
        <prompt>
          You terminated out.
        </prompt>
      <elseif cond="confirm_message=='#'"/>
        <prompt>
          You terminated out.
        </prompt>
      <else/>
        You entered <value expr="confirm_message"/>.
      </if>
    </filled>
  </field>
</form>
</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Wed Feb 17, 2010 12:48 pm, edited 4 times in total.

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

Post by soso »

Hi,

Thanks for your answer. That's working...

I've many fields wich runs like this methods, but with some differences.

Example:

- only numerics chars, with #
- or #
- only 10 characters for phone number (for example).

Is it possible to create an external link to file, and how?

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

IVR grammar

Post by support »

Hi,

Could you clarify further what you mean by "creating an external link to file"? Do you mean that you want to reference an external IVR grammar file?

If that's the case, then you would want to use the "src" attribute in your IVR code for the IVR tag, <grammar>.

Regards,
Plum Support

Post Reply