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

jsgf file format

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
xzhang
Posts: 4
Joined: Sun May 15, 2011 3:58 pm

jsgf file format

Post by xzhang »

I like to include an external jsgf grammar file but it always failed. What's the sample format of the grammar file?

I have following sample to test but failed

In VXML

<form id="test">
<field name="answer">
<grammar srcexpr="grammar_url' + '/menu/navigations2.gram'" type="application/x-jsgf"/>
</field>
</form>

In grammar file
#JSGF V1.0;

<![CDATA[
grammar navigations1;
public <navigations1> = [puppy|kitten|turtle];
]]>

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

Re: jsgf file format

Post by support »

Hi xzhang,

Here is a sample IVR application on how to include an external JSGF grammar file and how you can format your JSGF file:

xzhangexternalgrammar.php:

Code: Select all

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

?>
<vxml version="2.0">
<form id="test">
<var name="grammar_url" expr="'http://your.server.com/~xzhang/'"/>
<field name="answer">
<grammar srcexpr="grammar_url + 'remotegrammar.grxml'" type="application/x-jsgf"/>

<prompt>
Pick an animal: puppy, kitten, or turtle?
</prompt>

<filled>
<prompt>
You said <value expr="answer"/>.
</prompt>
</filled>
</field>
</form>
</vxml>
remotegrammar.grxml:

Code: Select all

<?xml version="1.0"?>
<grammar type="application/x-jsgf" mode="voice">
puppy | kitten | turtle
</grammar> 
From this example, the IVR application points to a remote grammar using the "srcexpr" attribute from the <grammar>. Within the remote grammar, note that the grammar type is set to a JSGF grammar that accepts a voice input match for either puppy, kitten, or turtle.

For more information on grammars, you can view our hosting documentation here:

http://www.plumvoice.com/docs/dev/devel ... ce:grammar
http://www.plumvoice.com/docs/dev/voicexml:tags:grammar

Hope this helps.

Regards,
Plum Support

xzhang
Posts: 4
Joined: Sun May 15, 2011 3:58 pm

Re: jsgf file format

Post by xzhang »

I have copied your sample code but I still got "missing ; in first line ...." javascript error

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

Re: jsgf file format

Post by support »

Hi xzhang,

Are you still having this error? We have tested this example again and haven't come across any issues with it.

Also, where are you copying this sample code into?

Regards,
Plum Support

Post Reply