Page 1 of 1

Grammars doesn't work

Posted: Tue Nov 04, 2008 9:37 am
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.

Posted: Tue Nov 04, 2008 9:40 am
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>

IVR code to fix grammar issues

Posted: Tue Nov 04, 2008 3:07 pm
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

Posted: Wed Nov 05, 2008 5:05 am
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?

IVR grammar

Posted: Wed Nov 05, 2008 10:42 am
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