CCXML and SIP, Part 1: Accessing SIP headers
May 6th, 2008 by Dan York
If you use SIP to connect to your voice appliction, one of the very nice things about CCXML is that you have full access to the underlying SIP headers that were sent as part of the SIP connection. With access to the SIP headers, you can then record information or make decisions in your code based on the contents of those headers.
First, let’s take a look at a typical SIP INVITE message that begins a call between two parties:
INVITE sip:1234@company2.com SIP/2.0 Via: SIP/2.0/UDP proxy.company2.com:5060;branch=z9hG5bK21ghi7ab34 Via: SIP/2.0/UDP sip.company1.com:5060;branch=z9hG4bKnashds7 To: sip:1234@company2.com From: sip:dan@company1.com;tag=451248 Call-ID: 324817637683475998ababcc10 CSeq: 1 INVITE Contact: sip:dan@company1.com Max-Forwards: 50 P-Asserted-Identity: "Dan York" <sip:dan@company2.com>
In CCXML, any and all of those headers are available to you using the following syntax:
event.connection.protocol.sip.headers['To']
You can use this information in a conditional statement, in a variable, or in a log statement such as this:
<log expr="'*** The SIP To header is ' + event$.connection.protocol.sip.headers['To']"/>
Note that for the headers whose names do not include a dash in them, there is also a shorter style:
<log expr="'*** The SIP From header is ' + event$.connection.protocol.sip.headers.to"/>
If the header names do include a dash in them, then they do need to be enclosed in brackets and single quotes. Here are some more examples of accessing the SIP headers from a connection object:
event.connection.protocol.sip.headers['To'] event.connection.protocol.sip.headers['P-Asserted-Identity'] event.connection.protocol.sip.headers.from
Let’s take a look at where you might see this code (shown in red) appear within a (admittedly VERY basic and not very useful) CCXML file:
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0">
<eventprocessor>
<transition event="connection.alerting">
<log expr="'*** The calledID is ' + event$.connection.local"/>
<log expr="'*** The caller ID is ' + event$.connection.remote"/>
<log expr="'*** The SIP From header is ' + event$.connection.protocol.sip.headers.from"/>
<accept/>
</transition>
<transition event="connection.connected">
<log expr="'*** Call was accepted ***'"/>
<disconnect/>
</transition>
<transition event="connection.disconnected">
<log expr="'*** Call was disconnected ***'"/>
<exit/>
</transition>
<transition event="connection.failed">
<exit/>
</transition>
</eventprocessor>
</ccxml>
Now here all we did was access the SIP header and then log one piece of information. Next time we’ll take a look at a more involved example where we use the SIP headers to change the actions inside the CCXML application.
If you would like to try out this code in a working environment head on over to www.voxeo.com/free and either join our (free) hosted development platform or download our (free) Prophecy software.
Technorati Tags: applications, ccxml, sip, voxeo, prophecy, voice, voip
Related posts:
- Accessing Web Services From CCXML
- Accessing Web Services From VoiceXML
- Leveraging a CCXML Wrapper for Post-call Cleanup
- What is a “State Machine”? And how does it apply to CCXML (and James Bond)?
- Certified Tech Tip: Prophecy 8 CCXML 1.0 Call Recording
If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.
RSS Feed





May 6th, 2008 at 11:50 am
[...] contents of the headers. (If you are developing your application on our platform and using CCXML, we’ve provided instructions for how to access those SIP headers.) For instance, the “P-Asserted-Identity” header is very often used as the [...]
May 29th, 2008 at 3:48 am
[...] contents of the headers. (If you are developing your application on our platform and using CCXML, we’ve provided instructions for how to access those SIP headers.) For instance, the “P-Asserted-Identity” header is very often used as the [...]