This document was generated from CDN thread
Created by: Adrian Fernandez on 16-09-2011 10:57:28 AM
Hi Forum,
I am trying to write the sip diversion reason using a tcl script with no luck so far, here is part of my script, with some explanation and outputs, any help will be welcome, thanks, Adrian.
proc act_Setup { } {
global ocn_number
global destination
global RNI_orr
leg setupack leg_incoming
set destination [infotag get leg_dnis]
set ret [ object create gtd gtd_iam IAM ]
set gtdHandle [infotag get evt_gtd gtd_iam]
if {$gtdHandle > 0} {
if {[infotag get gtd_attr_exists gtd_iam ocn.-1]} {
set ocn_number [object get gtd gtd_iam ocn.1.#]
set RNI_orr [object get gtd gtd_iam rni.1.orr]
puts "**********************RNI_orr = $RNI_orr"
if {$RNI_orr > 0} {
if {$RNI_orr == "2"} {
set headers(Diversion) $ocn_number
set headers(reason) "no-answer"
set callinfo(headers) headers
puts "*********************SIP invite diversion reason = $headers(reason)"
puts "*********************SIP invite diversion number(OCN) = $headers(Diversion)"
}
}
leg proceeding leg_incoming
leg setup $destination callInfo leg_incoming
fsm setstate CALLACTIVE
}
I took the idea of using the array ¿headers¿ (to set the callinfo) from the ¿TCL IVR 2.0 Programming Guide¿
As you can see in the following output (coming from the puts command lines), the headers array has the needed values:
Sep 15 11:38:13.124: //1660//TCL :/tcl_PutsObjCmd: *********************SIP invite diversion reason = no-answer
Sep 15 11:38:13.124: //1660//TCL :/tcl_PutsObjCmd: *********************SIP invite diversion number(OCN) = 5149023070
And here is part of the sip invite: Sent:
INVITE sip:5145090003@10.247.33.80:5060 SIP/2.0
Via: SIP/2.0/UDP 10.247.164.231:5060;x-route-tag="tgrp:1";branch=z9hG4bK8BA145D
Remote-Party-ID: <sip:5143804302@10.247.164.231>;party=calling;screen=yes;privacy=off
From: <sip:5143804302@10.247.164.231>;tag=B799E28-861
To: <sip:5145090003@10.247.33.80>
¿
Contact: <sip:5143804302@10.247.164.231:5060>
Diversion: <sip:5149023071@10.247.164.231>;privacy=off;reason=unconditional;screen=no
Expires: 180
Allow-Events: telephone-event
Content-Type: application/sdp
Content-Disposition: session;handling=required
Content-Length: 253
As you can see (from the sip invite) the diversion number is well placed but the reason is not the good one (no-answer).
What is wrong in my script? Is the diversion reason a sub header inside the diversion header? If so how can I recall it?
Subject: RE: How can I change the SIP Invite diversion reason?
Replied by: Adrian Fernandez on 19-09-2011 11:15:32 AM
Hi Raghavendra,
Actually I already modified the SIP diversion header number, but I don't find the way to modify the redirect reason code. Thanks,
Adrian
Subject: RE: How can I change the SIP Invite diversion reason?
Replied by: Raghavendra Gutty Veeranagappa on 19-09-2011 02:01:52 AM
Hi Adrian,
I don't think through TCL Script you can modify the diversion header, to modify Diversion header you need to create SIP Profiles and apply them to dial peer.
Thanks,
Raghavendra
Subject: RE: How can I change the SIP Invite diversion reason?
Replied by: Yaw-Ming Chen on 20-09-2011 12:31:39 PM
To use custom header command all content of header should be in one string. That's why we need to be very careful when using it.
Please refer to Cisco Tcl IVR programming guide
For example,
set headers(Diversion) "<sip:5149023071@10.247.164.231>;privacy=off;reason=unconditional;screen=no"
set callinfo(protoHeaders) headers
leg setup $destination callinfo leg_incoming
Subject: RE: How can I change the SIP Invite diversion reason?
Replied by: Raghavendra Gutty Veeranagappa on 20-09-2011 03:23:25 AM
Hi Adrain,
But diversion number(5149023071) in log and diversion number(OCN) = 5149023070 are different.BTW you are passing incorrect "callInfo" param to the leg setup please try with following code.
set headers(Diversion) $ocn_number
set headers(reason) "no-answer"
set callinfo(protoHeaders) headers
leg setup $destination callinfo leg_incoming
Thanks,
Raghavendra
Subject: RE: How can I change the SIP Invite diversion reason?
Replied by: Adrian Fernandez on 22-09-2011 10:02:46 AM
Hi Raghavendra and Yaw-Ming,
Thanks a lot, Raghavendra, you are right, the diversion output is not the good one, I did not try your code, I fixed the problem using Yaw-Ming's idea:
At the script for each ORR (Original Redirect Reason) I put a technical prefix in front of the called number, by the way, the script is triggered by an incoming dial-peer, so once the call pass through the gateway, the call is captured by an outgoing dial-peer (one dial-peer per redirect reason - technical prefix) which has a profile that will modify the diversion reason. Each profile is like the following one:
voice class sip-profiles 100
request INVITE sip-header Diversion modify "reason=[a-z\-]+" "reason=user-busy"
If I have time, I will try your code; it looks easier, thanks again,
Adrian