This document was generated from CDN thread Created by: BOGDAN OVIDIU STANCIU on 02-02-2010 03:30:17 PM 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, BogdanSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 02-02-2010 03:40:11 PMYes, 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. Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: BOGDAN OVIDIU STANCIU on 03-02-2010 03:12:13 PMThank 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 andVTG0-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!end3. 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!
All the best, BogdanSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Chris Bomba on 17-02-2010 01:50:43 PMYou 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.Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 17-02-2010 03:54:28 PMWhat 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, YawmingSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 17-02-2010 06:09:16 PMYou 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 CLIproc 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 peerproc 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 partyproc 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 callproc act_Cleanup { } { puts ">>> Tcl: act_Cleanup <<<" call close}init_configsset 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_INITSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Chris Bomba on 17-02-2010 04:57:04 PMWe 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}
Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Chris Bomba on 17-02-2010 05:57:31 PMWe 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? Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 17-02-2010 07:06:48 PMTo 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
Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 17-02-2010 07:31:49 PMThis 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 !Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Chris Bomba on 17-02-2010 07:27:49 PMYou 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?Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Chris Bomba on 17-02-2010 08:09:53 PMThis 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 CLIproc 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 peerproc 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 partyproc 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 callproc act_Cleanup { } { puts ">>> Tcl: act_Cleanup <<<" call close}init_configsset 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 found000733: 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 out000736: 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 renegotiation000738: Feb 17 15:08:23.194 EST: //99//AFW_:/Session_HandoffReturn: Cannot return leg with connections000739: Feb 17 15:08:23.194 EST: //99//AFW_:/Session_HandoffReturn: No incoming leg to handoff return000740: Feb 17 15:08:23.202 EST: //99//AFW_:/Session_HandoffReturn: No incoming leg to handoff returnSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yawming Chen on 17-02-2010 08:52:20 PMYou 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 CLIproc 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 peerproc 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 partyproc act_Setup { } { global oprtr puts ">>> Tcl: proc act_Setup <<<" puts ">>> TCL:Final Dest: $oprtr <<<" handoff appl leg_incoming default "DESTINATION=$oprtr" call close} Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Raghavendra Gutty Veeranagappa on 15-05-2012 05:44:52 AMhi 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 appThanks,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 15-05-2012 05:00:44 AMI'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 CUCMis it possible ?Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 15-05-2012 06:54:18 AMall that you've asked for in attachments regards,MMSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Raghavendra Gutty Veeranagappa on 15-05-2012 08:31:48 AMHi 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,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 16-05-2012 04:02:46 PMHi, IOS image is :c3900-universalk9-mz.SPA.151-4.M2.binthanks,MMSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Yaw-Ming Chen on 17-05-2012 10:46:34 AMproc 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.Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Raghavendra Gutty Veeranagappa on 17-05-2012 04:19:51 AMHi Michal,thanks for sharing the information, BTW did you try using leg setup instead of handoff command, did it work?.Thanks,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Raghavendra Gutty Veeranagappa on 18-05-2012 08:33:49 AMHi Michal,need to remove the act_Cleanup procedure after leg setup, try with the attached script.Thanks,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 18-05-2012 05:06:44 AMI replaced : handoff appl leg_incoming default "DESTINATION=$dest"with : leg setup $dest callInfo leg_incomingbut after message call gets disconnecteddebug 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..Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 18-05-2012 09:18:43 AMHi 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,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 18-05-2012 09:19:18 AMHi 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,RaghavendraSubject: Re: New Message from Raghavendra Gutty Veeranagappa in Voice Gateway API (V Replied by: Cyril Joseph on 18-05-2012 09:20:53 AMFrom: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]Sent: Friday, May 18, 2012 07:33 AMTo: 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/Subject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 21-05-2012 02:29:25 AMHi 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,RaghavendraSubject: RE: TCL/IVR script (incoming E1, plays a message and forwards call) Replied by: Michal Myszor on 08-10-2012 08:22:48 AMHisince last post I have succesfully implemented this script and it's workingbut 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 E1situation is like this:sb calls -> router picsk up the call -> plays message -> forwards to CUCM (certain phone number) -> phone is busyandwhen calling party comes from PSTN network it hears busy tone and call gets disconnectedbut 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 ?