« Back to TCL-API

RE: TCL/IVR script (incoming E1, plays a message and forwards call)

Combination View Flat View Tree View
Threads [ Previous | Next ]
Dear all,
 
I hope that I will not upset some experts here with my problem! I'm a newbie-newbie in TCl-IVR scripting!
 
My problem: I have a cisco router as a voice-gateway. It has a E1-ISDN connected to PSTN and a G0/0 to it's LAN. Whenever there a call from PSTN to one of the IP Phones from the LAN (let's say that the IP Phone1 has DN 123) the voice-gateway intercept the call, plays a message to the caller like "Welcome to our company" and than send the call to the original called IP Phone (123).
 
Can this problem be solved with the use of a TCL-IVR script? Can someone help me with this script?
 
If the call cannot be directed to the original called party, at least to be directed to the IPPhone of a secretary(let's say DN 100)!
 
Thank you a lot,
 
Bogdan

Yes, you can do this with Tcl IVR API.
 
Please check out the sample Tcl scripts in the Tech center you should be able to get some idea from sample scripts.
 

Thank you Chen!!
 
I resolved the problem! Here is how I've made it ( in case somebody else is facing the same problem):
1. topology:
IPPhone1(DN=10)-(1.1.1.0/24)--R1--(12.12.12.0/24)---R2--(2.2.2.0/24)-IPPhone2(DN=20)
 
Everything is done in GNS3 (dynagen/dynamips) and as Ip Phones I've used IP Communicator and
VTG0-PC Lite (from Ipblue http://www.ipblue.com/products_vtgo_lite.asp).

 
2. Solution (only the important stuff):
I've used the B-ACD script.
R1:
!
dial-peer voice 100 voip
 destination-pattern 2.
 session target ipv4:12.12.12.2
 codec g711ulaw
!
R2:
application
  service callq flash:app-b-acd-2.1.2.2.tcl
  param queue-len 10
  param number-of-hunt-grps 1
  param queue-manager-debugs 1
  !
  service aa flash:app-b-acd-aa-2.1.2.2.tcl
  paramspace english index 0
  param number-of-hunt-grps 1
  param drop-through-option 1
  param handoff-string aa
  paramspace english language en
  param max-time-vm-retry 2
  param aa-pilot 20
  paramspace english location flash:
  param drop-through-prompt _bacd_welcome.au
  param second-greeting-time 60
  param call-retry-timer 15
  param voice-mail 20
  param service-name callq
  !
!
dial-peer voice 100 voip
 service aa
 destination-pattern 1.
 session target ipv4:12.12.12.1
 codec g711ulaw
!
end
3. Description: When IPPhone1 calls number 20 (IPPhone2), the B-ACD script comes up, answer the call and playes a message:" Thank you for calling .....Our agents are busy, your call will be answered soon..." and the IPPhone with DN 20 rings!!
That's it!emoticon

All the best,
 
Bogdan

You got this to work because your phones are in CME correct?  I tried to get the B-ACD app to send the call to a dial-peer that sends the call to CCM but it didn't work.

What is your application looks like ? You should be able to get something to work, if you just need to play a message then forward the call.
 
Thanks,
 
Yawming

We have this working but we don't want the user to have to enter any digits or wait for the timeout.  We are using the its-CISCO.2.0.2.0.tcl script.    We want to play the Welcome prompt then just transfer the user to the operator param.  When the script gets to this section, we want to just do a transfer to the $oprtr value.
 
 1proc act_GotDest { } {
 2    global dest
 3    global callInfo
 4    global oprtr
 5    global busyPrompt
 6    puts "\n proc act_GotDest"
 7    set status [infotag get evt_status]
 8    set callInfo(alertTime) 30
 9
10    if {  ($status == "cd_004") } {
11        set dest [infotag get evt_dcdigits]
12        if { $dest == "0" } {
13                set dest $oprtr
14        }
15        #handoff callappl leg_incoming default "DESTINATION=$dest"
16        leg setup $dest callInfo leg_incoming
17    } elseif { ($status == "cd_001") || ($status == "cd_002") } {
18        set dest $oprtr
19        #handoff callappl leg_incoming default "DESTINATION=$dest"
20        leg setup $dest callInfo leg_incoming
21    }   else {
22        if { $status == "cd_006" } {
23                set busyPrompt _dest_unreachable.au
24        }
25        puts "\nCall [infotag get con_all] got event $status collecting destination"
26        set dest [infotag get evt_dcdigits]
27        if { $dest == "0" } {
28                set dest $oprtr
29                #handoff callappl leg_incoming default "DESTINATION=$dest"
30                leg setup $dest callInfo leg_incoming
31        } else {
32                act_Select
33        }
34    }
35}

We got it to work.  Not sure if this is the best way to do it but here is what I did.  I deleted the whole proc act_GotDest { } section.  I then added:
 
1set dest $oprtr
2#handoff callappl leg_incoming default "DESTINATION=$dest"
3leg setup $dest callInfo leg_incoming

 
at the end of the proc act_Setup { } section.  Plus, I had to remove following from the bottom of the script because it was referencing the act_GotDest section I removed above.
 
 set fsm(GETDEST,ev_collectdigits_done) "act_GotDest HANDOFF"
 
Now, when I hit the application it plays the welcome audio then immediately sends to the number I have configured for the operator. 
 
One question though, how would I add a delay before the transfer?
 

To add delay please refer to programming guide
 
use media play %s option 
 
%stime  : Amount of play silence (in ms). 

example:

media play leg_incoming $welcomeprompt %s500

You just like to play a message to caller before connecting to called party right ?
So you can remove most of stuff, something like the follwoing should do the job.
 
 
# initialize the parameters that configured from IOS CLI
proc init_configs { }  {
    global welcomePrompt
 

    if [infotag get cfg_avpair_exists welcome-prompt] {
       setwelcomePrompt [string trim [infotag get cfg_avpair welwome-prompt]]
    } else {
       set welcomePrompt flash:en_bacd_welcome.au
    }
 
}
#procedure to play audio file on incoming dial peer
proc act_Media { } {
    global dest
    global welcomePrompt
 
    set dest [infotag get leg_dnis]

    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
    media play leg_incoming $welcomePrompt
}
 
# setup the call, connect caller to called party
proc act_Setup { } {
    global dest
    puts ">>> Tcl: proc act_Setup <<<"
    puts ">>> TCL:Final Dest: $dest <<<"
   
   
     handoff appl leg_incoming default "DESTINATION=$dest"
 
     act_Cleanup
}
 
# disconnect the call
proc act_Cleanup { } {
    puts ">>> Tcl: act_Cleanup <<<"
    call close
}
init_configs
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(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_media_done)     "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"

fsm define fsm CALL_INIT

You just like to play a message to caller before connecting to called party right ?
So you can remove most of stuff, something like the follwoing should do the job.
 
 
# initialize the parameters that configured from IOS CLI
proc init_configs { }  {
    global welcomePrompt
 

    if [infotag get cfg_avpair_exists welcome-prompt] {
       setwelcomePrompt [string trim [infotag get cfg_avpair welwome-prompt]]
    } else {
       set welcomePrompt flash:en_bacd_welcome.au
    }
 
}
#procedure to play audio file on incoming dial peer
proc act_Media { } {
    global dest
    global welcomePrompt
 
    set dest [infotag get leg_dnis]

    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
    media play leg_incoming $welcomePrompt
}
 
# setup the call, connect caller to called party
proc act_Setup { } {
    global dest
    puts ">>> Tcl: proc act_Setup <<<"
    puts ">>> TCL:Final Dest: $dest <<<"
   
   
     handoff appl leg_incoming default "DESTINATION=$dest"
 
     act_Cleanup
}
 
# disconnect the call
proc act_Cleanup { } {
    puts ">>> Tcl: act_Cleanup <<<"
    call close
}
init_configs
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(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_media_done)     "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"

fsm define fsm CALL_INIT

 
 
With the above config, where would I enter the number that the calls would transfer to?  Would it be configurable in the service params or would it be hardcoded in the script?

This is not for transfer, just an example showing paly a meesge before connect the call.
 
You can add code to collect the digit to transfer out.
 
Thanks !

This is not for transfer, just an example showing paly a meesge before connect the call.
 
You can add code to collect the digit to transfer out.
 
Thanks !

 
Ok, I would like to use your code, but I need a paramater to set the transfer extension.  I added a couple things but still doesn't transfer for me.
 
 
# initialize the parameters that configured from IOS CLI
proc init_configs { }  {
    global welcomePrompt
    global oprtr

    if [infotag get cfg_avpair_exists welcome-prompt] {
       setwelcomePrompt [string trim [infotag get cfg_avpair welwome-prompt]]
    } else {
       set welcomePrompt flash:en_welcome.au
    }
    if [infotag get cfg_avpair_exists operator] {
        set oprtr [string trim [infotag get cfg_avpair operator]]
    } else {
        set oprtr "NONE"
    }

}
#procedure to play audio file on incoming dial peer
proc act_Media { } {
    global dest
    global welcomePrompt
    global oprtr
  
    set dest $oprtr


    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
    media play leg_incoming $welcomePrompt
}
 
# setup the call, connect caller to called party
proc act_Setup { } {
    global dest
    puts ">>> Tcl: proc act_Setup <<<"
    puts ">>> TCL:Final Dest: $dest <<<"
  
     handoff callappl leg_incoming default "DESTINATION=$dest"

     act_Cleanup
}

# disconnect the call
proc act_Cleanup { } {
    puts ">>> Tcl: act_Cleanup <<<"
    call close
}
init_configs
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(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_media_done)     "act_Cleanup         same_state"
set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"

fsm define fsm CALL_INIT
 
 
 
 
 
 
It works and I can now play the recording to the caller, and what ever I have setup for operator it will transfer to that number.   Here is the "debug voice application error" output from a call.
 
 
 
000728: Feb 17 15:08:04.494 EST: //99//TCL :/tcl_PutsObjCmd: >>> Tcl: proc act_Setup <<<
000729: Feb 17 15:08:04.494 EST:
000730: Feb 17 15:08:04.494 EST: //99//TCL :/tcl_PutsObjCmd: >>> TCL:Final Dest: 55001 <<<
000731: Feb 17 15:08:04.494 EST:
000732: Feb 17 15:08:04.494 EST: //-1//AFW_:/AFW_Module_ParseHandle: ERROR: Separator not found
000733: Feb 17 15:08:04.494 EST: //99//TCL :/tcl_PutsObjCmd: >>> Tcl: act_Cleanup <<<
000734: Feb 17 15:08:04.494 EST:
000735: Feb 17 15:08:04.494 EST: //99//Hand:/AFW_M_Handoff_Terminate:  Can't cleanup, 1 calls out
000736: Feb 17 15:08:04.494 EST: //-1//AFW_:/AFW_Util_GetTgCicValue: CIC Not  found for tag(56)
000737: Feb 17 15:08:05.758 EST: //99//Dest:/DestStartMediaNegotiation: Interworking Leg does not need renegotiation
000738: Feb 17 15:08:23.194 EST: //99//AFW_:/Session_HandoffReturn: Cannot return leg with connections
000739: Feb 17 15:08:23.194 EST: //99//AFW_:/Session_HandoffReturn: No incoming leg to handoff return
000740: Feb 17 15:08:23.202 EST: //99//AFW_:/Session_HandoffReturn: No incoming leg to handoff return

You can do "call close" as soon as you handoff the call
But to be safe you can either use
 handoff callappl leg_incoming default "DESTINATION=$oprtr" insetad of "appl" in this case you can know the handoff return status and do the necessary treatment
 
or use "leg setup" so you know the leg setip status
 
I modified you code a little bit
 
# initialize the parameters that configured from IOS CLI
proc init_configs { }  {
    global welcomePrompt
    global oprtr

    if [infotag get cfg_avpair_exists welcome-prompt] {
       setwelcomePrompt [string trim [infotag get cfg_avpair welwome-prompt]]
    } else {
       set welcomePrompt flash:en_bacd_welcome.au
    }
        if [infotag get cfg_avpair_exists operator] {
         set oprtr [string trim [infotag get cfg_avpair operator]]
     } else {
         set oprtr "NONE"
         puts "operator number not set"
     }
 

}
#procedure to play audio file on incoming dial peer
proc act_Media { } {
    global welcomePrompt

    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
    media play leg_incoming $welcomePrompt
}
 
# setup the call, connect caller to called party
proc act_Setup { } {
  
     global oprtr

    puts ">>> Tcl: proc act_Setup <<<"
    puts ">>> TCL:Final Dest: $oprtr <<<"

     handoff appl leg_incoming default "DESTINATION=$oprtr"
   call close
}
 
 
 

I'm trying to setup generic script which just plays message then transfers call (without specifically defined number)
I'm using Yaw-Ming Chen's first sample script, but I get this error :

The incoming call has a global identifier already present in the list of currently handled calls. It is being refused.

what am I doing wrong - any suggestions ?

The result I'm trying to achieve is to play one message (e.g. your calls may be recorded) - catch all with one dial-peer, and then redirect it to CUCM
is it possible ?

hi michal,

could you please share the logs by enabling below debugs, also please share your script so that it will be easy for us to look into the issue.

debug voip app

Thanks,
Raghavendra

all that you've asked for in attachments
 
regards,
MM
Attachments:

Hi Michal,

i have tested your script didn't face any issue, are you able to place a call using "leg setup" command instead of "handoff" command.

could you please let us know the ios image version your are using.

Thanks,
Raghavendra

Hi, IOS image is :
c3900-universalk9-mz.SPA.151-4.M2.bin

thanks,
MM

Hi Michal,

thanks for sharing the information, BTW did you try using leg setup instead of handoff command, did it work?.

Thanks,
Raghavendra

I replaced :
     handoff appl leg_incoming default "DESTINATION=$dest"
with :
    leg setup $dest callInfo leg_incoming

but after message call gets disconnected

debug in attachment
 
Is there a problem that I'm testing it on incoming dial-peer (from CUCM) ?
but without service applied my calls goes through..
Attachments:

Hi Michal,
need to remove the act_Cleanup procedure after leg setup, try with the attached script.
Thanks,
Raghavendra
Attachments:

Hi Michal,

i have tested your script didn't face any issue, are you able to place a call using "leg setup" command instead of "handoff" command.

could you please let us know the ios image version your are using.

Thanks,
Raghavendra

Hi Michal,

i have tested your script didn't face any issue, are you able to place a call using "leg setup" command instead of "handoff" command.

could you please let us know the ios image version your are using.

Thanks,
Raghavendra

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Friday, May 18, 2012 07:33 AM
To: cdicuser@developer.cisco.com <cdicuser@developer.cisco.com>
Subject: New Message from Raghavendra Gutty Veeranagappa in Voice Gateway API (VGAPI) - TCL-API: RE: TCL/IVR script (incoming E1, plays a message and forwards call)

Raghavendra Gutty Veeranagappa has created a new message in the forum "TCL-API":

--------------------------------------------------------------
Hi Michal,
need to remove the act_Cleanup procedure after leg setup, try with the attached script.
Thanks,
Raghavendra
--
To respond to this post, please click the following link:

<http://developer.cisco.com/web/vgapi/forums/-/message_boards/view_message/5748209>

or simply reply to this email.



Information contained in this email is subject to the disclaimer found by clicking on the following link: http://www.lyondellbasell.com/Footer/Disclaimer/

Hi Michal,

i have tested your script didn't face any issue, are you able to place a call using "leg setup" command instead of "handoff" command.

could you please let us know the ios image version your are using.

Thanks,
Raghavendra

Hi
since last post I have succesfully implemented this script and it's working
but there's still one problem - when a phone is busy...
there are few different dial-peers on router, some for PSTN calls, some for mobile networks.. all of them are directed to E1
situation is like this:
sb calls -> router picsk up the call -> plays message -> forwards to CUCM (certain phone number) -> phone is busy
and
when calling party comes from PSTN network it hears busy tone and call gets disconnected
but
when calling party comes from mobile network (different dial-peer) it doesn't hear busy tone, just one clik and call gets dropped
 
Both calls (to mobile and PSTN networks) go out the same dial-peer...
any suggestions ?

proc act_Setup { } {

global oprtr

puts ">>> Tcl: proc act_Setup <<<"
puts ">>> TCL:Final Dest: $oprtr <<<"

handoff appl leg_incoming default "DESTINATION=$oprtr"
call close
}


If you have problem to do handoff you can try "leg setup" first to see what is the setup status. Once setup is successful then do handoff.