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

New to VXML--possible to set a grammar globally?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
jallard
Posts: 21
Joined: Mon Oct 03, 2011 7:20 am

New to VXML--possible to set a grammar globally?

Post by jallard »

Hello I am extremely new to VXML. Writing a very basic IVR, with only DTMF being used. I wanted to know if there was a way to set the DTMF grammar in the xml file globally, so that I don't have to specify it on each form. I was reading the developer's documentation, and from my reading it looks like the grammar tag can only be a child tag of the form tag. So I can't specify it unless it's within a form. At least that's what I gather. I will probably be posting a lot of ignorant questions on here so please forgive me in advance.

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

Re: New to VXML--possible to set a grammar globally?

Post by support »

Hi jallard,

Unfortunately, there is no good way to properly create this global-level grammar. We recommend creating an external GRXML file that you could then reference within the field tags.

main.php:

Code: Select all

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

<vxml version="2.0">
  <form>
    <field name="number">
      <grammar src="http://www.example.com/grammars/grammar.grxml" type="application/srgs+xml"/>
      <prompt>
	Enter a number between 1 and 4.
      </prompt>
      <filled>
	<prompt>
	  You entered: <value expr="number"/>
	</prompt>
      </filled>
    </field>
  </form>
</vxml>
grammar.grxml:

Code: Select all

<?xml version="1.0"?>
<grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
  <rule id="ROOT">
    <one-of>
      <item> 1 </item>
      <item> 2 </item>
      <item> 3 </item>
      <item> 4 </item>
    </one-of>
  </rule>
</grammar>
This will allow you to declare your grammar in one location while referencing it in multiple locations throughout your application.

Regards,
Plum Support

Post Reply