How-To: Distinguish PSTN, Skype, iNum, and SIP in your Tropo applications
February 23rd, 2010 by John DyerHere at the secret layers of Tropo Support we often see similar questions raised by our developer base. We pay attention to these trends, since they often indicate that something may be lacking in our documentation. If we do find something is lacking we of course want to address by expanding on concepts or adding additional examples to help shore up our doc sets and help out our developers.
Recently I have started to notice a trend of developers asking how to determine the source of callers dialing into their applications (Skype, PSTN, SIP, or iNum). We’ll since we are often asked this question I figured I would provide a nice Ruby example for the ‘class’ =), I do hope this help!
Regards,
John Dyer
Customer Engineer
Voxeo Support
# -----------
# route based on DNIS
# John Dyer
# Voxeo Support
# -----------
log "@"*10 + $currentCall.inspect # List some headers
log "@"*10 + $currentCall.getHeader("x-voxeo-to") # log to header
module SipRegex
def evaluate_sip_header(header)
case header
when /^<sip:990/ # SKYPE
"SKYPE"
when /<sip:999/ # SIP
"SIP"
when /^<sip:883/ # iNUM
"INUM"
when /<sip:|[1-9]\d\d/ # PSTN
"PSTN"
else
"OTHER"
end
end
end
include SipRegex
toHeader = evaluate_sip_header($currentCall.getHeader("x-voxeo-to"))
if toHeader == 'PSTN'
answer
log "@"*10 + toHeader
hangup
elsif toHeader == 'SKYPE'
answer
log "@"*10 + toHeader
hangup
elsif toHeader == 'SIP'
answer
log "@"*10 + toHeader
hangup
elsif toHeader == 'INUM'
answer
log "@"*10 + toHeader
hangup
elsif toHeader == 'OTHER'
answer
log "@"*10 + toHeader
hangup
else
log "@"*10 + "SOMETHING BAD HAPPENED"
end
Related posts:

How-To: Distinguish PSTN, Skype, iNum, and SIP in your Tropo applications – http://bit.ly/92Jz51
This comment was originally posted on Twitter
How-To: Distinguish PSTN, Skype, iNum, and SIP in your Tropo applications – http://bit.ly/92Jz51 (via @tropo)
This comment was originally posted on Twitter
I noticed that SIP calls come with the following x-voxeo-to header:
Call[mtelis->999144xxxx] : @@@@@@@@@@
and wrongly identified as “PSTN”. You need to remove leading “1″ in the pattern. Here is my version:
module SipRegex def evaluate_sip_header(header) case header when /^<sip:990/ # SKYPE "SKYPE" when /<sip:999/ # SIP "SIP" when /^<sip:883/ # iNUM "INUM" when /<sip:|[1-9]\d\d/ # PSTN "PSTN" else "OTHER" end end end
BTW, you don't have a branch for 'SIP' in the if toHeader.. elseif statement and in result the code produces "SOMETHING BAD HAPPENED" error message while in fact everything is working just as expected.
Something is wrong with formatting, comment is looking good when I type it but not line breaks when submitted. Here is yet another attempt. For some reason Mike =========
I noticed that SIP calls come with the following x-voxeo-to header:
Call[mtelis->999144xxxx] : @@@@@@@@@@
and wrongly identified as “PSTN”. You need to remove leading “1″ in the pattern. Here is my version:
module SipRegex def evaluate_sip_header(header) case header when /^<sip:990/ # SKYPE "SKYPE" when /<sip:999/ # SIP "SIP" when /^<sip:883/ # iNUM "INUM" when /<sip:|[1-9]\d\d/ # PSTN "PSTN" else "OTHER" end end end
BTW, you don't have a branch for 'SIP' in the if toHeader.. elseif statement and in result the code produces "SOMETHING BAD HAPPENED" error message while in fact everything is working just as expected.
Thanks Mike,
It seems changes made on our network while making Tropo production ready effected some of the SBC data used to determine these routes, and as such it invalidated my test module. Appreciate the heads up, and I have corrected the code.
Regards,
John Dyer Customer Engineer Voxeo Support