March 5, 2021
Hot Topics:

Introduction to CCXML, Part II

  • By Jonathan Eisenzopf
  • Send Email »
  • More Articles »

Basic Call Control

Accepting calls with <accept>

The <accept> element answers an incoming phone call and is usually called within a <transition> element, which is answering to the connection.CONNECTION_ALERTING event.

<transition event="connection.CONNECTION_ALERTING"
  <accept callid="evt.callid"/>

The <accept> element contains the callid attribute, which is optional, and specifies the call leg id that will be accepted. If the callid is not specified, it will default to the call leg id of the event that's being processed. Setting the callid attribute manually means that only a call with the specified id will be answered. It is unlikely that you will ever set this attribute manually. In the code snippet above, the callid attribute is set to the callid value of the evt call object, which is the call leg id of the object that is processing the connection.CONNECTION_ALERTING event. This is essentially the same as excluding the callid attribute.

Rejecting calls with <reject>

Of course, we don't always have to <accept> the call, we could have also rejected it based upon the caller's phone number or some other criteria by using the <reject> element. See the <if> element in the Conditional/Control Statements section below for an example.

Terminating a call with <disconnect>

The <disconnect> element does exactly what its name implies--it terminates a call. You can specify the call leg to terminate by specifying the call leg id in the callid attribute. The attribute is optional.

ex. <disconnect callid="evt.callid">

Making an outbound call with <createcall>

The <createcall> element dials the phone number or SIP address specified by the dest attribute. When the call is connected, a connection.CONNECTION_CONNECTED event is sent, which can be caught by a <transition> element. If the call cannot be connected, a connection.CONNECTION_FAILED event is sent.

ex. <createcall dest="'7035551212'"/>

Once an outbound call is connected, it's common to execute a VoiceXML dialog to interact with the caller. The code fragment below is an example of two <transition> elements; the first one places the call with <createcall>, the second one is executed when the call is connected and executes a VoiceXML dialog with the <dialogstart> element:

    <transition state="'init'" event="ccxml.loaded">
      <assign name="state0" expr="'dialing'"/>            
      <createcall dest="'7034769418'"/>

    <transition state="'dialing'" 
      <assign name="state0" expr="'connected'"/>            
      <dialogstart src="'angie.vxml'"/>

Conditional/Control Statements

Controlling executing with <if>, <elseif>, <else>

In fact, you might remember an earlier VoiceXML tutorial where we controlled the dialog based upon the caller's phone number. So in conjunction with the CCXML <accept> and <reject> elements, we could replicate this functionality in CCXML:

<transition event="connection.CONNECTION_ALERTING" 
  <if cond="evt.calledid == '7035551212'">

The code snippet above is based in part on a tutorial located at:


If the ECMAScript code in the event attribute is evaluated to true, then we reject the call; otherwise we accept it and pick up the line.

Transitioning to another CCXML application with <goto>

The <goto> element contains only one attribute, next, which contains the URL of the CCXML application that the caller will be transitioned to.

ex. <goto next="conference.ccxml"/>

Submitting CCXML variables with <submit>

If it's necessary to pass values to the next CCXML application, you'll want to use the <submit> element rather than <goto>. Like <goto>, the next attribute contains the URL of the CCXML application that will be executed. The namelist attribute contains the list of variables contained in the current CCXML application whose values will be passed to the next application. The method attribute corresponds to the HTTP method, which can be GET or POST (the default is GET).

ex. <submit next="conference.asp" 
            namelist="state calledid callerid"/>

Executing VoiceXML Content

Starting a VoiceXML dialog with <dialogstart>

The <dialogstart> element executes a VoiceXML dialog specified by the src attribute. The element contains the following attributes, all of which are optional except for src:

  • callid - same as the callid attribute defined for the <accept> element
  • src - must be a valid URL location of a VoiceXML dialog
  • type - MIME type; default is application/xml+vxml
  • name - same as the <transition> element
ex. <dialogstart src="'example2.vxml'"/>

The CCXML is non-blocking, so it does not stop executing the CCXML application when a VoiceXML dialog starts. 

Stopping a VoiceXML dialog with <dialogstop>

In fact, you may want to pause or stop the VoiceXML dialog with a <dialogstop> while the dialog is still executing. For example, you might execute a VoiceXML dialog that plays on-hold music while you try to conference in another party. When the other party connects, you'd want to stop the music and announce that the other party has joined the conference.


In Part II of the Introduction to CCXML series, we've learned the basic elements that are used to handle events, execute VoiceXML content, and control calls. In Part III, we will apply our knowledge by creating a practical CCXML application.

About Jonathan Eisenzopf

Jonathan is a member of the Ferrum Group, LLC  which specializes in Voice Web consulting and training. He has also written articles for other online and print publications including WebReference.com and WDVL.com. Feel free to send an email to eisen@ferrumgroup.com regarding questions or comments about the VoiceXML Strategy series, or for more information about training and consulting services.

Page 2 of 2

This article was originally published on November 5, 2002

Enterprise Development Update

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

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