October 23, 2016
Hot Topics:

Introduction to CCXML, Part IV

  • November 7, 2002
  • By Jonathan Eisenzopf
  • Send Email »
  • More Articles »

Accessing Values Returned from Dialogs

Another concept that we need to grasp for the example that we will be looking at in a few minutes in the method by which VoiceXML dialogs can pass form field values back to the calling CCXML interpreter. This is done by specifying the list of variables in the namelist attribute of the <exit> element (within the VoiceXML file; not the CCXML file):

<exit namelist="name address phone"/>

We can read in these returned variables in CCXML within the dialog.exit event handler. Looking at the second event handler listed in our previous example and also listed below:

<transition name="evt" 
  <assign name="current_state" 
  <var name="age" expr="evt.age"/>
  <if cond="age > 21">
    <dialogstart src="'main.vxml'"/>

You may have noticed before that the <var> element is initializing the age variable using the value from evt.age; but where did it get that value from? Well, each event handler can define the name of the object that holds an event object's values and whose name is defined by the name attribute of the <transition> element. So when the dialog.exit event is caught and the exiting dialog contains a form field variable named age which was returned with the <exit> element inside that VoiceXML dialog, we would have access to that variable through the evt object.

Calling Card Application with CCXML

Now we're going to tie everything we've learned about CCXML up to this point to develop an application that functions like a calling card: you dial a number, enter your calling card number, and then dial the number you wish to call.

For this application, we want to do the following:

  1. answer the incoming call
  2. start the VoiceXML dialog that  collects the caller's PIN code and the number they want to call
  3. dial the phone number (if their PIN code matched)
  4. Join the two call legs when the remote party answers the phone

You can view the full source of the application here.

During execution, the application will be in one of five states. The table below lists the state and their related events as well as the next state.

Notice that there are two separate events that might occur while in the dialing state. Either the outbound call will be connected, or it will fail. Also, you'll notice that we're handling the connection.CONNECTION_CONNECTED event in two different places. The first occurrence is triggered when the incoming call is answered and connected. The second occurrence is triggered when the outbound call (using the number they specified) is connected. In the first occurrence, we start the VoiceXML dialog that collects the caller's PIN code and phone number to dial. In the second occurrence, we're calling the <join> elements to join the inbound and outbound call legs together.

You can view the full source of the VoiceXML dialog that collects and returns the caller's PIN code and outbound phone number here.

Some things to notice in this new application:

Placing the outbound call:

<transition name="evt" 
  <assign name="phone_number" 
  <if cond="phone_number.length == 10">
    <assign name="current_state" expr="'dialing'"/>
    <createcall dest="phone_number"/>

The <transition> element above sets the local variable phone_number with the return value from evt.phone_number. If the phone number is 10 digits long, then the state changes to dialing and an outbound call is initiated to the specified number with the <createcall> element.

Joining the Call Legs:

<transition name="evt" 
  <assign name="outgoing_callid" expr="evt.callid"/> 
  <join sessionid1="incoming_callid" 

The <transition> element above joins the inbound and outbound call legs with the <join> element when the outbound call is connected. If the call is not connected for whatever reason (no answer, busy signal, disconnected number), then the <transition> element listed below is executed:

<transition state="'dialing'" 
<log expr="'Failed making outbound call'"/>

This event handler simply logs the error and exits the CCXML application, disconnecting the call.


If you've made it through the entire CCXML series so far, then you already have a good grasp of the CCXML language. Now you know how to create simple two-party conference calls with the <join> and element. The next and final tutorial in this series will demonstrate how to create multi-party conference calls using the <createconference> element.

About Jonathan Eisenzopf

Jonathan is a member of the Ferrum Group, LLC  which specializes in Voice Web consulting and training. Feel free to send an email to eisen@ferrumgroup.com regarding questions or comments about this or any article.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel