CCXML: short tutorial on how to use VoiceXML2.1's data tag to talk to CCXML

Hello www-voice,

I've received a couple of emails that indicate there is some confusion
on how to use the VXML <data> tag to send information to CCXML.

Specifically, here is how to process test #447 of 7_2.txml in the CCXML 
test suite.

Here is an explanation of how our SPOT browser does this.

The VXML below is 7_2_data.vxml from the CCXML IR test suite.
-----------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US">
<!--
     Release 1.1 - 2010-10-22
     FIXED: ISSUE-726: version 2.1 replaced by  version 2.1 (This is 
VoiceXML 2.1, actually)
-->

<var name= "data" expr="'Test'"/>
<var name="name" expr="'dialog.user.test'"/>
<var name="dialogid" expr="session.connection.ccxml.dialogid"/>
<var name="sessionid" expr="session.connection.ccxml.sessionid"/>
<var name="connectionid" expr="session.connection.ccxml.connectionid"/>
<var name="processorType" 
expr="session.connection.ccxml.values.IO_ProcessorType"/>
<var name="params_to_pass" expr="undefined"/>
<script>
         params_to_pass = new Object();
</script>

<catch event="connection.disconnect.hangup">
<exit namelist="data"/>
</catch>
<form>
<block>
<assign name="params_to_pass.a" expr="1"/>
<assign name="params_to_pass.b" expr="'2'"/>
<data srcexpr="processorType"  namelist="dialogid sessionid name 
connectionid params_to_pass.a params_to_pass.b" method="post"/>
</block>
</form>
</vxml>
-----------------------------
Note that because passing objects via HTTP has undefined behavior, the 
VXML above picks the
individual properties on the namelist. Those must go as strings in the HTTP
Our HTTP POST looks like this:
-----------------------------
POST /spot/ccxml/basichttp HTTP/1.1^M
Host: 206.81.53.137:80^M
Pragma: no-cache^M
Accept: */*^M
User-Agent: iiARCADE/V7.0.0.0^M
Connection: keep-alive^M
Keep-Alive: 300^M
Content-Length: 234^M
Content-Type: application/x-www-form-urlencoded^M
^M
connectionid=000D5656038E79907072427017129242353030_fromMyself&dialogid=dialog.000D5656038E799070724270171292423530121&name=dialog.user.test&params_to_pass.a=1&params_to_pass.b=2&sessionid=session.000D5656038E7990707242701712924235301
----------------------------------
Our 204 response from CCXML looks like this:
----------------------
HTTP/1.1 204 No Content^M
Date: Wed, 15 Dec 2010 14:33:36 GMT^M
Server: Apache/2.2.3 (CentOS)^M
Content-Length: 95^M
Connection: close^M
Content-Type: text/html; charset=UTF-8^M
----------------------------
These are initially received by CCXML from HTTP as strings:

connectionid             000D5656038E79907072427017129242353030_fromMyself
dialogid                 dialog.000D5656038E799070724270171292423530121
name                     dialog.user.test
params_to_pass.a         1
params_to_pass.b         2
sessionid                session.000D5656038E7990707242701712924235301
---------------
Because javascript use of a "dot" represents the properties of
an object, it is obvious that params_to_pass must become an object,
this means the the event is now:

connectionid             000D5656038E79907072427017129242353030_fromMyself
dialogid                 dialog.000D5656038E799070724270171292423530121
name                     dialog.user.test
params_to_pass           { "a": "1" , "b": "2" }
sessionid                session.000D5656038E7990707242701712924235301

Note the JSON notation for params_to_pass
----------------------
Now CCXML spec mandates that any received parameters should be
dangled off the values object. See 
http://www.w3.org/TR/2010/CR-ccxml-20100401/#dialogEventsErrorDialoguser
The important text under 7.3.10 is "Type" of "values" = ECMA script 
object, and "Details" = Return values from the dialog for the user event.

Consequently we create that values object and attach
the params_to_pass object above as a property off the values.
Also, the dialog object is maintained by CCXML so we look up its
javascript object in CCXML memory space(using the dialogid as a search 
key) and attach it as a property
also to the dialog.user.test event:
connectionid             000D5656038E79907072427017129242353030_fromMyself
dialog                   { "_connectionid": "000D5656038E
                                    79907072427017129242353030_fromM
                                    yself" , "_srcid": "36_206.81.53
                                    .137" , "dialogid": "dialog.000D
                                    5656038E799070724270171292423530
                                    121" , "input": "000D5656038E799
                                    07072427017129242353030_fromMyse
                                    lf" , "objecttype": "dialog" , "
                                    outputs": [ "000D5656038E7990707
                                    2427017129242353030_fromMyself"
                                    ] , "src": "file://chrisdownload
                                    s/paulo/7_2/7_2_data.vxml" , "ty
                                    pe": "application/voicexml+xml"
                          }
dialogid                 dialog.000D5656038E799070724270171292423530121
name                     dialog.user.test
sessionid                session.000D5656038E7990707242701712924235301
values                   { "params_to_pass": { "a": "1" , "b": "2" } }
----------
Finally, should you happen to dump the javascript event$ received in
<transition event="dialog.user.test" state="ASSERTION_NMBR_447">
you will see:

{ "connectionid": "000D5656038E799070724270171292423530150_fromMyself" , 
"dialog": { "_connectionid": 
"000D5656038E799070724270171292423530150_fromMyself" , "_srcid": 
"113_206.81.53.137" , "dialogid": 
"dialog.000D5656038E799070724270171292423530241" , "input": 
"000D5656038E799070724270171292423530150_fromMyself" , "objecttype": 
"dialog" , "outputs": [ 
"000D5656038E799070724270171292423530150_fromMyself" ] , "src": 
"file://chrisdownloads/paulo/7_2/7_2_data.vxml" , "type": 
"application/voicexml+xml" } , "dialogid": 
"dialog.000D5656038E799070724270171292423530241" , "name": 
"dialog.user.test" , "sessionid": 
"session.000D5656038E7990707242701712924235303" , "values": { 
"params_to_pass": { "a": "1" , "b": "2" } } }

-----------
The application could then access "a" from VXML as 
$event.values.params_to_pass.a
although in the test suite case it does not.
-----------------------------
Regards,
Chris


-- 
Chris Davis
Interact Incorporated R&D
512-502-9969x117

Received on Wednesday, 15 December 2010 15:33:20 UTC