Introduction to CCXML, Part III

Wednesday Nov 6th 2002 by Jonathan Eisenzopf
Share:

In Part III of the Introduction to CCXML, we will begin developing practical call control applications, handling inbound calls with CCXML as well as placing outbound calls.

In case you missed it, you can still read the previous sections of this article: Introduction to CCXML, Part I and Introduction to CCXML, Part II.

In Part III of the Introduction to CCXML, we will begin developing practical call control applications.

Overview

As I've mentioned previously, I'm using the Voxeo CCXML platform to develop and test my CCXML applications. You can signup for a developer account at techpreview.voxeo.com. I would also recommend installing Voxeo Application Insight (which was also reviewed by Hitesh Seth).

Accept a call, start a dialog

Probably the most basic CCXML application accepts an incoming call with the <accept> element and starts a VoiceXML dialog with the <dialogstart> element.

1  <?xml version="1.0" encoding="UTF-8"?>
2  <ccxml version="1.0">
3  
4    <eventhandler>
5 <transition 
event="connection.CONNECTION_ALERTING" 
name="evt">
6 <accept callid="evt.callid"/>
7      </transition>
8    
9 <transition event=
"connection.CONNECTION_CONNECTED">          
10    <dialogstart src="'example2.vxml'"/>
11      </transition>
12  
13      <transition event="dialog.exit">
14  <log expr="'Thats all for now folks.'"/>
15        <exit/>
16      </transition>
17  
18    </eventhandler>    
19  </ccxml>

The CCXML application above defines three event handlers on lines 5, 9, and 13. The first catches the connection.CONNECTION_CONNECTED event, which gets triggered when a call comes into the system. The <accept> element on line 6 takes the phone off-hook (or in other words, it answers the call).

Once the call has been connected, the connection.CONNECTION_CONNECTION event is triggered and handled on lines 9-11 where the <dialogstart> element starts the example2.vxml dialog. At this point, the CCXML processor is still working in the background as the caller interacts with the VoiceXML dialog. The VoiceXML application doesn't incur any additional restrictions because it's being loaded by a CCXML application. Any valid VoiceXML application can be launched from a CCXML application.

When the VoiceXML dialog finishes execution, the dialog.exit event is thrown. The event handler on lines 13-16 handles this event. Line 14 records this event in the Voxeo log. The <log> element is not part of the CCXML specification, but was added by Voxeo so that developers can log call progress and error messages. Line 15 calls the <exit/> element, which ends the execution of the CCXML application.

Blocking Callers

Now, let's make our example a bit more sophisticated. Let's say that we have a list of phone numbers that we want to block from accessing the application. If someone calls from one of these blocked numbers, then we don't want to even pick up the phone.

1  <?xml version="1.0" encoding="UTF-8"?>
2  <ccxml version="1.0">
3  
4    <eventhandler>
5   <transition event=
"connection.CONNECTION_ALERTING" 
name="evt">
6    <if cond="evt.callerid == '7035551212'">
7          <reject/>
8          <exit/>
9   <elseif cond="evt.callerid == '2025551212'"/>
10          <reject/>
11          <exit/>
12        <else/>
13          <accept callid="evt.callid"/>
14        </if>
15      </transition>
16    
17 <transition event=
"connection.CONNECTION_CONNECTED">          
18        <dialogstart src="'example2.vxml'"/>
19      </transition>
20  
21      <transition event="dialog.exit">
22        <log expr="'Thats all for now folks.'"/>
23        <exit/>
24      </transition>
25  
26    </eventhandler>    
27  </ccxml>

As with the previous example, we have created an event handler for connection.CONNECTION_ALERTING via a <transition> element on lines 5-15. We've added several conditional statements that check the caller's phone number. If the caller's number is 202-555-1212 or 703-555-1212, then we <reject> the call and <exit> the application, otherwise, we <accept> the call.

As before, once the call is connected, the CCXML processor starts the example2.vxml dialog on line 18.

Placing outbound calls

With the <createcall> CCXML element, we can easily place outbound calls that initiate VoiceXML dialogs. Instead of setting up an inbound handler for connection.CONNECTION_ALERTING, we want to set up a handler for the ccxml.loaded event, which is triggered as soon as the CCXML has started up and is ready to process the program (lines 6-8). 

On line 7, we place the outbound call with <createcall>. The dest attribute specifies the phone number to dial.

If the call goes through and is connected, a connection.CONNECTION_CONNECTION event will be triggered. If the call could not be connected for whatever reason, the connection.CONNECTION_FAILED event will be triggered.

1  <?xml version="1.0" encoding="UTF-8"?>
2  <ccxml version="1.0">
3  
4    <eventhandler>
5  
6      <transition event="ccxml.loaded">           
7        <createcall dest="'7035551212'"/>
8      </transition>
9  
10      <transition 
event="connection.CONNECTION_CONNECTED">          
11        <dialogstart src="'example2.vxml'"/>
12      </transition>
13  
14      <transition 
event="connection.CONNECTION_FAILED">
15        <log expr="'Failed making outbound call'"/>
16        <exit/>
17      </transition>
18  
19      <transition event="dialog.exit">
20        <log expr="'Thats all for now folks.'"/>
21        <exit/>
22      </transition>
23  
24      <transition event="call.CALL_INVALID" name="evt">
25        <exit/>
26      </transition>
27  
28      <transition event="error.*" name="evt">
29 <log expr="'an error has occurred 
(' + evt.error + ')'"/>
30        <exit/>
31      </transition>
32  
33    </eventhandler>    
34  </ccxml>

On lines 10-12, we handle the connection.CONNECTION_CONNECTED event by starting the example2.vxml dialog. The connection.CONNECTION_FAILED event is handled on lines 14-17 by logging the error and then calling <exit>.

I've also added a third event handler that catches and logs any and all errors on lines 28-31.

Conclusion

So, now we've had a bit of experience handling inbound calls with CCXML as well as placing outbound calls. In the next article, we will learn how to use CCXML to conference calls.

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.

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved