CCXML Voxeo 1.0 Development Guide Home  |  Frameset Home

  ANI and DNIS  |  TOC  |  H: Speechify TTS Guide  
This documentation is for CCXML 1.0-Voxeo, which has been superceded by CCXML 1.0-W3C. The CCXML-Voxeo platform is not being updated any longer. The CCXML 1.0-W3C version, however, has many new features and is actively being enhanced. If you're writing a new CCXML application, you should use CCXML 1.0-W3C. Click here for the CCXML 1.0-W3C documentation.

Appendix G: <Send> Element & HTTP Requests

The <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.

When the <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.

Attribute Listing

The following listing briefly highlights the attributes available for this element when using the <send> element as to perform a HTTP request. For more details on this element, it is suggested that you view the CCXML element guide.




It is also possible, in the "returned document", to provide a specific, defined data structure that will result in a user-defined event in the originating CCXML session. Let's look at a sample data structure:


          hello
          test=123
          more=is that it


The above example illustrates how your "return document" should look.  The document should always be in "text/plain" format with the first line containing the name of the user-defined event to be thrown, each of the following lines should contain any name/value pairs (delimited by an 'equals' sign) that you wish to return to your CCXML application.  The name/value pairs in this example will be accessible via the event object when transitioning the 'user.hello' event.  Note that if parsing of the requested document fails, (such as what would be caused when missing an '=' sign),  no event will be sent at all, but the event error.send will be returned to the invoking document.

Example using <SEND> to make a HTTP request


<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0">

  <assign name="test_1" expr=" 'this goes out' "/>
  <assign name="test_2" expr=" 'and so is this one' "/>

  <eventhandler>
    <transition event="ccxml.loaded" name="evt">

    <!--
          we are sending a GET request to our imaginary server,
          passing two variables (as URL parameters), and we're
          expecting an HTTP '200' reponse with the document shown
          above; also note that this request will be delayed for 1 second
    -->

    <send event=" 'http.get' " target=" ' http://MySever.com/MyCode.asp' "
                      name="what_i_sent"
                      namelist="test_1 test_2"
                      delay=" '1000' "/>


      <log expr=" 'event ID = [ ' +what_I_sent + ' ] ' "/>

      <!--
            this common timeout even t brings down our session,
            regardless of whether or not we got an answer
      -->

      <send event=" 'My_Cool_Event' " target="session.id" delay=" '20000' "/>

  </transition>

  <transition event="error.send" name="evt">
    <log expr=" ' ** Problem: ' + evt.error + ' (eventid = ' + evt.eventid + ') **' "/>
  </transition>


  <transition event="user.hello">

    <!-- We now examine the return values from the HTTP request -->

    <log expr=" 'count on ' + evt.test + ' - ' + evt.more"/>

  </transition>
</eventhandler>

</ccxml>





  ANNOTATIONS: EXISTING POSTS
amitsood
10/12/2007 10:52 AM (EDT)
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();
  }
}

CCXML will see the following text output from the web page call

EventFromAspPage
Key1=Value1
Key2=-Value2

login
  ANI and DNIS  |  TOC  |  H: Speechify TTS Guide  

© 2011 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site