| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<?xml version="1.0"?>
<vxml version = "2.0">
<form id="F1">
<field name="F_1">
<grammar src="NameGram.xml" type="application/grammar-xml" />
<prompt>
Please tell me your full name so I can verify you
</prompt>
</field>
<filled mode="all" namelist="F_1">
<prompt>
You name is <value expr="F_1"/>
<break strength="medium"/>
</prompt>
</filled>
</form>
</vxml>
<?xml version= "1.0"?>
<grammar xml:lang="en-US" root = "TOPLEVEL">
<rule id="TOPLEVEL" scope="public">
<item>
<!-- FIRST NAME RETURN -->
<item repeat="0-1">
<ruleref uri="#FIRSTNAME"/>
<tag>out.firstNameSlot=rules.FIRSTNAME.firstNameSubslot;</tag>
</item>
<!-- MIDDLE NAME RETURN -->
<item repeat="0-1">
<ruleref uri="#MIDDLENAME"/>
<tag>out.middleNameSlot=rules.MIDDLENAME.middleNameSubslot;</tag>
</item>
<!-- LAST NAME RETURN -->
<ruleref uri="#LASTNAME"/>
<tag>out.lastNameSlot=rules.LASTNAME.lastNameSubslot;</tag>
</item>
<!-- TOP LEVEL RETURN-->
<tag> out.F_1= out.firstNameSlot + out.middleNameSlot + out.lastNameSlot; </tag>
</rule>
<rule id="FIRSTNAME" scope="public">
<one-of>
<item> matt<tag>out.firstNameSubslot="matthew";</tag></item>
<item> dee <tag> out.firstNameSubslot="dee ";</tag></item>
<item> jon <tag> out.firstNameSubslot="jon ";</tag></item>
<item> george <tag>out.firstNameSubslot="george ";</tag></item>
<item> billy <tag> out.firstNameSubslot="billy ";</tag></item>
</one-of>
</rule>
<rule id="MIDDLENAME" scope="public">
<one-of>
<item> bon <tag>out.middleNameSubslot="bon ";</tag></item>
<item> double ya <tag> out.middleNameSubslot="w ";</tag></item>
<item> dee <tag> out.middleNameSubslot="dee ";</tag></item>
</one-of>
</rule>
<rule id="LASTNAME" scope="public">
<one-of>
<item> henry <tag> out.lastNameSubslot="henry "; </tag></item>
<item> ramone <tag> out.lastNameSubslot="dee "; </tag></item>
<item> jovi <tag> out.lastNameSubslot="jovi "; </tag></item>
<item> bush <tag> out.lastNameSubslot=""bush "; </tag></item>
<item> williams <tag> out.lastNameSubslot="williams "; </tag></item>
</one-of>
</rule>
</grammar>
<?xml version= "1.0"?>
<grammar xml:lang="en-US" root = "TOPLEVEL">
<rule id="TOPLEVEL" scope="public">
<item>
<!-- FIRST GROUP RETURN -->
<item repeat="0-1">
<ruleref uri="#FIRST"/>
<tag>out.firstSlot=rules.FIRST.firstSubslot;</tag>
</item>
<!-- MIDDLE GROUP RETURN -->
<item repeat="0-1">
<ruleref uri="#MIDDLE"/>
<tag>out.middleSlot=rules.MIDDLE.middleSubslot;</tag>
</item>
<!-- LAST GROUP RETURN -->
<ruleref uri="#LAST"/>
<tag>out.lastSlot=rules.LAST.lastSubslot;</tag>
</item>
<!-- TOP LEVEL RETURN-->
<tag> out.F_1= (out.firstSlot + out.middleSlot) * out.lastSlot; </tag>
</rule>
<rule id="FIRST" scope="public">
<one-of>
<item> one<tag>out.firstSubslot=1;</tag></item>
<item> two <tag> out.firstSubslot=2;</tag></item>
</one-of>
</rule>
<rule id="MIDDLE" scope="public">
<one-of>
<item> three <tag>out.middleSubslot=3;</tag></item>
<item> four <tag> out.middleSubslot=4;</tag></item>
<item> five <tag> out.middleSubslot=5;</tag></item>
</one-of>
</rule>
<rule id="LAST" scope="public">
<one-of>
<item> six <tag> out.lastSubslot=6; </tag></item>
<item> seven <tag> out.lastSubslot=7; </tag></item>
<item> eight <tag> out.lastSubslot=8; </tag></item>
</one-of>
</rule>
| ANNOTATIONS: EXISTING POSTS |
794L
|
|
| It appears there should be a <item> tag added immediately below the line containing "<!-- LAST NAME RETURN -->". Is that correct? | |
MattHenry
|
|
|
Hiya Warren, I can see the source of your confusion: Take a closer look at the tag nesting scheme, however: <rule id="TOPLEVEL" scope="public"> <!-- start of item tag --> <item> .. <!-- LAST NAME RETURN --> <ruleref uri="#LASTNAME"/> <tag>assign(c $return)</tag> </item> <!-- end of item tag --> Cheers, ~Matt |
|
polar
|
|
| I tried following this example exactly in order to create a dialogue that asks "How old are you?", and then responds by saying "oh, you are [number] years old".
<?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="AGEGRAM"> <rule id="AGEGRAM" scope="public"> <item> <item>i am</item> <item><ruleref uri="#NUMBERSUB"/> <tag>assign(a $return)</tag></item> <item>years old</item> </item> <tag><![CDATA[<age $a>]]></tag> </rule> . . . </grammar> I know that NUMBERSUB works fine. Right now is responds to "i am twenty years old" with "oh, you are i am [age] years old years old" (i.e. the entire utterance is returned, instead of just the age). The calling vxml code is: <form id="basic2"> <field name="age"> <grammar type="application/grammar-xml" src="agegram.grxml"/> <prompt><break strength="small"/>how old are you?</prompt> <filled> <prompt>oh, you are <value expr="age"/> years old</prompt> </filled> </field> </form> I cannot for the life of me spot how this differs from the code above. Any ideas? |
|
bsmith
|
|
| Hello polar,
It's kind of hard to say for sure without seeing your #NUMBERSUB but I would say it probably is not setting a custom return value. Make sure it uses the <tag> element like so: ___________________________ <rule id="NUMBERSUB" scope="private"> <one-of> <item> three <tag> return ("lying. You are not three") </tag> </item> </one-of> </rule> Let us know if you have any other questions! Best Regards, Ben Smith Voxeo Corporation |
|
polar
|
|
| <?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="AGEGRAM"> <rule id="AGEGRAM" scope="public"> <item> <item>i am</item> <item><ruleref uri="#NUMBERSUB"/> <tag>assign(a $return)</tag></item> <item>years old</item> </item> <tag><![CDATA[<age $a>]]></tag> </rule> <rule id="NUMBERSUB" scope="public" mode="voice"> <one-of> <item>zero<tag>return("zero")</tag></item> <item>one</item> <item>two</item> <item>three</item> <item>four</item> <item>five</item> <item>six</item> <item>seven</item> <item>eight</item> <item>nine</item> <item>ten</item> //shortened </one-of> </rule> </grammar> The entire grammar is posted above, with numbersub included. You were right that I didnt have the <tag> labels, but after testing (see "zero" for an example), adding them doesnt seem to do anything. I still have the same problem as before. Can you see any errors in my code? Thanks a lot! |
|
bsmith
|
|
| Hello polar,
Let me do some further testing regarding that in our labs and see what I can come up with. I'll post my results as soon as they are complete. Best Regards, Ben Smith Voxeo Corporation |
|
MattHenry
|
|
|
Hi there, In looking over your files, I think that this is essentially a case of making the source grammar over-complicated, and I'd like to offer you a more compact, "best practices" grammar structure that will serve your purpose. For this type of grammar, I don't see any need at all for a subgrammar structure; we can do this all in a single <rule>. Also notice the usage of <item repeat>, this allows your callers a lot more flexibility in utterances that can be captured: <?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="NUMBERSUB"> <rule id="NUMBERSUB" scope="public"> <item> <item repeat="0-1"> i am </item> <one-of> <item>one <tag>return("one_interp_value")</tag> </item> <!-- ETC --> <item>zero <tag>return("zero_interp_value")</tag> </item> </one-of> <item repeat="0-1"> years old </item> </item> </rule> </grammar> Hope that this helps illustrate, but if you have any additional questions, by all means let me know. Regards, ~Matthew henry |
|
Jenny
|
|
| Hi,
I need to develop a vxml application to accept the account number in both "dtmf" and "voice" mode. If user presses "0" or says "operator" I need to transfer out the call. How could I achieve it either by using inline /external grammar? I need this to be done in today itself..... Please help. I dont know the way to use both dtmf and voice grammar together.. Thanks in Advance, Jenny |
|
VoxeoBrian
|
|
| Hello,
To make this posting as easy to read as possible I will answer your questions in a segmented order. Your first question: "a vxml application to accept the account number in both "dtmf" and "voice" mode" This can be accomplished in GSL through the use of our built in grammars, with the implementation of type="digits" This will allow for the the capture of both DTMF and Voice input. IE: <field name="F_1" type="digits"> A link to the specific documentation on built in grammars is found here: http://docs.voxeo.com/voicexml/2.0/frame.jsp?page=gslbuiltins.htm To address your second question: If user presses "0" or says "operator" I need to transfer out the call. This can done with the use of 2 seperate grammars inline or external the choice is yours: <grammar type="text/gsl"> <![CDATA[ [ [(dtmf-1)] {<F_1 "one">} ] ]]> </grammar> This can be used to capture the DTMF press of 1 to transfer to the operator as you desired. A separate grammar will have to used in order to capture a user utterance for "operator". This is very simple to accomplish: IE: <field name="F_1"> [(Operator)] You desire to have DTMF 1 and operator transfer the caller out at anytime. It is important to know that this will require the Link element to make the choices available throughout the entire document. This element can be implemented as such: <link event="something" message="'something'"> <grammar type="text/gsl"> [democrats republicans]</grammar> </link> So the grammars you create for both DTMF 1 and the user utterance for operator will have to be contained in a link element. Additionally as you may have an issue with a caller entering a 0 as part of their account #, thus triggering the operator transfer. The field attribute Modal can be used to temporarily stop the grammars from listening for 0, thus giving you the desired functionality. This is an attribute of the field element and is discussed and examples provided in our documentation here: http://www.vxml.org/frame.jsp?page=grxmlsubg.htm&bm=1 Modal Defined: The modal attribute is a Boolean value that allows fine grained control of active grammars within the field. When the modal attribute is set to false (default), then all higher scoped grammars are enabled, (i.e., form-level document/dialog scoped grammars) while a user is within the field. If the modal attribute is set to true, then only field grammars are enabled and all other grammars are temporarily disabled. Hope this helps, and if you have any other questions feel free to ask. Cheers Brian |
|
Jenny
|
|
| Hi Brian,
Thank you very much for your detailed answer. According to my project specification I need to do that with .grxml grammar. Is that same task(getting input both in voice and dtmf) possible with GRXML by any way? If this requirement can be accomplished only thro gsl, I have few more doubts. My form will prompt the user as follows " Enter or say your account number to get your account details. At any time you can press "0" or say "Operator" to speak with Customer Service Representative". So with in a <field> element, I will prompt this message to the caller. And for some reasons I could not use, <link> in my application. So now my question is how could I bundle these 3 grammars(viz., 1. Grammar to get account number thro voice and dtmf, 2. Grammar to get "0" as DTMF input and 3. Grammar to get "operator" thro voice) to make a single slot to be filled? or how can I call more than one grammar to accomplish my task? As I m new to gsl grammar, I m not getting any idea to do this.. can u help? Thanks in advance Jenny |
|
VoxeoBrian
|
|
| Hello,
There are ways to accomplish the same task in GRXML as we were able to in GSL. I have cooked up an example using both GSL an GRXML grammars to give you a basis for your coding. I have commented the code to aid you in understanding. <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <meta name="author" content="Matthew Henry"/> <meta name="copyright" content="2005 voxeo corporation"/> <meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/> <catch event="MyEvent"> <prompt>we caught a link event</prompt> </catch> <!-- Here is the implementation of the link event, and a GRXML grammar that catches both voice for operator and DTMF for 0 --> <link event="MyEvent" dtmf="0"> <grammar xml:lang="en-US" root = "TOPLEVEL"> <rule id="TOPLEVEL" scope="public"> <one-of> <item> 0 </item> <item> operator </item> </one-of> </rule> </grammar> </link> <form id="F1"> <!-- Because of the built in grammars already provided within GSL it is much easier to accomplish the capturing of an account number using the built in type=digits attribute. If you would like to build your own GRXML grammar I have provided a link to documentation that will help you in the process. --> <field name="F_1" type="digits?length=3"> <!-- http://docs.voxeo.com/voicexml/2.0/grxml_dtmf.htm --> <prompt> please enter your acccount # </prompt> </field> <filled> <prompt>we caught a field match. </prompt> </filled> </form> </vxml> Hope this helps, and if you have any more questions please feel free to ask. Cheers Brian |
|
nitink
|
|
| hi,
i am new to grxml grammars. I wanted to develop user interface which accepts pin as voice input and i need to validate it from database. I am using vxml 2.0. How to incorporate it and how to write grxml for that? I have attempted following grxml: <?xml version="1.0"?> <grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" xmlns:nuance="http://voicexml.nuance.com/grammar" xml:lang="en" tag-format="Nuance" root="vdigits" version="1.0"> <rule id="number" mode="voice"> <one-of> <item>one</item> <item>two</item> <item>three</item> <item>four</item> <item>five</item> <item>six</item> <item>seven</item> <item>eight</item> <item>nine</item> <item>zero</item> </one-of> </rule> <rule id="vdigits" scope="public"> <item repeat="1-15"> <ruleref uri="#number" /> </item> </rule> </grammar> DTMF input is working fine but How can I take combined 4 digit number as voice input and pass it for validation from database? |
|
VoxeoBrian
|
|
| Hello,
I am glad to see you have got your grammar file functioning properly. As far as aiding in the integration of server side elements such as a databases, we generally do not offer support for this. The reason why, is server side scripting is a fairly time intensive procedure and would likely slow our support efforts to a grinding halt. However if you do have any questions related to one our supported languages, we are more then happy to assist! Cheers Brian |
|
nitink
|
|
| Hi Brian,
Thanks for the support and reply. But the problem what I am getting is in entering the voice input of pin in vxml.. Kindly help me out. How to write grxml in external file to confirm the voice input of say 4 digit pin and how to get back the confirmed pin in vxml whole pin in string format so that I can transfer it to the backend?? Also, I am using Nunace 8.5 ASR Please help me out regarding this. I need it urgently |
|
VoxeoBrian
|
|
| Hello,
I have whipped up some sample code for you that illustrates a GRXML grammar which expects voice input for capturing the numbers 1-4, and return their numeric value. These return values are now associated with a slot value, and can be passed back to your back end database. As far as providing a code example for doing so, as I mentioned previously our support for server side elements is extremely limited, and I wouldn't be able to provide this for you. However if you do have any more questions, as always we are more then happy to help. <?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root = "MYRULE"> <rule id="MYRULE" scope="public"> <one-of> <item> one won <tag> <![CDATA[ <MySlot "1"> ]]> </tag> </item> <item> two too <tag> <![CDATA[ <MySlot "2"> ]]> </tag> </item> <item> three <tag> <![CDATA[ <MySlot "3"> ]]> </tag> </item> <item> four <tag> <![CDATA[ <MySlot "4"> ]]> </tag> </item> </one-of> </rule> </grammar> Cheers Brian |
|
wafa
|
|
| i need to developpe a pplication that let to user convert GSL to GRXML, please can you help me | |
voxeojeff
|
|
| Hello,
I'm afraid I'm a bit puzzled by this request. Can you elaborate a bit on what exactly you are attempting to do here? i.e., the call flow of the application, etc. Once we have a bit more information we should be able to offer up the best possible advice and/or solution. :-) Best, Jeff Menkel Voxeo Corporation |
|
meksof1
|
|
| Hello,
I need to build an external file with GRXML grammar. The user say the sentence "I would like to consult" or "consult the stock" or any sentence contain the word consult , the returned value is "consult".If the user say "I would like to modify" or "modify the stock" or any sentence contain "modify", the returned value is "modify". Thinks in Advance |
|
MattHenry
|
|
|
Hi there, I think that this inquiry is best boiled down to "how can add optional prefixes and suffixes to a grammar?" As chance has it, I happen to have some sample code on this specific topic, which I will post below so that you will have a decent starting point for your development efforts: [color=blue] <?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="INTRO"> <rule id="INTRO"> <one-of> <item> <!-- PREFIX --> <item repeat="0-1"> can i </item> <one-of> <item> repeat </item> </one-of> <tag> <![CDATA[ <MySlot "repeat"> ]]> </tag> <!-- SUFFIX --> <item repeat="0-1"> please </item> </item> </one-of> </rule> </grammar> [/color] Hope this helps, ~Matt |
|
virtualme123
|
|
| Hello,
I'm just starting out with VoiceXML2.0 and am interested in creating an interrupt that can be picked up across the whole document when a # is pressed. I've looked at the following: <form scope="document"> <link next"#menu"> <grammar mode="dtmf" version="1.0" root="root"> <rule id="root" scope="document"> <one-of> <item> # </item> </one-of> </rule> </grammar> </link> </form> ... which I hoped would do what I wanted however I'm struggling to find any consistant answers to my problem. Can anyone help? Thanks, Chris |
|
VoxeoDustin
|
|
| Hey Chris,
When you want to use a document scoped link, you'll need to scope it at the VXML level, e.g: <vxml version="2.1"> <link next"#menu"> <grammar mode="dtmf" version="1.0" root="root"> <rule id="root" scope="document"> <one-of> <item> # </item> </one-of> </rule> </grammar> </link> ... </vxml> Alternately, you could create an application level link grammar by specifying a root document, and placing your link element at the vxml scope in that document, making the link grammar valid in any document that defines the root document. http://docs.voxeo.com/voicexml/2.0/vxml.htm Cheers, Dustin |
|
virtualme123
|
|
| Hello Dustin,
Thanks for your quick reply, but I'm still unable to get the script to react to the # key being pressed. Is it something I am getting wrong with the prompts I'm using? I've looked at bargeintype of speech for instance, is that necessary for it to work because it doens't seem to work for me. Here is my updated example: <vxml xmlns="http://www.w3.org/2001/vxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd" version="2.0"> <property name="bargeintype" value="dtmf"/> <link next="#menu"> <grammar mode="dtmf" version="1.0" root="root"> <rule id="root"> <one-of> <item>#</item> </one-of> </rule> </grammar> </link> <form id="test"> <block><prompt>Hello this is a long sentence consisting of words that I am speaking to you with the aid of my voice</prompt></block> </form> <form id="menu"> <block>Hello!!!</block> </form> </vxml> Can you see anything you wouldn't expect or recommend? Cheers, Chris |
|
voxeojeremyr
|
|
| Hi Chris,
What you will want to do is to tell the VXML browser that you expect some kind of input from this form for that grammar to be active. I put in the <field> attribute like this: .. <form id="test"> <block><prompt>Hello this is a long sentence consisting of words that I am speaking to you with the aid of my voice</prompt></block> <field> <prompt>Testing</prompt> </field> </form> <form id="menu"> <block>Hello!!!</block> .. I tested it and when I pressed the pound sign ('#') it barge through correctly and played the Hello!! message. Thanks, Jeremy Richmond Voxeo Support |
|
naika
|
|
| I try to enter a combination of digits,* and # using below grammer. But the voice browser deletes 2 numbers before # if i enter "12#4". All works well if i enter "123#". Can u please suggest me a better way to write grammer?
<?xml version='1.0'?> <grammar xml:lang="ja-JP" mode="dtmf" version="1.0" root="digit_dtmf" xmlns="http://www.w3.org/2001/06/grammar" tag-format="swi-semantics/1.0" > <rule id="digit_dtmf" scope="public"> <ruleref uri="#DTMF" /> </rule> <rule id="DTMF"> <item repeat="4"> <ruleref uri="#DIGIT"/> </item> </rule> <rule id="DIGIT"> <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> <item> * </item> <item> # </item> </one-of> </rule> </grammar> |
|
voxeoJeffK
|
|
| Hello,
We are somewhat guessing without seeing the log output from a call, but my guess is that you have not reassigned the termination character. The default termchar is "#". To change it you set: <property name="termchar" value="A"/> Give that a try, and if you still have difficulties, I would recommend opening a Support ticket, and attach a log of a test call for us to review. Regards, Jeff Kustermann Voxeo Support |
|
borjomez
|
|
| If I only say 1st and last names, the example above plays the name back like "Firstname Undefined Lastname".
how and where do I check if the caller has entered the optional value? |
|
VoxeoDustin
|
|
| Hello,
This is expected, as the first name and middle name rules are optional. You can assign the first and middle name variables an empty value at the top level of the grammar to alleviate this: <rule id="TOPLEVEL" scope="public"> <tag> out.firstNameSlot = ""; out.middleNameSlot = ""; </tag> Now the variables are both empty strings. If we do not speak a first or middle name, they will simply return nothing instead of undefined. Let me know if this does the trick for you. Regards, Dustin Hayre Customer Support Engineer II Voxeo Support |
|
borjomez
|
|
| When calling a GRXML script from a VXML script, can I pass any custom data to GRXML, or should I use PHP or similar for that?
|
|
voxeojeremyr
|
|
| Hello,
The <grammar> element does not have any attributes for passing parameters to a GRXML script. I believe that you are wanting to have dynamic grammars. If that is the case, we would recommend that this be done with some server side scripting such as PHP or JSP. Please let us know if you have any additional questions. Regards, Jeremy Richmond Voxeo Support |
|
mf.mctear
|
|
| I am trying to return an ECMAScript object from the recognition of a sentence but am unable to access the object although I can see it in the log file. The example is based on an example in the SISR spec.
The recognition result in the log file is: Speech recognition result 0: | _interpretationconfidence=0.46 | _marktime=1500 | _confidence=0.46 | SWI_literal=I would like a small pepsi | order={liquid:"pepsi",drinksize:"small"} | vmlslot0=I would like a small pepsi | _grammar_id=0 | _inputmode=voice | _utterance=I would like a small pepsi in which the object is: order={liquid:"pepsi",drinksize:"small"} I am only able to return the following: last result[object Object] field result[object Object] Grammar file <?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" tag-format="semantics/1.0" root = "order"> <rule id="order"> I would like a <ruleref uri="#drink"/> <tag>out.order= new Object(); out.order.liquid=rules.drink.type; out.order.drinksize=rules.drink.drinksize;</tag> </rule> <rule id="drink"> <ruleref uri="#foodsize"/> <ruleref uri="#kindofdrink"/> <tag>out.drinksize=rules.foodsize; out.type=rules.kindofdrink;</tag> </rule> <rule id="foodsize"> <tag>out="medium";</tag> <!-- "medium" is default if nothing said --> <item repeat="0-1"> <one-of> <item>small<tag>out="small";</tag></item> <item>medium</item> <item>large<tag>out="large";</tag></item> <item>regular<tag>out="medium";</tag></item> </one-of> </item> </rule> <rule id="kindofdrink"> <one-of> <item>coke</item> <item>pepsi</item> <item>coca cola<tag>out="coke";</tag></item> </one-of> </rule> </grammar> VoiceXML file <?xml version="1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id = "drinks"> <field name = "drink"> <prompt> what would you like to drink? </prompt> <grammar src="drinks_object.grxml" mode="voice"/> </field> <filled> last result <value expr = "lastresult$.interpretation.order" /> field result <value expr = "drink" /> </filled> </form> </vxml> |
|
voxeojeremyr
|
|
| Hello,
The reason you are getting "Object Object" is that both the field value 'drink' and lastresult$.interpretation.order are objects. Within the grammar order is defined as an object with two properties, drinksize and liquid. To list out the contents in a log file you can use the JSON function stringify. I modified your code and ran a test on my machine here. Below are the changes I made [code] ... ... <filled> <log expr="'last response: ' + JSON.stringify(lastresult$.interpretation.order)"/> <prompt> last result <value expr = "lastresult$.interpretation.order.drinksize" /> <value expr = "lastresult$.interpretation.order.liquid" /> </prompt> <log expr="'field: ' + JSON.stringify(drink)"/> <prompt> field result <value expr = "drink" /> </prompt> </filled> ... ... [/code] Please let me know if you have any questions. Regards, Jeremy Richmond Voxeo Support |
|
mf.mctear
|
|
| Jeremy,
Thanks. That works now - except I changed the output to give me the object structure: i.e. from field result <value expr = "drink" /> to field result <value expr = "JSON.stringify(drink)" /> I am now trying to create an array, based also on example in SISR, but get a content error at the point <tag>out.push(rules.account_names); </tag> The system runs ok if I comment out that line. Is there a different way to add to the array? Code below. Thanks, Mike <?xml version="1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id="getdetails"> <field name="accounts"> <prompt> <break time="2000"/> please list your accounts </prompt> <grammar xml:lang="en-US" tag-format="semantics/1.0" root = "accounts"> <rule id="accounts" scope="public"> <tag> out=new Array;</tag> <ruleref uri = "#account_names" /> <tag>out.push(rules.account_names); </tag> <item repeat = "1-"> and <ruleref uri = "#account_names" /> <tag>out.push(rules.account_names); </tag> </item> </rule> <rule id="account_names" scope="public"> <one-of> <item> savings </item> <item>current</item> <item>business</item> </one-of> </rule> </grammar> </field> <filled> <prompt> you have the following accounts <value expr="JSON.stringify(accounts)"/> </prompt> </filled> </form> </vxml> |
|
voxeojeremyr
|
|
| Hello,
There were a couple of issues within your code. The first was that you need to declare a value coming from the internal rule. Also, you cannot declare out as a type Array, you have to create a property of out, and make that an array. Here is the modified code that tested successfully for me. [code] <?xml version="1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id="getdetails"> <field name="accounts"> <prompt> <break time="2000"/> please list your accounts </prompt> <grammar xml:lang="en-US" tag-format="semantics/1.0" root = "ACCOUNTS"> <rule id="ACCOUNTS" scope="public"> <tag>out.accounts = new Array;</tag> <ruleref uri = "#ACCOUNT_NAMES" /> <tag>out.accounts.push(rules.ACCOUNT_NAMES.account_names); </tag> <item repeat = "1-"> and <ruleref uri = "#ACCOUNT_NAMES" /> <tag>out.accounts.push(rules.ACCOUNT_NAMES.account_names); </tag> </item> </rule> <rule id="ACCOUNT_NAMES" scope="public"> <one-of> <item>savings <tag> out.account_names = "savings"; </tag> </item> <item>current <tag> out.account_names = "current"; </tag></item> <item>business <tag> out.account_names = "business"; </tag></item> </one-of> </rule> </grammar> </field> <filled> <prompt> you have the following accounts <value expr="JSON.stringify(accounts)"/> </prompt> </filled> </form> </vxml> [/code] Please let me know if you have any questions. Regards, Jeremy Richmond Voxeo Support |
| login |
|