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

Need help in GRXML grammar

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
aravindm
Posts: 14
Joined: Mon Mar 30, 2015 10:40 am

Need help in GRXML grammar

Post by aravindm »

I am using the below GRXML grammar in IVR application. It always throws nomatch. Please help me to resolve it. If you could provide sample ASR and dtmf GRXML grammar for digits grammar (Ex: phonenumber or zipcode) for reference will be very helpful.

accesscode.grxml

Code: Select all

<?xml version= "1.0"?>
<grammar mode="dtmf"
         root="ROOT"
         type="application/srgs+xml" >		 
 
<rule id="ROOT" scope="public">
	 <item repeat="1-3"> 
	     <ruleref uri="#digits"/>              	
	 </item> 
</rule> 

<rule id="digits" scope="public>  
     <one-of> 
	 <item>0 <tag>SWI_literal="0"</tag></item> 
	 <item>1 <tag>SWI_literal="1"</tag></item> 
	 <item>2 <tag>SWI_literal="2"</tag></item> 
	 <item>3 <tag>SWI_literal="3"</tag></item> 
	 <item>4 <tag>SWI_literal="4"</tag></item> 
	 <item>5 <tag>SWI_literal="5"</tag></item> 
	 <item>6 <tag>SWI_literal="6"</tag></item> 
	 <item>7 <tag>SWI_literal="7"</tag></item> 
	 <item>8 <tag>SWI_literal="8"</tag></item> 
	 <item>9 <tag>SWI_literal="9"</tag></item>
     </one-of> 
</rule> 
</grammar>
Vxml snippet:

Code: Select all

<form id="frm_accesscode">
<field name="access_code">
<prompt>Enter 3 digit access code</prompt>
<grammar type="application/srgs+xml" mode="dtmf" src="http://.../accesscode.grxml" />
<filled>
 Entered access code is <value expr="access_code" />
<goto next="#frm_accesscode" />
</filled>
<nomatch>
....
</nomatch>
<noinput>
...
</noinput>
</field>
</form>

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

Re: Need help in GRXML grammar

Post by support »

Hello aravindm,

Based on what you're trying to accomplish here we believe an inline grammar would be best. There is no need for the literal tag on numbers as they are already set. Attached below is code that performs what you are trying to do. It will prompt the user for 3 digit access code and recite the code back then reprompt like yours does.

Code: Select all

<?xml version= "1.0"?>
<vxml version="2.1">
    <form id="frm_accesscode">
     <field name="access_code">
      <prompt>Enter 3 digit access code</prompt>
        
        
<grammar type="application/srgs+xml" mode="dtmf" root="ROOT">
 <rule id="ROOT" scope="public">
  <one-of>
   <item repeat="1-3">
    <ruleref uri="#digits"/>
   </item>
  </one-of>
 </rule>

 <rule id="digits" 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>


  <filled>
   <prompt>Entered access code is <value expr="access_code" /></prompt>
   <goto next="#frm_accesscode" />
  </filled>

  <nomatch>
   I'm sorry I didn't catch that.
   <reprompt/>
  </nomatch>
  
  <noinput>
   Nothing was entered. Please try again.
  </noinput>
 </field>
</form>
</vxml>
The following example demonstrates how you can use a builtin digits grammar to restrict a digit entry between a minimum number of digits and a maximum number of digits:

Code: Select all

<?xml version="1.0"?> 
<vxml version="2.0">
  <form>
    <field name="userid" type="digits?minlength=5;maxlength=7">
      <prompt>
        Please say your user identification number.
      </prompt>
      <filled>
        You entered <value expr="userid"/>.
      </filled>
    </field>
  </form>
</vxml>
You can find more information regarding built-in grammars on our DEV site here: http://www.plumvoice.com/docs/dev/devel ... n_grammars

Please let us know if you have anymore questions.

Regards,
Plum Support

Post Reply