| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<?xml version="1.0" encoding="utf-8" ?>
<vxml version="2.1">
<meta name = "maintainer" content="yourEmail@somewhere.com"/>
<link next="F_Name.cfm">
<grammar type="text/gsl"> [start over] </grammar>
</link>
<form id="F1">
<field name="F_name">
<grammar src="FName.xml" type="application/grammar-xml"/>
<prompt>
Welcome to the login page for our application.
Please spell your first name so we can verify your credentials.
</prompt>
<nomatch>
<prompt>
Sorry, i didnt get that.
Please spell your first name.
</prompt>
</nomatch>
<noinput>
<prompt>
Look buddy, I dont have all day, and I dont recognize
M to the A double T as a valid first name.
Spell your first name, or quit wasting my time.
</prompt>
</noinput>
<filled>
<submit next="L_Name.cfm" namelist="F_name"/>
</filled>
</field>
</form>
</vxml>
<link> grammar at the <vxml> level, which will take a user back to the start of the application, regardless of where or when he utters the command in the <link> grammar. In subsequent documents, we will want to make sure that we reference this file as the application root in order to make this link active throughout the scope of the application. <submit> the results to our next page, which just so happens to gather a caller's last name. In looking at this next document, you will doubtlessly find it eerily familiar:
<?xml version="1.0" encoding="utf-8" ?>
<vxml version="2.1" application="F_Name.cfm">
<meta name = "maintainer" content="yourEmail@somewhere.com"/>
<form id="F2">
<field name="L_name">
<grammar src="LName.xml" type="application/grammar-xml"/>
<prompt>
Okay, great. Now spell your last name, and we will be on our way.
</prompt>
<nomatch>
<prompt>
Sorry, i didnt get that.
Please spell your last name.
</prompt>
</nomatch>
<noinput>
<prompt>
Look buddy, I dont have all day.
Spell your last name, or quit wasting my time.
</prompt>
</noinput>
<filled>
<submit next="Finish.cfm" namelist="L_name"/>
</filled>
</field>
</form>
</vxml>
<CFSILENT> tags, which will ensure that the ColdFusion doesn't insert any whitespace to our XML documents:
<CFSILENT>
</CFSILENT>
<CFAPPLICATION> tag, along with it's accompanying SESSIONMANAGEMENT and SETCLIENTCOOKIES attributes. While we are at it, let's also add the <CFCOOKIE> tag to add support for a session cookie in our application. This last is very important when using cookies with ColdFusion; if we don't set the 'CFID' and 'CFTOKEN' in the Application.cfm file, then we will have persistent cookies set by the ColdFusion Server. And as we all know, persistent cookies aren't kosher at all.
<CFSILENT>
<CFAPPLICATION NAME="MyApp" SESSIONMANAGEMENT="yes" SETCLIENTCOOKIES="Yes">
<CFCOOKIE NAME="CFID" VALUE="#CFID#"/>
<CFCOOKIE NAME="CFTOKEN" VALUE="#CFTOKEN#"/>
</CFSILENT>
<CFSILENT>
<CFAPPLICATION NAME="MyApp" SESSIONMANAGEMENT="yes" SETCLIENTCOOKIES="Yes">
<CFCOOKIE NAME="CFID" VALUE="#CFID#"/>
<CFCOOKIE NAME="CFTOKEN" VALUE="#CFTOKEN#"/>
<CFHEADER NAME="Cache-Control" VALUE= "no-cache">
<CFHEADER NAME="Expires" VALUE="#Now()#">
</CFSILENT>
<submit> element to pass VoiceXML variables to the ColdFusion side of things, we need to set up some logic in the Application.cfm file to recognize and catch these querystring values, and then assign them to ColdFusion session variables. Check out the highlighted code below:
<CFSILENT>
<CFAPPLICATION NAME="MyApp" SESSIONMANAGEMENT="yes" SETCLIENTCOOKIES="Yes">
<CFCOOKIE NAME="CFID" VALUE="#CFID#"/>
<CFCOOKIE NAME="CFTOKEN" VALUE="#CFTOKEN#"/>
<CFHEADER NAME="Cache-Control" VALUE= "no-cache">
<CFHEADER NAME="Expires" VALUE="#Now()#">
<CFPARAM NAME="session.F_name" DEFAULT=""/>
<CFIF isdefined('url.F_name')>
<CFSET session.F_name=url.F_name/>
</CFIF>
<CFPARAM NAME="session.L_name" DEFAULT=""/>
<CFIF isdefined('url.L_name')>
<CFSET session.L_name=url.L_name/>
</CFIF>
</CFSILENT>
<CFPARAM NAME="session.F_name" DEFAULT=""/>
<CFPARAM NAME="session.F_name" DEFAULT=""/>
<CFIF isdefined('url.F_name')>
<CFSET session.F_name=url.F_name/>
</CFIF>
<CFOUTPUT> elements. In addition, we also want to have the ability for a caller to re-enter the information if there has been a recognition mistake, and the interpreter gets either of the names wrong:
<?xml version="1.0" encoding="utf-8" ?>
<vxml version="2.1" application="F_Name.cfm">
<meta name = "maintainer" content="yourEmail@somewhere.com"/>
<CFOUTPUT>
<form id="F3">
<field name="confirm" type="boolean">
<prompt>
The Cold Fusion session variables tells me that your name is
#session.F_name# #session.L_name# , is that right?.
</prompt>
<filled>
<if cond="confirm == true">
<prompt>
Okay, #session.F_name#. Thanks for calling.
</prompt>
<else/>
<prompt>
Okay then, we will start from the beginning.
</prompt>
<goto next="F_name.cfm"/>
</if>
</filled>
</field>
</form>
</CFOUTPUT>
</vxml>
<ruleref> with the following syntax:
<ruleref uri="builtin:x-nuance-(WHATEVER)"/>
<tag> element matches up with the field slot itself:
<field name="F_name">
<tag><![CDATA[ <F_name $return> ]]> </tag>
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US"
root="MYRULE">
<rule id="MYRULE">
<one-of>
<item>
<ruleref uri="builtin:x-nuance-firstnamespelling"/>
<tag><![CDATA[ <F_name $return> ]]> </tag>
</item>
</one-of>
</rule>
</grammar>
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US"
root="MYRULE">
<rule id="MYRULE">
<one-of>
<item>
<ruleref uri="builtin:x-nuance-lastnamespelling"/>
<tag><![CDATA[ <L_name $return> ]]> </tag>
</item>
</one-of>
</rule>
</grammar>
<ruleref> element| ANNOTATIONS: EXISTING POSTS |
awirtz
|
|
| In the last name VXML page, your nomatch prompt mentions _first_ name.
You are berating callers just for trying to say "M to the A double T?" You have no idea... (well, maybe you do but are just too nice to corrupt the dreams of the uninitiated and impressionable by revealing the true limits of caller stupidity) |
|
MattHenry
|
|
| Hiya Aaron,
Thanks for the catch; I have corrected this oversight in our documentation. ~ M-A to the double T Henry |
|
danielvinson
|
|
| Hiya
Is there a version of this code that can be used on a static host i.e. the Voxeo server or do I have to arrange a CF server. Just trying to improve the accuracy of spelling a word. Thanks Daniel |
|
VoxeoBrian
|
|
| Hello,
You certainly would not have have to pass the variables via submit to a cold fusion server, you can simply implement this within the filled element. <prompt> You said <value expr="F_name"/> </prompt> I hope this helps to clarify this for you, if you need further assistance please do let us know, we are more then happy to help! Cheers Brian |
| login |
|