| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<form> level will be given dialog scope, while variables declared at the <vxml> level will be given document scope. Variables declared at the <vxml> level within the application root document will inherit application scope.<form> of a document will not be available within the second <form>, unless it is passed along via a <submit>, or if it is explicitly assigned a higher scope while within the <form>.<block> or within a <field>. They will only be considered active when the application visits and executes these form items.
<value expr="application.MyVar"/>
<value expr="document.MyVar"/>
<value expr="dialog.MyVar"/>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">
<meta name="author" content="J. Richmond"/>
<meta name="copyright" content="2008 voxeo corporation"/>
<var name="first" expr="5" />
<var name="second" expr="10" />
<var name="third" expr="15"/>
</vxml>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1" application="root.xml">
<meta name="author" content="J. Richmond"/>
<meta name="copyright" content="2008 voxeo corporation"/>
<form id="A">
<block>
<prompt> The values are
<value expr="first"/>
<value expr="second"/>
<value expr="third"/>
</prompt>
<goto next="#B"/>
</block>
</form>
<form id="B">
<var name = "first" expr="50"/>
<var name = "second" expr="100"/>
<var name = "third" expr="150"/>
<!-- The above declarations will create new Form scoped variables -->
<block>
<prompt> Application scoped variables are:
<value expr="application.first"/> <!-- Value should be 5 -->
<value expr="application.second"/> <!-- Value should be 10 -->
<value expr="application.third"/> <!-- Value should be 15 -->
</prompt>
<prompt> Form level scoped vars are:
<value expr="first"/> <!-- Value should be 50 -->
<value expr="second"/> <!-- Value should be 100 -->
<value expr="third"/> <!-- Value should be 150 -->
</prompt>
<goto next="Leaf.xml"/>
</block>
</form>
</vxml>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" application="root.xml">
<meta name="author" content="J. Richmond"/>
<meta name="copyright" content="2008 voxeo corporation"/>
<form id="C">
<block>
<!-- Because we are out of the Main.xml document and out of
form 'B', any references to first, second, and third will be
to the application scope variables -->
<prompt> Application scoped variables are:
<value expr="first"/>
<value expr="second"/>
<value expr="third"/>
</prompt>
</block>
</form>
</vxml>
| ANNOTATIONS: EXISTING POSTS |
jongmagno
|
|
| how do you assign a value to a variable from a user input? | |
mikethompson
|
|
| Hi Jong,
You can assign values to user input simply by using slot values within your grammars. I could hit you with some example code but I see a perfect example located in our GSL documentation. You can find that here: http://docs.voxeo.com/voicexml/2.0/gslmultislot.htm This will give you an in depth look at Multi-slot grammars. Hope this helps, Mike Thompson Voxeo Extreme Support |
|
appalachiangypsy
|
|
| This tutorial is awesome. I found the info I needed. Thanks. | |
bsmith
|
|
| Thank you for the feedback! We always appreciate what our customers have to say.
Thanks again, Ben Smith Voxeo Corporation |
|
SSA_MarkPMiller
|
|
| Simple typo in example code:
The second document references a non-existant root application document. The root doc is named "Page1.vxml" and the second page references 'application="Page1.cfm"' Also, the goto in the first doc references a .cfm file when it should be a .vxml file as named in the code. Mark |
|
mikethompson
|
|
| Mark,
Good catch! :) This is defintely a mix up. I imagine Matt was using .cfm for no-caching headers when he was building the application for this tutorial. I'll certainly let him know of this slip up here and have him make any changes needed. Best, Mike Thompson Voxeo Corporation |
|
sarika
|
|
| Hello,
How can i access vxml declared variable in php code or how can i access php variable in voicexml code within the same document? |
|
raghu.ram
|
|
| looking answer for thr above question.....
-rag |
|
vanguill
|
|
| Hi,
Thanks in advance for any advice you can offer. I have a vxml file, seaslugs.vxml which is functioning as my document root. In seaslugs.vxml root file, I declare a variable with application scope (appSlugColor). I gather a value for appSlugColor variable from a user inside of a slugColor field of a form getSlugInfo form within the root document. Inside of the <filled> tag corresponding to the slugColor field, I assign the value gathered from the user to the application variable appSlugColor, using <assign name="application.appColor" expr="slugColor"/>. (I've also tried this from within script tags) Immediately following that assignment, I submit a couple of values (slugColor and slugShell) to a cgi script, which looks up the slug color in a MySQL database and returns a list of slugs of that color. After retrieving the slugs from the database, the cgi writes out a new vxml file (in which seaslugs.vxml is declared as the application) which tells the user what slugs were retrieved and then then redirects the user back to another form (called goodByeSSSS) within the original application root, seaslugs.vxml, using a <goto> tag. This all works, so what's my problem? Well, it is that the value of the appSlugColor variable is lost somewhere after the post and before getting back into the form at #goodbyeSSSS. Is what I am attempting to do completely wrong, or is this a syntax or scope question? I've include the seaslugs.vxml source below. This is a learning exercise for me, so any advice will be appreciated. Thanks, Linda ---------- <?xml version="1.0"?> <vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"> <property name="universals" value="help"/> <var name="myAppName" expr="'Sea Slug Survey System'" /> <var name="appSlugColor" /> <link next="#welcomeSSSS"> <grammar type="application/x-nuance-gsl" mode="voice">[main back begin]</grammar> </link> <link next="#goodbyeSSSS"> <grammar type="application/x-nuance-gsl" mode="voice">[exit quit bye goodbye]</grammar> </link> <form id="welcomeSSSS"> <block> <audio src="Welcome.wav"/> <prompt> the <value expr="application.myAppName"/>!</prompt> </block> <field name="needHelp"> <prompt>Do you require help identifying your slug?</prompt> <grammar type="application/x-nuance-gsl" mode="voice"> <![CDATA[ ;Match one of the enclosed terms [ ;Each line is recognized as a separate term ;Terms are separated by a space yes no ;Match either yes yep si or oui ;Square brackets are the same as OR [yes yep wee see] ;Parentheses require all of the enclosed terms to be matched (yes please) (no thanks) ] ]]> </grammar> <!-- The user was silent, restart the field --> <noinput> I did not hear you, please speak up. <reprompt/> </noinput> <!-- The user said something that was not defined in our grammar --> <nomatch> I do not understand those words. Please try again. <reprompt/> </nomatch> <!-- The user requested help --> <help> Please say, yes please, or, no thanks. </help> </field> <filled> <if cond="needHelp == 'yes'"> <prompt>I'm happy to help!</prompt> <goto next="#slugIdentHelp"/> <elseif cond="needHelp == 'yes please'"/> <prompt>You need polite help.</prompt> <goto next="#slugIdentHelp"/> <elseif cond="needHelp == 'no'"/> <prompt>You don't think you need help, but you will.</prompt> <goto next="#getSlugInfo"/> <elseif cond="needHelp == 'no thanks'"/> <goto next="#getSlugInfo"/> <else/> <prompt> You don't even know whether you need help. Let me tell you a few things. The caller i d number is <value expr="session.callerid"/> The called i d of this application is <say-as interpret-as="telephone"> <value expr="session.callerid"/> </say-as> </prompt> <goto next="#welcomeSSSS"/> </if> </filled> </form> <form id="slugIdentHelp"> <block><prompt>Okay. Let's walk through a few questions.</prompt></block> <field name="slugShell" slot="sShell"> <prompt> Does your slug have a shell? </prompt> <grammar type="application/x-nuance-gsl" mode="voice"> <![CDATA[[ [yes no] ]]]> </grammar> <filled> <if cond="slugShell == 'yes'"> <prompt>I'm sorry, I am not yet able to classify slugs with shells. This feature will be available in January of 2009. Returning to main menu. </prompt> <goto next="#welcomeSSSS"/> <elseif cond="slugShell == 'no'"/> <prompt> Okay then. </prompt> </if> </filled> </field> <field name="slugColor" slot="sColor"> <prompt> What color is your slug? </prompt> <grammar type="application/x-nuance-gsl" mode="voice"> <![CDATA[[ (?[light dark] [red]) { <sColor "red"> } [orange] { <sColor "orange"> } (*[light lemon] [yellow]) { <sColor "yellow"> } [green] { <sColor "green"> } [purple violet] { <sColor "purple"> } [pink fuscia] { <sColor "pink"> } [brown] { <sColor "brown"> } [white] { <sColor "white"> } (+[light dark baby royal] [blue]) { <sColor "blue"> } [black] { <sColor "black"> } ]]]> </grammar> <nomatch> I do not know that color. Please say: red, orange, yellow, green,light blue, dark blue, purple, violet, pink, brown, white, or black. <reprompt/> </nomatch> </field> <filled> <script> application.appSlugColor = 'fyoosha'; </script> <prompt> I just assigned <value expr="application.appSlugColor"/> too appSlugColor. Checking database for <value expr="slugColor$.utterance"/> slugs with index term <value expr="slugColor$.interpretation.sColor"/>. </prompt> <submit next="http://www.linguistland.net/~lcvg/cgi-bin/checkColors.cgi" namelist="slugShell slugColor" method = "get" /> <goto next="#goodbyeSSSS"/> </filled> </form> <form id="getSlugInfo"> <block><prompt>Great.</prompt></block> <field name="slugColor"> <prompt> What is the order of your slug? </prompt> <grammar type="application/x-nuance-gsl" mode="voice"> <![CDATA[[ headshield sapsucking seahare sidegill nudibranch noodibrank ]]]> </grammar> </field> </form> <form id="goodbyeSSSS"> <block> <prompt> Thank you for caring about <value expr="application.appSlugColor"/>. sea slugs. Goodbye. </prompt> </block> </form> </vxml> |
|
SSAUK_SIGDEV
|
|
| What is the correct method of reassigning a value to an application scoped variable within a subdocument or form? | |
mikethompson
|
|
| Hello,
Assuming you are using an application root document to contain your application scoped variables, you can change the value of a variable application-wide like so: [code] <assign name="application.starttime" expr="'2:40:19 PM'"/> [/code] Hope this helps, Mike Thompson Voxeo Corporation |
|
honey_singla85
|
|
| is it the same case with the ccxml???
I am declaring a var in ccxml and after that i am starting vxml dialogs from that ccxml file , can I access that variable in all leaf vxml scripts? |
|
honey_singla85
|
|
| OR
I am using this in ccxml and passing ANI as namelist to vxml, <dialogstart connectionid="connid1" prepareddialogid="dialogid1" src="'input.vxml'" namelist="ANI"/> now i want to make it an appliaction scoped variable in input.vxml, How I can do that how to fetch and assign this value to application scoped variable |
|
voxeoadam
|
|
| Hello,
Thank you for contacting Voxeo Support. 1. For your question "is it the same case with the ccxml??? ". Yes, you can assign value to variable as <assign name="application.starttime" expr="'2:40:19 PM'"/> in CCXML. 2. For "I am declaring a var in ccxml and after that i am starting vxml dialogs from that ccxml file , can I access that variable in all leaf vxml scripts?" If you declare one user variable, you should pass the variable in "namalist" attribute to Vxml, and then pick it up in VXML like "<var name="myVar1" expr="session.connection.ccxml.values.myVarname"/>". For more variable details, please check the link: http://docs.voxeo.com/ccxml/1.0-final/ccxml10_passtovxml.htm For the application variable, we can not access directly in deaf vxml, and I think you also need do as above way. 3. For "I am using this in ccxml and passing ANI as namelist to vxml, <dialogstart connectionid="connid1" prepareddialogid="dialogid1" src="'input.vxml'" namelist="ANI"/> ,now i want to make it an appliaction scoped variable in input.vxml, How I can do that how to fetch and assign this value to application scoped variable". I have done a sample script, you can follow it. CCXML: <?xml version="1.0" encoding="UTF-8"?> <ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml"> <var name="myState" expr="'init'"/> <var name="ANI"/> <eventprocessor statevariable="myState"> <transition state="init" event="connection.alerting"> <assign name="ANI" expr="event$.connection.protocol.sip.headers['x-sbc-from']"/> <log expr="'*********'+ANI"/> <assign name="myState" expr="'accepted'"/> <accept/> </transition> <transition state="accepted" event="connection.connected"> <assign name="myState" expr="'connected'"/> <dialogstart src="'testVxml.xml'" type="'application/voicexml+xml'" namelist="ANI" /> </transition> <transition state="connected"> <exit/> </transition> </eventprocessor> </ccxml> VXML: <?xml version="1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id="MainMenu"> <block> <assign name="application.valueFromCCxml" expr="session.connection.ccxml.values.ANI"/> <log expr="'****This is to assign ANI to application variable****'+application.valueFromCCxml"/> </block> </form> </vxml> In the meantime, if there is any other questions that we can further help just feel free to let us know. Regards Adam Kong Voxeo Support |
| login |
|