| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<field>, will default to the fieldname itself. The use of grammar slots comes in handy when we want to reuse a grammar in more than one <field>, as evidenced in the example below:<?xml version="1.0"?>
<vxml version="2.0">
<form>
<field name="F_1" slot="MySlot">
<grammar src="GrammarFile.gsl#MYRULE" type="text/gsl"/>
<prompt>
what is your favorite cheese?
</prompt>
<filled namelist="F_1$.interpretation.MySlot">
<prompt>
You said <value expr="F_1$.interpretation.MySlot"/>
</prompt>
<goto nextitem="F_2"/>
</filled>
</field>
<field name="F_2" slot="MySlot">
<grammar src="GrammarFile.gsl#MYRULE" type="text/gsl"/>
<prompt>
what is your least favorite cheese?
</prompt>
<filled namelist="F_2$.interpretation.MySlot">
<prompt>
You said <value expr="F_2$.interpretation.MySlot"/>
</prompt>
</filled>
</field>
</form>
</vxml>
MYRULE [
[cheddar] {<MySlot "cheddar">}
(?monteray jack) {<MySlot "jack">}
(+stinky french cheese) {<MySlot "stinky">}
]
| ANNOTATIONS: EXISTING POSTS |
declanh
|
|
| Hi,
In the field element you can specify the slot to use from the grammar. Can you specify more than one? If you have a multi slot grammar do you have to use the individual specified slot from the application.lastresult$ array (Read it directly in the filled)? Example: <field name="AlphaNum_201" modal="true" cond="AlphaNum_201_Active" slot="confirm"> <if cond="dialog.AlphaNum_201$.interpretation == 'yes'"> OR <if cond="application.lastresult$[0].interpretation.confirm == 'yes'"> For example, with these three, if you did not specify the slot as a field attribute, which slot will be used? The first returned? application.lastresult$.interpretation.number application.lastresult$.interpretation.date application.lastresult$.interpretation.confirm <assign name="AlphaNum" expr="dialog.AlphaNum_201$.interpretation"/> what would you expect to see in the AlphaNum variable? All the slots, or just the first? (Assuming no slot specified) Any comments appreciated! Thanks, Declan |
|
voxeoblehn
|
|
| Hello Declan,
Just wanted to update you quickly and let you know we are in the process of putting together some additional information for you on this. We look to have an additional update for you shortly, kindly stay tuned. Regards, Brian Lehnen Voxeo Support |
|
VoxeoDustin
|
|
| Declan,
The slot attribute of the field element is unnecessary, but will determine the default slot to use with lastresult$.interpreation. When your grammar contains multiple slots, the lastresult$.interpretation variable will be an object with properties equivalent to each slot name. If you specify multiple slots, the value of lastresult$.interpretation - or fieldname$.interpretation, will be returned as "Object". Let me know if we can be of further assistance. Regards, Dustin Hayre Solutions Engineer Voxeo Corporation |
|
declanh
|
|
| Hi Dustin,
Thanks. Is there a way to get the names of the properties (That is, the slotnames)? That would be very useful. Thanks again, Declan |
|
MattHenry
|
|
| Helklo Declan,
I think the best way to answer this inquiry is with a code sample that illustrates how you can get at these slot values themselves, which can be found [url=http://www.vxml.org/gslmultislot.htm]right here[/url]. In regards to determining which slots are present in an arbitrary fashion, I'd suggest that you set the following in your <filled> element: [code]<assign name="myObj" expr="application.lastresult$"/> <log expr="'*******' + JSON.stringify(myObj)"/> [/code] This will give you the "raw" values of the lastresult Object, which you can then access independently by crafting a foreach loop either via ECMAScript, or via the <foreach> VXML element. Cheers, ~Matthew Henry |
| login |
|