| CCXML 1.0-W3C Development Guide | Home | Frameset Home |
|
<send> element is used for one main purposes: to send events to a separate CCXML session. The Voxeo implementation adds to this by allowing the developer to trigger a HTTP request.<send> is used to reach a HTTP server, then the resulting document will be examined. This document, or the HTTP body, can be empty, leading to a silent send without any feedback. Notice that it still will be transactional, since errors are always reported.
hello
test=123
more=is that it
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml">
<var name="myVar" expr="'some cool value'"/>
<var name="statevar" expr="'init'"/>
<var name="what_i_sent"/>
<eventprocessor statevariable="statevar">
<transition state="init" event="ccxml.loaded">
<send target="'sendTarget.php'" name="what_i_sent" namelist="myVar" delay="'1s'" targettype="'basichttp'"/>
<assign name="statevar" expr="'state1'"/>
</transition>
<transition event="myEvent" state="state1">
<var name="myObj" expr="JSON.parse(event$.myVar)"/>
<log expr="'***** DATA RECIEVED FROM SERVER *****'"/>
<log expr="'***** myObj = ' + myVar"/>
</transition>
<transition event="error.send">
<log expr=" ' ** Problem: ' + event$.reason + ' (eventid = ' + event$.eventid + ') **' "/>
</transition>
</eventprocessor>
</ccxml>
<?php
echo "myEvent\n"
?>
<?php
header('Cache-Control: no-cache');
foreach($_REQUEST as $key => $value )
{
echo $key , "=", $value, "\n";
}
?>
| ANNOTATIONS: EXISTING POSTS |
amitsood
|
|
|
Here is the sample ASP.net code that will return the values as expected by CCXML, in this case EventFromAspPage is the event name that will handeled by CCXML set content type to plain text public class MyForm: System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { string callId = string.Empty; string outputStr = string.Empty; try { this.Context.Response.ContentType = "text/plain"; //Needs for CCXML version 1.0 callId = FormatInputParam("callID"); string InputParam1= FormatInputParam("param1"); string InputParam2= FormatInputParam ("param2"); string InputParam3= FormatInputParam ("param3"); //Do your processing outputStr = CreateCCXMLResponse("EventFromAspPage", "Value1", "Value2"); } } catch(Exception ex) { // Handle the errors outputStr = CreateCCXMLResponse( "EventFromAspPage", "Value1", "Value2"); } this.Context.Response.Write(outputStr); } private string FormatInputParam(string paramName) { string retString = this.Context.Request[paramName]; if (null == retString) { retString = string.Empty; } return retString; } private string CreateCCXMLResponse(string eventName, string value1, string value2) { StringBuilder returnStringBuilder = new StringBuilder(eventName); returnStringBuilder.Append("\n"); returnStringBuilder.Append("Key1"); returnStringBuilder.Append("="); returnStringBuilder.Append(value1); returnStringBuilder.Append("\n"); returnStringBuilder.Append("Key2"); returnStringBuilder.Append("="); returnStringBuilder.Append(value2); return returnStringBuilder.ToString(); } } |
|
jbuehring
|
|
| On our test-bed installation of Prophecy 8.0.x, it appears to be the default behavior of the send element when using basichttp to transmit namelist data as base64-encoded HTTP POST. In this case, the target's server-side logic needs to process it accordingly before the data can be meaningful to it.
The way around this appears to be to specify 'http.get' as the name attribute, which transmits the namelist in plain-text via the HTTP GET method. Needless to say, this caveat should be documented, both in the send element's page, and in Appendix G! |
|
VoxeoBrian
|
|
| Hello,
You are correct, it is possible to specify the name attribute as http.get, which will transmit your parameters as plain text via GET. This however is not valid per the CCXMl specification and is a "hack", if you will that was created for our specific platform implementation. Allowing CCXML sends via GET is not something provided by the specification and as such was not included in the documentation. I will however make note of this, as I believe this should be documented for future use. Please let us know if you have any additional questions, we are always happy to help. Regards, Brian |
|
ScapeLogic
|
|
| I think it'd be useful for this example to be updated with the following:
First, the example output above has an event called 'hello', whereas the code example uses an event called 'myEvent'. Second, <log expr='***** myObj = ' + myVar"/> shouldnt that be + myObj instead of + myVar? Third, I think it'd be useful for people to understand they can get access to the actual key/value pairs like event$.keynamehere |
|
mikethompson
|
|
| Good eye there! I will need to follow up with the keepers of our documentation and see if we can get this changed.
Thanks, Mike Thompson Voxeo Corporation |
|
samo.jst
|
|
| Hi,
I've noticed that the link to 'complete code' zip file is not available. Could you please send it to me by email or republish it on the web site... ... I would really like to try the example, becouse I can see the PHP http response in the ccxml log file: <parameter name="content" value="clir=1" /> , but the expected new variable 'clir' can not be accessed - it remains undefined: <log expr="'CLIR:'+ clir"/> <log expr="'CLIR:'+ evt.clir"/> ==> <log>CLIR:undefined</log> <log>CLIR:undefined</log> br, Samo |
|
voxeodamonic
|
|
| Hello,
We apologize for the broken link. I will do some investigation and find out why this link is broken and get the page republished. Thank, Damonic Voxeo Support |
|
voxeojeff
|
|
| Hi Samo,
My apologies for the delayed update here. This issue has been rectified, and all links should now be fully functional. :-) Best regards, Jeff |
|
l8apex
|
|
| What is the timeout behavior when sending events using the 'basichttp' target type?
For example, given the following line: <send target="'doSomethingComplicated.php'" name="'http.get'" namelist="sessionID token silent" targettype="'basichttp'"/> Will there been an event if the <send> times out due to the php page taking too long to render? Is that timeout configurable? I'm trying to add error handling that wouldn't leave the CCXML session hanging just because the php backend is out to lunch. Thanks! |
|
voxeoblehn
|
|
| Hello,
The send timeout is configurable in a local Prophecy installation, but as this is done at the config level, we would have to make a platform change in hosted for this to take effect. So unfortunately, no, the timeout is not adjustable for the <send> element. As for the event thrown, the <send> element will return an 'error.send' if nothing is returned to the application. If successful, you will see a 'send.successful' returned in the logs. You may want to include an all encompassing error handler in your code which will catch this and avoid the dreaded 'zombie' session. I have included a basic example below: [code] <transition event="error.*"> <log expr="'an error has occured (' + event$.name + ')'"/> <log expr="'*** ' + event$.name + ' detected ***'"/> <log expr="'*** event$.name = ' + event$.name"/> <log expr="'*** event$.reason = ' + event$.reason"/> <log expr="'*** event$.tagname = ' + event$.tagname"/> <log expr="'*** event$.eventid = ' + event$.eventid"/> <log expr="'*** event$.eventsource = ' + event$.eventsource"/> <log expr="'*** event$.eventsourcetype = ' + event$.eventsourcetype"/> <voxeo:sendemail to="'blehnen@voxeo.com'" from="'myApp@voxeo.com'" type="'debug'" body="'An unexpected error has occurred \n Game over man, game over!'"/> [/code] Cheers, Brian Lehnen Voxeo Support |
|
michaelphines
|
|
| Hi guys,
Regarding the response from a <send> tag, like from the sendTarget.php above: Should the values be url-encoded, JSON, or both? Also is this part of the W3C CCXML 1.0 recommendation, or is it a proprietary extension? Thanks, Mike |
|
voxeoJohn
|
|
| Hello Mike,
The data needs to be in "text/plain" format, and you need to ensure that the first line is the the name of the user-defined event to be thrown. Then each of the following lines should contain any name/value pairs (delimited by an 'equals' sign) that you wish to return to your CCXML 1.0 application. Regarding W3C spec compliance, this is a little 'special sauce' that Voxeo added, as this functionality is not provided by the spec itself. I do hope this helps clear up any confusion on this functionality, and if there are any other questions here please let us know as our team is most certainly standing by to be of service! Regards, John Dyer Customer Engineer Voxeo Support |
|
michaelphines
|
|
| Thanks John,
That's too bad. I'm trying really hard to stay in compliance with the spec, as a portion of my application is going to be a reusable library. Is there any W3C compliant way of raising an event on the call from an external server? HTTP or otherwise? Mike |
|
voxeoJohn
|
|
| Hello Mike,
Perhaps I am misunderstanding your request here, are you just looking to inject an event into an active session, or fetch data using the send element?? Perhaps you can give us a bit of additional context into what it is you are trying to do so we can help? If you want we can move this into a private account ticket to ensure any potentially sensitive information is not posted on a public forum. We are standing by for your update at this time. Regards, John Dyer Customer Engineer Voxeo Support |
|
michaelphines
|
|
| Hi John,
I'm not worried too much about the sensitivity of this information, but if you think it's more appropriate to move this conversation into a ticket, that would be fine. My use case is primarily that I want to interrupt a dialog in progress in the case that an external event has occurred and start a new dialog. It's not imperative that the CCXML receive data from the server (though that might clean things up), just that an event be thrown. I was using a <send> to initiate an HTTP connection and holding the connection open until I received a response with some kind or interrupt=true variable or the connection timed out and I had to initiate a new one, but that seems less than ideal. The following code is the basic idea. I haven't tried to see if it runs mostly because I don't know how to raise the myEvent event from an external server in a compliant way. <ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml"> <var name="appState" expr="'init'" /> <var name="appDlg" /> <var name="callInfo" /> <eventprocessor statevariable="appState"> <transition state="init" event="connection.alerting"> <assign name="callInfo" expr="event$.connection" /> <accept /> </transition> <transition state="init" event="connection.connected"> <var name="call" expr="JSON.stringify(callInfo)" /> <dialogstart type="'application/voicexml+xml'" src="'dialog.vxml.aspx'" dialogid="appDlg" namelist="call" /> <assign name="appState" expr="'begin'" /> </transition> <transition state="begin" event="myEvent"> <dialogterminate dialogid="appDlg" /> <var name="call" expr="JSON.stringify(callInfo)" /> <dialogstart type="'application/voicexml+xml'" src="'newdialog.vxml.aspx'" dialogid="appDlg" namelist="call" /> <assign name="appState" expr="'interrupted'" /> </transition> </eventprocessor> </ccxml> Thanks for all of your help, Mike |
|
voxeoJohn
|
|
| Hello Mike,
Ah, I think this is going to be cake, as it seems like your just looking for our ccxml.send API! This API is fully documented, along with examples, at the following link: (http://docs.voxeo.com/ccxml/1.0-final/sendevent_ccxml10.htm). This http processor is inline with the spec, as illustrated in Appendix K of the W3C CCXML 1.0 spec (http://www.w3.org/TR/ccxml/#basichttpio) so you should be in the clear with your requirments. I do hope this helps, and if there are any other questions please let us know! Regards, John Dyer Customer Engineer Voxeo Support |
|
michaelphines
|
|
| Hi John,
Thanks for pointing that out to me, it's even better than I expected. This makes my life soooooooo much easier. For anyone else reading this, The documentation at http://docs.voxeo.com/ccxml/1.0-final/sendevent_ccxml10.htm seems to imply that requests must be made by GET. I just tried using POST and it worked just fine for me, which is good because it looks like the W3C spec demands that the request be in an application/x-www-form-urlencoded POST body. Mike |
| login |
|