cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
765
Views
0
Helpful
0
Replies

Need help with TCL Scripting

ajey_shetty
Beginner
Beginner

We have calls coming into the CUBE incoming dialpeer 100 which will hit the outgoing DialPeer 200 this 200 DP has a TCL script application running which plays "calls will be monitored and recorded" and then it prefixes the dnis with 999. This indeed matched another Dialpeer 200999 which has the destination pattern 999.......... and the call is sent to the Call Manager.

 

I am trying to bypass this audio for one particular calling number as I don't want the call to be connected till the call is received  by the user, Hence I added one more function(CheckANI ) to check the calling number(6154455555) and if the calling number matches then it will simply add the prefix 544 to the called number so that it hits another dialpeer with destination pattern 544......... and sends it to CUCM

 

# Close and cleanup call when either party disconnects.
set FSM(any_state,ev_disconnected) "Cleanup,same_state"
set FSM(any_state,ev_disconnect_done) "Cleanup,same_state"

# Main script logic.
set FSM(CALL_INIT,ev_handoff) "CheckANI,CHECKANI"
set FSM(CHECKANI,ev_handoff) "AcceptCall,ACCEPTEDCALL"
set FSM(ACCEPTEDCALL,ev_media_done) "Handoff,PLACINGCALL"

# Log events.
set FSM(any_state,ev_any_event) "LogEvent,same_state"

# Sets the initial FSM state
fsm define FSM CALL_INIT

# end state machine definition

# start procedure definitions

proc Init {} {
# Audio to be played to caller prior to placing auto dial call.
global announcementAudio


set announcementAudio flash:LegalDisclaimer.wav
}

proc CheckANI { } {
global ani
global dnisString

set ani [infotag get leg_ani]
set dnisString [infotag get leg_dnis]
if{$ani == "6154455555"}{
set dnisString "544${dnisString}"
Handoff
}

# New call received, accept the call and play announcement audio.
proc AcceptCall { } {
global announcementAudio
global dnisString
global incoming

set incoming [infotag get leg_incoming]
set dnisString [infotag get leg_dnis callnumber $incoming]
#regexp {[0-9*#]+} $dnisString dnisString
set dnisString "999${dnisString}"

Log "Accepting call after receiving ev_handoff event"

set legState [infotag get leg_state leg_incoming]
puts "TCL : Leg State is $legState"
if {$legState != "lg_005" && $legState != "lg_008"} {
if {$legState == "lg_001"} {
puts ">>> TCL: legstate = lg_001 <<< \n"
leg setupack leg_incoming
leg proceeding leg_incoming
leg connect leg_incoming
} elseif {$legState == "lg_002"} {
puts ">>> TCL: legstate = lg_002 <<<\n"
leg proceeding leg_incoming
leg connect leg_incoming
} else {
puts ">>> TCL: legstate = $legState <<<\n"
leg connect leg_incoming
}
}

media play leg_incoming $announcementAudio
}

proc Handoff {} {
global dnisString

Log "Placing call to: $dnisString ..."

handoff appl leg_incoming default "DESTINATION=$dnisString"
Cleanup
}

# Cleanup on disconnect
proc Cleanup { } {
Log "Ending and cleaning up call legs."
set status [infotag get evt_status]
Log "Status of event is $status"
call close
}

proc LogEvent { } {
set ev [infotag get evt_event]
set state [infotag get evt_state_current]

Log "Event $ev received in state $state"
}

#
# Log a message.
#
proc Log { message } {
puts -nonewline "ANNOUNCEMENT $message"
}

# End Procedure definitions

# Initialize
requiredversion 2.0
Init

 

 

I am very new to TCL. Please help me understand if I am doing this right.

0 Replies 0
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: