Showing results for 
Search instead for 
Did you mean: 
Walkthrough Wednesdays

SIP to SIP TCL transfer

Hi Guys,

I am wondering if somebody can provide me with a sample TCL script to be used in incoming dial-peer for SIP calls redirect on my CUBE gateway. I.e. I need to send SIP 3xx to ITSP, so they will redirect or divert this call accordingly and with that release both call legs on my local CUBE.



Actually I have created a simple vxml script myself

<?xml version="1.0" encoding="UTF-8"?>

<vxml xmlns="" xmlns:conf="" version="2.0">

<form id="xfer">

     <transfer name="mycall" type="refer" dest="tel:+22736"  bridge="false">




And it works on my CUBE router, does the transfer, when I enable service on the inbound dial-peer, but the problem is that it does not actually send REFER message but sends INVITE instead, therefore keeping CUBE in the loop. I need this to be like RTT release trunk transfer, wondering if this is something that can be done on the CUBE.


You can set mode as below for redirect, for sample scripts and programming guide please refer

set callInfo(mode) REDIRECT
leg setup $ReferDnis callInfo leg_incoming

please refer below H450 TCL script also


Thanks very much Raghavendra !

So the method you submitted ends up as SIP REFER / NOTIFY being submitted back to calling party, I am wondering what the method would be to send SIP 3XX message i.e. 302, moved temporarily instead of REFER?

Here is my code that I did for SIP REFER

proc act_Media { } {

    global dest

         set dest 22736

    leg setupack leg_incoming

    leg proceeding leg_incoming

    leg connect leg_incoming

    media play leg_incoming


# setup the call, connect caller to called party

proc act_Setup { } {

    global dest

    puts ">>> Tcl: proc act_Setup <<<"

    puts ">>> TCL:Final Dest: $dest <<<"  


   set callInfo(originationNum) 23402

set callInfo(mode) REDIRECT

#set callInfo(rerouteMode) REDIRECT_ROTARY

leg setup $dest callInfo leg_incoming


proc act_CallSetupDone { } {  

    set status [infotag get evt_status]

    puts "\n CALL STATUS = $status"

    if { $status == "ls_000"} {

        puts "\n You have sucessfully placed the call to the destination !"

    } else {       

        puts "\n Sorry your call was not connnected !"

        call close



# disconnect the call

proc act_Cleanup { } {

    puts ">>> Tcl: act_Cleanup <<<"

    call close


set fsm(any_state,ev_disconnected)  "act_Cleanup  same_state"

set fsm(CALL_INIT,ev_setup_indication)   "act_Media PLAYPROMPT"

set fsm(PLAYPROMPT,ev_media_done) "act_Setup PLACECALL"

set fsm(PLACECALL,ev_disconnected)      "act_Cleanup CALLDISCONNECT"

set fsm(PLACECALL,ev_setup_done)      "act_CallSetupDone CALLDISCONNECT"

set fsm(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"

set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"

fsm define fsm CALL_INIT

please try with alert as below.

set callInfo(mode) REDIRECT_AT_ALERT




but it sends INVITE now, I need that thing to send 3xx no refer no invite, something like 302 moved temprorarily

I don't think we can send 302 with TCL script other than sip invite or refer message.



please try with alert as below.

set callInfo(mode) REDIRECT_AT_ALERT

The mode you mentioned is undocumented. Documented modes are:

  • rotary
  • redirect
  • redirect_rotary

Which other modes exists, and what is their differences from the documented modes ?

There are REDIRECT_AT_ALERT and REDIRECT_AT_CONNECT, commonly used for TBCT.

REDIRECT_AT_ALERT -- if doing TBCT, PSTN switch will disconnect transfer by leg and trying to connect to transfer to leg. (there is a chance that transfer to leg won't get connected but transfer by leg disconnected already)

REDIRECT_AT_CONNECT transfer by leg is disconnected only when the transfer to leg is connect.

So the difference is when to release transfer by leg when doing TBCT.


You can disconnect the leg like this in tcl.

leg disconnect leg_incoming -c1

c1 is cause 1 for ISDN cause code "Unallocated or unassigned number"

you can find the list of cause codes here:

Q.931 - Wikipedia, the free encyclopedia

Cisco Employee

hello Farhad,

i'm having a need that may be as youre's, i was wondering if you can help me. i have not a gw connected to PSTN (E1 or Sip trunk) and i need that when an specific number is called inbound i do play a prompt asking for the destination number and then i just need to add to the dialed number an static to transfer the call internally you think you can show me how to achieve that? can you share you script?


you can try to set destination as below.

set dest ""

leg setup $dest callinfo leg_incoming



Content for Community-Ad