CCXML 1.0-W3C Development GuideHome  |  Frameset Home

  Learning CCXML 1.0  |  TOC  |  tutorial Basic Event Handling  

Tutorial: Hello World

This simple tutorial will step you through the creation and deployment of a "Hello World" application. When we are done, you will have a basic understanding of creating a CCXML 1.0 application and have begun the process of familiarizing yourself with the syntax.

In this tutorial, we will:


Note: The code presented within this tutorial is intended for the "Prophecy - CCXML 1.0" application type only. Attempts to utilize this code on the "CCXML - Voxeo" application type will not function, as the latter platform is based on the W3C specification from 2002.  Prophecy CCXML 1.0 is compliant to the most recent specification from 2006.


Step 1: basic syntax

Like any XML markup, CCXML requires an XML header. Also bear in mind that when saving our file, we should specify an encoding type of "UTF-8", and not "ANSI": When in doubt as to whether your text editor can save in this format, use Notepad. Every XML document you write, including CCXML documents, will need a header like this:


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


Next, you should add the main <ccxml> element pair. This will contain all other CCXML elements, which essentially defines the start and end of our CCXML document.


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

</ccxml>



Step 2: assigning a variable

In CCXML, variables have to be defined before they can be used. The name of a variable is always absolute, while its value is, as with most CCXML attributes, a fully qualified ECMAScript expression. Thus even for a simple string, we have to use single quotes to encapsulate it. If we don't, the persnickety interpreter would treat it as a language expression (i.e., as a nonexisting variable) and fail.


<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0">
  <var name="MyVariable" expr="'This is a CCXML Variable'"/>
</ccxml>



Step 3: outputting log information

There is no official way within CCXML to send debug information to a logging system, but Voxeo has created a method that unifies your approach, that allows you to see debug information via the realtime logger.  Like CallXML and VoiceXML, normal output will flow through the logger, which is accessible in your Evolution Account (you do have a Evolution Account, right?), or via the Log Viewer in your local Prophecy installation.  But sometimes... only sometimes you want to insert specific debug messages into the logging stream.  Let's try that here, using the variable we just defined:


<?xml version="1.0" encoding="UTF-8"?>
<cxml version="1.0">
  <var name="MyVariable" expr="'This is a CCXML Variable'"/>
  <log expr="'*** Hello World. I just made a variable: ' + MyVariable + ' ***'"/>
</ccxml>


Notice again that the <log> tag is subject to the same rules regarding ECMAScript expressions as <var> because of the "expr" attribute.  Don't be scared. Remember that we aren't actually outputting any audio for this tutorial, and when we call in to test the application, we will hear dead silence, followed by a hang-up: This is normal, as our method of verifying that our code works is via the logging stream.


Step 4: don't let the door slam when you <exit>

Here the show is over already. The <exit> tag will terminate the session, resulting in a hangup on all lines.  This tag is critical and should, if you are a highly skilled, phone-markup coder, be included in every script.  Applications that do not have an <exit> point may never be terminated, resulting in a dead session.  Thick-necked thugs may ring your door-bell to deliver a heavy sack beating should these dead sessions accumulate too often.  Definite "termination behavior" for each CCXML session is always a good idea.  It improves your document and your longevity.


<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0">
  <var name="MyVariable" expr="'This is a CCXML Variable'"/>
  <log expr="'*** Hello World. I just made a variable: ' + MyVariable + ' ***'"/>
  <exit/>
</ccxml>


Important Note:

This application may sound peculiar when you call it.  Since we have not yet learned how to actually answer an incoming phone call, you may hear what telco experts refer to as a "fast busy.", or a more ominous "Error 728". Not to worry though, soon we will learn how to answer the phone (then, we will tackle the feat of not getting the phone cord all twisted up). 

Your CCXML hello world application is now done.  You can log into your Voxeo Account to create a new application, or open the Prophecy Admin screen, and edit your "Call Routing" screen to denote application type "Prophecy CCXML 1.0". Remember, we need to open up our Logger in order to see whether or not our application executes correctly; we won't actually hear anything at all when we dial in.


What we covered:

  CCXML source code.




  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Learning CCXML 1.0  |  TOC  |  tutorial Basic Event Handling  

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