cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6914
Views
1
Helpful
6
Replies

TCL ivr no answer condition

Bar1s
Level 1
Level 1

Hello,

I have very basic tcl script that I have been using.

Recently I noticed that if internal called number does not answer the call is stay off-hook situation.

And external caller if forgot to close the call line will be off-hook as well.

So How can I check this situation and how can I divert tcl to another state or can I close the call?

Regards,

Baris.

Here is my script----------

# TCL IVR

proc init { } {

  global param

  global pilotno

  global alerttimeout

  global langselect

  global digitcollect

  set pilotno 6001

  set alerttimeout 6

  set langselect "Turkish"

  set digitcollect ""

  set param(interruptPrompt) true

  set param(abortKey) *

  set param(terminationKey) #

  puts "\n(init) Starting tcl Cisco\n";

  if { [infotag get cfg_avpair_exists cm-pilot] } {

  set pilotno [infotag get cfg_avpair cm-pilot]

  } else {

  puts "\ndebug(init) Critical problem found, no Pilot number defined!\n";

  }

  if { [infotag get cfg_avpair_exists alert-time] } {

  set alerttimeout [infotag get cfg_avpair alert-time]

  } else {

  puts "\ndebug(init) Critical problem found, no Alert-Timeout defined!\n";

  }

  puts "\ndebug(init)Language selected currently is '$langselect'\n";

  puts "\ndebug(init)Digitcollect currently is '$digitcollect'\n";

  puts "\ndebug(init)Finished Initialisation, CMpilot is $pilotno, Alerttime is $alerttimeout\n";

}

proc act_Setup { } {

  global alerttimeout

  global langselect

  global digitcollect

  set langselect "Turkish" 

  set digitcollect ""

  puts "\ndebug(act_Setup)Language selected currently is '$langselect'\n";

  puts "\ndebug(act_Setup)Digitcollect currently is '$digitcollect'\n";

  puts "\n(act_Setup) Entering procedure\n";

  

  if { [infotag get leg_isdid] } {

  leg proceeding leg_incoming

  leg progress leg_incoming

  leg connect leg_incoming

  media play leg_incoming flash:man_tr_anons.au

  set param(interDigitTimeout) 3

  set param(initialDigitTimeout) 2

  set param(maxDigits) 4

  set param(interruptPrompt) true

  set param(abortKey) *

  set param(terminationKey) #

  leg collectdigits leg_incoming param

  fsm setstate SELECTOPT

  } else {

  call close

  }

}

proc act_Collected { } {

  global delay

  global pilotno

  global langselect

  global digitcollect

  global alerttimeout

  puts "\ndebug(act_Collected) Entering procedure\n";

  puts "\ndebug(act_Collected) Digitcollect is: '$digitcollect'\n";

  set status [infotag get evt_status]

  puts "\n(act_Collected) Collect status is '$status' (lang=$langselect)\n";

  if { $status == "cd_001"} {

  puts "\n(act_Collected) Collect Timeout play prompt and transfer to operator\n";

  if { $langselect == "Turkish" } { 

  puts "\n(act_Collected) Playing Turkish prompt\n";

  media play leg_incoming flash:bekletme.au

  }

  if { $langselect == "English" } {

  puts "\n(act_Collected) Playing English prompt\n";

  media play leg_incoming flash:bekletme.au

  }

  

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:bekletme.au

  }

  if { $status == "cd_005" } {

  set choice [infotag get evt_dcdigits]

set first [string range $choice 0 0]

set length [string length $choice]

  puts "\n(act_Collected) Digits entered is '$choice'\n";

if { $length == "1" } {

  if { $choice == "0" } {

  puts "\n(act_Collected) Digits entered is '$choice'. Transferring to operator ($pilotno)\n";

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:bekletme.au

} elseif { $choice == "9" } {

  puts "\n(act_Collected) Choice select is 9\n"

  set langselect "English"

  puts "\n(act_Collected) Language set to $langselect\n"

  media play leg_incoming flash:man_eng_anons.au

  set param(maxDigits) 4

  set param(interruptPrompt) true

  set param(abortKey) *

  set param(terminationKey) #

  leg collectdigits leg_incoming param

  fsm setstate SELECTOPT

} else {

  puts "\n(act_Collected) Caller dialed invalid menu item. Transferring to operator ($pilotno)\n";

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:hatalino.au

  } 

  } elseif { $length == "4" } {

  puts "\n(act_Collected) Caller dialed valid extension. Transferring to extension ($choice)\n";

  leg setup $choice callInfo leg_incoming

  fsm setstate TRANSFERTOEXT

  

  } else {

  puts "\n(act_Collected) Caller dialed invalid extension. Transferring to operator ($pilotno)\n";

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:hatalino.au

  }

  } 

}

proc act_InvalidExt { } {

  global langselect

  global pilotno

  puts "\n(act_InvalidExt) Entering Procedure\n";

  set status [infotag get evt_status]

  

  puts "\nDEBUG STATUS: $status\n";

  playtone leg_incoming tn_none

  if { $status == "ls_007"} {

  puts "\n(act_InvalidExt) Extension is busy. Transferring to operator ($pilotno)\n";

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:busy.au

  }

}

proc act_Cleanup { } {

  puts "\n(act_Cleanup)Closing call\n";

  call close

}

proc optransfer { } {

  puts "\n(act_Collected) Transferring to operator ($pilotno)\n";

  leg setup "6001" callInfo leg_incoming

  media play leg_incoming flash:bekletme.au

}

proc donothing { } {

  puts "\n(donothing) Cannot end up here\n";

}

init

set delay 5 

#----------------------------------

# State Machine

#----------------------------------

set fsm(any_state,ev_disconnected) "act_Cleanup same_state"

set fsm(CALL_INIT,ev_setup_indication) "act_Setup same_state"

set fsm(SELECTOPT,ev_collectdigits_done) "act_Collected same_state"

set fsm(PLACECALL,ev_leg_timer) "act_Cleanup same_state"

set fsm(CLEANUP,ev_leg_timer) "act_Cleanup same_state"

set fsm(TRANSFERTOOP,ev_media_done) "optransfer same_state"

set fsm(TRANSFERTOEXT,ev_collectdigits_done) "exttransfer same_state"

set fsm(TRANSFERTOEXT,ev_setup_done) "act_InvalidExt same_state"

fsm define fsm CALL_INIT

6 Replies 6

Raghavendra G V
Cisco Employee
Cisco Employee

Hi Baris,

When the call setup timed out TCL script will receive the status code "ls_002".

You can use "call close"  command in TCL script  to close the call.

For more information please refer TCL IVR programming Guide  in below location.
https://developer.cisco.com/site/voice-gateway/documents/api-documents/index.gsp

Thanks,
Raghavendra

Hello Raghavendra,

Thank you for your reply.

I belive I have to add something like that ;

        if { $status == "ls_002" } {

        call close

        }

But I couldn't figured out in which part I have to add my code. How I can trigger this condition ?

Regards,

Baris.

yawming
Cisco Employee
Cisco Employee

This is happening when script receives ev_setup_done event. You need to add this i the function you handle ev_setup_done event.

Inprogramming guide -  https://developer.cisco.com/fileMedia/download/f3ff7b79-266a-4a58-9694-9f05ccf4824a

002 The call setup timed out (meaning that the destination phone was alerting, but no one

answered). The limit of this timeout can be specified in the  leg setup command

So go to the leg setup session you will see an example that we need to set set callInfo(alertTime) xx

example

set callInfo(alertTime) 25

In this case script will receive ls_002 if there is no answer after 25 seconds.

Hope this helps.

Hi,

Yeah I was struggled to understand fsm transitions.

So I changed my script little bit. and I added one fsm state.

set fsm(SELECTOPT,ev_collectdigits_done) "act_Collected  CALLISACTIVE"

set fsm(CALLISACTIVE,ev_setup_done) "act_InvalidExt  same_state”

I added code on proc act_InvalidExt procedure :

if {$status == "ls_000"} {

        puts "\n LS_000The call is active or was successful. \n";

        return

        }

        #call setup timeout/invalid no/Destination Busy/dest disconnect/conference failed/

       if { ($status == "ls_002") ||

            ($status == "ls_004") ||

            ($status == "ls_007") ||

            ($status == "ls_009") ||

            ($status == "ls_010")

            } {

            puts "\n LS_002,4,7,9,10 The call noans, failed, busy, disconnected \n";

            call close

            return

    }

And I found this tutorial on some web page. It was very useful to solve my issue.

FSM

The first thing in the study from Cisco was my voice menu is very difficult to understand, this duck FSM transitions.

It looks like this:

ivr_fsm the set (CALLCOMES, ev_setup_indication) "act_Setup same_state"

Transitions such can be any number, and they are located at the end of the TCL script. Let's see what it is all about. The general syntax of this command is as follows:

set array (CURRSTATE, curr_event) "act_proc NEXTSTATE"

where: of array - the name FSM array. CURRSTATE - the current status of the name in which the received event curr_event .act_proc - name of the function that you want to run when entering events curr_event able CURRSTATE . NEXTSTATE - state name, which is established after the launch act_proc . In other words, , FSM is a marker, for which Cisco compares obtained from the API event curr_event and current status with CURRSTATE , if any, or FSM transition are described, the procedure is called act_proc and status changes to NEXTSTATE . the most important thing in this - is that current event and the state compared with all described FSM transitions simultaneously . Those. for Cisco does not matter the order in which the FSM transitions are located, they are processed immediately.

functions

The second point is the functions themselves, which should be described to the initialization script. There are a number of points, not peculiar to the PLO ordinary language. For example, if you have 2 teams:

media play leg_incoming $ playng_files (noexist)
leg setup $ numbers (ckp) callinfo leg_incoming

That is the logic of the object-oriented (or not) of the programming language, you first execute: media play and after the leg of setup a . There is also executed in the same order, but the interpreter does not wait for execution 1st team and soon after the launch of media play The following command will be executed. End play is already being processed by FSM transitions. The appointment of all the teams and conditions described in detail in tcl_ivr_2.0_programming_guide file, which you can download here, I will focus in detail only on those that will be used directly in the script

1) initialization script

Start any TCL IVR script contains a procedure for the init , in my example, this function is as follows:

proc init {} {
    the puts "\ the n the proc the Init the start"
    global the param
}

It essentially runs display team puts "..." and the definition of the global variable param

script is initialized after the description of all the functions, and begins with the start function the init . This simple things over, then everything is much more interesting. The last line of the script executable must be a string determining the starting FSM transition and start conditions. In this case:

fsm define ivr_fsm CALLCOMES

This means that the name of the FSM array given as ivr_fsm , and the initial state CALLCOMES . With the initialization done, more will be understood that there is (I hope).

2) Greeting

proc Play_Welcome {} {
        the puts "\ the n \ the n the IVR - the proc Play_Welcome the start \ the n \ the n"
        global playng_files
         global the param
         global the pattern
         global numbers
         global workingtime
       
        # Call the procedure, which describes all the variables
        init_perCallVars
       
        # Get the time
        GetDate
       
        # Depending on the working time is now or not, set the greeting
        the if {} {$ workingtime
        set after_welcome $ playng_files (takenumber)       
        } Else {
        set after_welcome $ playng_files (noworking)
        }
       
        # Set the connection parameters of the incoming call
        set param (interruptPrompt) true
        set param (abortKey) *
        the param the set (terminationKey) #       
       
        # Connect the incoming call
        leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming
       
        # Run the numbers pressed collection procedure from the caller
        leg collectdigits leg_incoming param pattern
       
        # Start losing files caller, after the end of the
        # will be operational param timer (interDigitTimeout), after which the
        # There will be an event ev_collectdigits_done
        media play leg_incoming% s500 $ playng_files (welcome) $ after_welcome $ playng_files (onhold)
       
        # Start the timer, after which the event will occur ev_named_timer
        timer start named_timer $ numbers (waiting_time) t1
}

Here some detail all described. The result of this procedure is to connect the incoming line to Cisco by teams leg setupack, leg proceeding, leg connect , and the loss of music files at a time to the input line at the expense of the team media-play leg_incoming . Immediately starts collecting pressed process key leg collectdigit and timer command the timer the start . and now is the time verified working or not, calling the function GetDate :

{} GetDate the proc {
         global workingtime
       
        #Hour
        set houris [clock format [clock seconds] -format% H]
        # Day of week
        set dayis [clock format [clock seconds] -format% A]
        # Check the working time
        the if {$ houris> 17 || $ houris < 8 || dayis == $ "the Sunday" || dayis == $ "on Saturday" } {
        set workingtime 0
        } the else {
        set workingtime 1
        }
}

Depending on the working time or not we change the music file, which will play caller. Since the initial state is set to in this case as afsm the define ivr_fsm CALLCOMES , it will enter immediately 3 the FSM :

ivr_fsm the set (CALLCOMES, ev_setup_indication)     "Play_Welcome, same_state"
the set ivr_fsm (CALLCOMES, ev_collectdigits_done)   "CheckDestanation, same_state"
the set ivr_fsm (CALLCOMES, ev_named_timer)           "GoToReception, same_state"

Event ev_setup_indication happens when you receive a call, and will be launched procedure Play_Welcome , which describes the start of the process of collecting the pressed numbers and start the timer. After playing music subscriber will reverse timer report, which is specified by the param (initialDigitTimeout) (which can be set slightly higher string set param (initialDigitTimeout) 15 and set to 15 seconds), because He's not specified, the default is 10 seconds, after which the script will receive an eventev_collectdigits_done , upon the occurrence of which, as we have described in the FSM transition function will be executedCheckDestanation . Timer running in Play_Welcome team:

# Timer type named_timer, duration, taken from the variable numbers (waiting_time), the name of the timer t1
timer start named_timer $ numbers (waiting_time) t1

After its completion will generate an event ev_named_timer , which will be processed the next FSM transition:

ivr_fsm the set (CALLCOMES, ev_named_timer)           "GoToReception, same_state"

and call the procedure GoToReception .

3) Check the number entered

proc CheckDestanation {} {
        the puts "\ the n \ the n the IVR - the proc CheckDestanation the start \ the n \ the n"
        global playng_files
         global numbers
         global digit The
         # Stop the loss of media
        media stop leg_incoming
       
        # Determine the value of a variable
        set status [infotag get evt_status]
        set digit [infotag get evt_dcdigits]
       
        # Compare the figures and statuses
        # If the entered number corresponds to that specified in the $ numbers (fast_reception),
        # change the digit number to the reception and transfer $ digit in CheckCallersAndConnect function
        # after changing the status to CALLCONNECTED,
        # whereby, when an event occurs ev_setup_done (connection to a number of the Secretary)
        # will be worked out procedure CallIsConnect
        the if {$ == $ digit The numbers (fast_reception) {}
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the reception the next \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (reception)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If you enter a number that corresponds to that specified in the $ numbers (fast_ckp), connect to the CCU
        # through CheckCallersAndConnect
        } Elseif {$ digit == $ numbers (fast_ckp)} {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the next the CKP \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (ckp)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If you enter a number that corresponds to that specified in the $ numbers (fast_fax), connect to the fax
        # through CheckCallersAndConnect
        } Elseif {$ digit == $ numbers (fast_fax)} {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the next fax \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (fax)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If the status = cd_004 (entered the correct digits) - connect to the desired number
        # through CheckCallersAndConnect
        } elseif {$ the status == "cd_004" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate CALLCONNECTED
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If the status = cd_005 (coincidence with the dial plan) - connect to the desired number
        # through CheckCallersAndConnect       
        } elseif {$ the status == "cd_005" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate CALLCONNECTED       
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit       
        # If the status = cd_006 (dialed number does not exist) - Play line playng_files $ (noexist)
        # and change the status to TORECEPTION, the action of which the occurrence of the event and
        will be called the procedure Play_TakeNumber #ev_media_done (end of playing a sound file)
        } elseif {$ the status = = "cd_006" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noexist)
        # In all other cases, the change in the status TORECEPTION, the action of which
        # and time of the event ev_media_done (audio file playback end) will be called
        # procedure GoToReception
        } the else {
                 # We lose "your call is forwarded to the Secretary"
                fsm setstate TORECEPTION
                media play leg_incoming $ playng_files (toreception)               
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ \ the n \ the n"
        }       
}

In CheckDestanation procedure that will be called after the dialing by the caller, we compare the figures obtained from the set with the settings and translate the script to the appropriate state team fsm setstate . All states, trapped in the function fall under the following FSM transitions:

the set ivr_fsm (CALLCONNECTED, ev_setup_done)    "CallIsConnect, same_state"
the set ivr_fsm (TORECEPTION, ev_media_done)            "GoToReception, same_state"
the set ivr_fsm (TRYAGAIN, ev_media_done)            "Play_TakeNumber, TRYING"
the set ivr_fsm (TRYING, ev_collectdigits_done)   "CheckDestanation, same_state"
the set ivr_fsm (TRYING, ev_named_timer)    "GoToReception, same_state"

Let's order. 1) So, initially feature CheckDestanation called after keystroke collection procedures. 2) for information on keystrokes we write variable digit with the command set digit [infotag get evt_dcdigits] Similarly record line status in the status variable 3) Then, We compare the results obtained with the set variables and change the state of the script at the coincidence:

the if {$ == $ digit The numbers (fast_reception) {}
the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the reception the next \ the n \ the n"
fsm setstate CALLCONNECTED
leg setup $ numbers (reception) callinfo leg_incoming
}

4) Check the Caller

proc CheckCallersAndConnect {digit} {
the puts "\ the n \ the n the IVR - the proc CheckCallersAndConnect the start \ the n \ the n"

set callernumber [infotag get leg_ani]

switch $ callernumber {
  "9120000000" {the set callInfo (displayInfo) "Director (mobile)" }
   "9130000000" {the set callInfo (displayInfo) "Buhgalter (mobile)"
  default {}
}
the puts "\ the n \ the n the IVR - correct caller is $ callernumber the connect with digit The $ \ the n \ the n"

leg setup $ digit callInfo leg_incoming
}

This feature allows you to change the field, responsible for writing the name of the caller. Just for the sake of aesthetics, it will be nicer when the phone will be written not only the number but the caller ID. After changing the caller ID is a connection line to the desired number.

5) Connecting Rooms

proc CallIsConnect {} {
        the puts "\ the n \ the n the IVR - the proc CallIsConnect the start \ the n \ the n"
        global playng_files       

# Define what is status
        set status [infotag get evt_status]
       
        # If the status is ls_000 (successful connection to the desired number), change in the status of CALLACTIVE
        the if {$ the status == "ls_000" } {
        fsm setstate CALLACTIVE       
       
        # If the status is ls_002 (nobody answered the call), run the procedure for requesting rooms
        } elseif {$ the status == "ls_002" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noanswer)
        # If the status - the wrong number, start the procedure for requesting rooms
        } elseif {$ the status == "ls_004" || the status == $ "ls_005" || the status == $ "ls_006" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noexist)
        # If the status is ls_007 (subscriber busy), run the procedure for requesting rooms
        } elseif {$ the status == "ls_007" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (busy)
        }
}

This function is called the next FSM transition:

ivr_fsm the set (CALLCONNECTED, ev_setup_done)    "CallIsConnect, same_state"

Event ev_setup_done comes after connecting the caller to the desired line.

6) Re-request number

proc Play_TakeNumber {} {
    the puts "\ the n \ the n the IVR - the proc Play_TakeNumber the start \ the n \ the n"
        global playng_files
         global numbers
         global the param
         global the pattern
       
        # Check for any time a subscriber tries to dial
        the if {$ numbers (cur_try) <= $ numbers (max_try) {}
        the puts "\ the n \ the n the IVR - the proc current Play_TakeNumber the try is: $ numbers (cur_try) \ the n \ the n"
        incr numbers (cur_try)

# Run the numbers pressed collection procedure from the caller
        leg collectdigits leg_incoming param pattern

# Start losing files
        media play leg_incoming $ playng_files (takenumber)

# Start the timer, after which the event will occur ev_named_timer
        timer start named_timer $ numbers (waiting_time) t1
       
        # If the attempt to more than $ numbers (max_try) - sever
        } the else {
                fsm setstate CALLDISCONNECTED
                media play leg_incoming $ playng_files (callafter)       
        }
}

This function checks for any time the caller makes a mistake, and if the value is less than $ numbers (max_try) prompts you to enter the number again. This function is called following the FSM :

ivr_fsm the set (TRYAGAIN, ev_media_done)                          "Play_TakeNumber, TRYING"
the set ivr_fsm (TRYING, ev_collectdigits_done)                         "CheckDestanation, same_state"
the set ivr_fsm (TRYING, ev_named_timer)                                 "GoToReception, same_state"

7) Disconnection

proc AbortCall {} {
the puts "\ the n \ the n the IVR - the proc AbortCall the start \ the n \ the n"
call close
}

Called following the FSM :

the set ivr_fsm (any_state, ev_disconnected)       "AbortCall, same_state"
the set ivr_fsm (CALLACTIVE, ev_disconnected)      "AbortCall, callDisconnected"
the set ivr_fsm (callDisconnected, ev_disconnected)    "AbortCall, same_state"
the set ivr_fsm (callDisconnected, ev_media_done)     "AbortCall, same_state"
the set ivr_fsm (callDisconnected, ev_disconnect_done)   "AbortCall, same_state"

8) Connection script

Connection on a Cisco router is held in 2 stages. The first thing to do is determine the application :

application
service voicemunu flash: voicemenu.tcl
  param allowed_pattern 5 [ 5 -7 ] ..
  param fastto_reception 1
  param reception_number 5501
  param fastto_ckp 2
  param ckp_number 5604
  param fastto_fax 3
  param fax_number 5555
  param waiting_time 20
  param max_try 3
  param file_noanswer flash: en_noanswer.au
  param file_after flash: en_after.au
  param file_noexist flash: en_noexist.au
  param file_busy flash: en_busy.au
  param file_welcome flash: en_welcome.au
  param file_onhold flash: music-on-hold.au
  param file_noworking flash: en_takenumber2.au
  param file_takenumber flash: en_takenumber2.au

Second , connect the service to of dial-a peer :

dial-peer voice 200 pots
description - = ISP Beeline - INcoming call to number 3300100 = -
service voicemunu
incoming called-number 3300100

Thus, when a call comes to the number 3300100, will call our voice menu voicemunu .

9) Full version of the script

Above we have considered only the basic functions of the script, then the full text, keep in mind this is almost the easiest option:

################################################## #####
# the Cisco the IVR the TCL script by the DA Konovalov v.2
################################## #####################
#
# to debug script
# the debug of voip application script
# Fuller debug (not recommended may lead to an overload)
# the debug of voip ivr
#
# The script must be run with the following parameters:
# 5 allowed_pattern the param [5-7] ..
# 1 fastto_reception the param
# param reception_number 5501
# param fastto_ckp 2
# param ckp_number 5604
# param fastto_fax 3
# param fax_number 5555
# param waiting_time 20
# param max_try 3
# the param file_welcome of flash: en_welcome.au
# file_takenumber the param of flash: en_takenumber.au
# file_after the param of flash: en_after.au
# file_busy the param of flash: en_busy.au
# file_noexist the param of flash: en_noexist.au
# file_noanswer the param of flash: en_noanswer.au
# file_onhold of flash the param: music-on-hold.au
# file_noworking the param of flash: music-on-hold.au

# Initialization procedure script
proc init {} {
    the puts "\ the n the proc the Init the start"
    global the param
}

# Procedure with variables
proc init_perCallVars {} {
        global the pattern
         global numbers
         global playng_files
       
        ##### Permissible numbering
        # If the script parameter is not specified allowable numbering will set .... - any 4 digits
        the if {[Infotag the get cfg_avpair_exists allowed_pattern]} {
                set pattern ( 1 ) [string trim [infotag get cfg_avpair allowed_pattern]]
                the puts "\ the n \ the n the IVR - as with the set the Allowed the pattern: the pattern $ (1) \ the n \ the n"
                } the else {
                        set pattern ( 1 ) ....
                        the puts "\ the n \ the n the IVR - the Allowed the set the pattern as with the DEFAULT: the pattern $ (1) \ n \ n"
                        }       
        ##### Rooms
        # Secretary. If no number of the Secretary in the script parameters will be set in 0000 number
        the if {[Infotag the get cfg_avpair_exists reception_number]} {
                set numbers (reception) [string trim [infotag get cfg_avpair reception_number]]
                the puts "\ the n \ the n the IVR - the reception number as with the set: $ numbers (the reception) \ the n \ the n"
                } the else {                       
                        set numbers (reception) 0000
                        the puts "\ the n \ the n the IVR - the reception the set number as with the DEFAULT: $ numbers (the reception) \ the n \ the n"
                        }       
        CCU #
        the if {[Infotag the get cfg_avpair_exists ckp_number]} {
                set numbers (ckp) [string trim [infotag get cfg_avpair ckp_number]]
                the puts "\ the n \ the n the IVR - ckp number as with the set: $ numbers (ckp) \ the n \ the n"
                } the else {                       
                        set numbers (ckp) 0000
                        the puts "\ the n \ the n the IVR - ckp the set number as with the DEFAULT: $ numbers (ckp) \ the n \ the n"
                        }
        Fax #
        the if {[Infotag the get cfg_avpair_exists fax_number]} {
                set numbers (fax) [string trim [infotag get cfg_avpair fax_number]]
                the puts "\ the n \ the n the IVR - fax number as with the set: $ numbers (fax) \ the n \ the n"
                } the else {                       
                        set numbers (fax) 0000
                        the puts "\ the n \ the n the IVR - fax number as with the set the DEFAULT: $ numbers (fax) \ the n \ the n"
                        }                       
        # Fast Transfer Reception at
        the if {[Infotag the get cfg_avpair_exists fastto_reception]} {
                set numbers (fast_reception) [string trim [infotag get cfg_avpair fastto_reception]]
                the puts "\ the n \ the n the IVR - to the reception of fast as with the set: $ numbers (fast_reception) \ the n \ the n"
                } the else {                       
                        set numbers (fast_reception) 1
                        the puts "\ the n \ the n the IVR - the set of fast to the reception as with the DEFAULT: $ numbers (fast_reception) \ the n \ the n"
                        }
        # Quick transfer to CCU
        the if {[Infotag the get cfg_avpair_exists fastto_ckp]} {
                set numbers (fast_ckp) [string trim [infotag get cfg_avpair fastto_ckp]]
                the puts "\ the n \ the n the IVR - of fast to ckp as with the set: $ numbers (fast_ckp) \ the n \ the n"
                } the else {                       
                        set numbers (fast_ckp) 2
                        the puts "\ the n \ the n the IVR - ckp of fast to the set as with the DEFAULT: $ numbers (fast_ckp) \ the n \ the n"
                        }
        # Quick transfer to fax
        the if {[Infotag the get cfg_avpair_exists fastto_fax]} {
                set numbers (fast_fax) [string trim [infotag get cfg_avpair fastto_fax]]
                the puts "\ the n \ the n the IVR - of fast to fax as with the set: $ numbers (fast_fax) \ the n \ the n"
                } the else {                       
                        set numbers (fast_fax) 3
                        the puts "\ the n \ the n the IVR - of fast fax to the set as with the DEFAULT: $ numbers (fast_fax) \ the n \ the n"
                        }
        # Timeout entering a number (to be more time loss of greeting file)
        the if {[Infotag the get cfg_avpair_exists waiting_time]} {
                set numbers (waiting_time) [string trim [infotag get cfg_avpair waiting_time]]
                the puts "\ the n \ the n the IVR - as with the set number: wait: $ numbers (waiting_time) \ the n \ the n"
                } the else {                       
                        set numbers (waiting_time) 10
                        the puts "\ the n \ the n the IVR - the set number: wait as with the DEFAULT: $ numbers (waiting_time) \ the n \ the n"
                        }
        # The number of attempts to enter the correct number before the call will be transferred to the Secretary of
        the if {[Infotag the get cfg_avpair_exists max_try]} {
                set numbers (max_try) [string trim [infotag get cfg_avpair max_try]]
                the puts "\ the n \ the n the IVR - max as with the try the set: $ numbers (max_try) \ the n \ the n"
                the set numbers (cur_try) 0
                } the else {                       
                        set numbers (max_try) 5
                        the puts "\ the n \ the n the IVR - max the try the set as with the DEFAULT: $ numbers (max_try) \ the n \ the n"
                        the set numbers (cur_try) 0
                        }
        ##### Music files, which will be played                
        # greeting file
        the if {[Infotag the get cfg_avpair_exists file_welcome]} {
                set playng_files (welcome) [string trim [infotag get cfg_avpair file_welcome]]
                the puts "\ the n \ the n the IVR - file_welcome as with the set: $ playng_files (welcome) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (welcome)% s1
                        the puts "\ the n \ the n the IVR - file_welcome the set as with the DEFAULT: $ playng_files (welcome) \ the n \ the n"
                        }
        # Request file to enter the number you want
        the if {[Infotag the get cfg_avpair_exists file_takenumber]} {
                set playng_files (takenumber) [string trim [infotag get cfg_avpair file_takenumber]]
                the puts "\ the n \ the n the IVR - file_takenumber as with the set: $ playng_files (takenumber) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (takenumber)% s1
                        the puts "\ the n \ the n the IVR - file_takenumber the set as with the DEFAULT: $ playng_files (takenumber) \ the n \ the n"
                        }
        File # "Please call back later,"
        the if {[Infotag the get cfg_avpair_exists file_after]} {
                set playng_files (callafter) [string trim [infotag get cfg_avpair file_after]]
                the puts "\ the n \ the n the IVR - file_after as with the set: $ playng_files (callafter) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (callafter)% s1
                        the puts "\ the n \ the n the IVR - file_after the set as with the DEFAULT: $ playng_files (callafter) \ the n \ the n"
                        }
        File # "Number busy"
        the if {[Infotag the get cfg_avpair_exists file_busy]} {
                set playng_files (busy) [string trim [infotag get cfg_avpair file_busy]]
                the puts "\ the n \ the n the IVR - file_busy as with the set: $ playng_files (busy) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (busy)% s1
                        the puts "\ the n \ the n the IVR - file_busy the set as with the DEFAULT: $ playng_files (busy) \ the n \ the n"
                        }
        File # "number does not exist,"
        the if {[Infotag the get cfg_avpair_exists file_noexist]} {
                set playng_files (noexist) [string trim [infotag get cfg_avpair file_noexist]]
                the puts "\ the n \ the n the IVR - file_noexist as with the set: $ playng_files (noexist) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (noexist)% s1
                        the puts "\ the n \ the n the IVR - file_noexist the set as with the DEFAULT: $ playng_files (noexist) \ the n \ the n"
                        }
        # File "now connects with the secretary / operator"
        the if {[Infotag the get cfg_avpair_exists file_toreception]} {
                set playng_files (toreception) [string trim [infotag get cfg_avpair file_toreception]]
                the puts "\ the n \ the n the IVR - file_toreception as with the set: $ playng_files (toreception) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (toreception)% s1
                        the puts "\ the n \ the n the IVR - file_toreception the set as with the DEFAULT: $ playng_files (toreception) \ the n \ the n"
                        }
        File # "number does not answer, call back later,"
        the if {[Infotag the get cfg_avpair_exists file_noanswer]} {
                set playng_files (noanswer) [string trim [infotag get cfg_avpair file_noanswer]]
                the puts "\ the n \ the n the IVR - file_noanswer as with the set: $ playng_files (noanswer) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (noanswer)% s1
                        the puts "\ the n \ the n the IVR - file_noanswer the set as with the DEFAULT: $ playng_files (noanswer) \ the n \ the n"
                        }
        # Music file to be played while waiting for
        the if {[Infotag the get cfg_avpair_exists file_onhold]} {
                set playng_files (onhold) [string trim [infotag get cfg_avpair file_onhold]]
                the puts "\ the n \ the n the IVR - file_onhold as with the set: $ playng_files (for onhold) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (onhold)% s1
                        the puts "\ the n \ the n the IVR - file_onhold the set as with the DEFAULT: $ playng_files (for onhold) \ the n \ the n"
                        }
        File # music that will be played in the time off
        the if {[Infotag the get cfg_avpair_exists file_noworking]} {
                set playng_files (noworking) [string trim [infotag get cfg_avpair file_noworking]]
                the puts "\ the n \ the n the IVR - file_noworking as with the set: $ playng_files (noworking) \ the n \ the n"
                } the else {
                         # If the file is not found, it will be replaced by silence in 1ms
                        set playng_files (noworking)% s1
                        the puts "\ the n \ the n the IVR - file_noworking the set as with the DEFAULT: $ playng_files (noworking) \ the n \ the n"
                        }
}

proc GetDate {} {
        global workingtime
       
        #Hour
        set houris [clock format [clock seconds] -format% H]
        # Day of week
        set dayis [clock format [clock seconds] -format% A]
        # Check the working time
        the if {$ houris> 17 || $ houris < 8 || dayis == $ "the Sunday" || dayis == $ "on Saturday" } {
        set workingtime 0
        } the else {
        set workingtime 1
        }
}

# Procedure loss greetings
proc Play_Welcome {} {
    the puts "\ the n \ the n the IVR - the proc Play_Welcome the start \ the n \ the n"
        global playng_files
         global the param
         global the pattern
         global numbers
         global workingtime
       
        # Call the procedure, which describes all the variables
        init_perCallVars
       
        # Get the time
        GetDate
        # Depending on the working time is now or not, set the greeting
        the if {} {$ workingtime
        set after_welcome $ playng_files (takenumber)       
        } Else {
        set after_welcome $ playng_files (noworking)
        }
       
        # Set the connection parameters of the incoming call
        set param (interruptPrompt) true
        set param (abortKey) *
        the param the set (terminationKey) #       
       
        # Connect the incoming call
    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
       
        # Run the numbers pressed collection procedure from the caller
        leg collectdigits leg_incoming param pattern
        # Start losing files caller, after their completion will start
        # act param timer (interDigitTimeout), after which
        # will ev_collectdigits_done event
    media play leg_incoming% s500 $ playng_files (welcome) $ after_welcome $ playng_files (onhold)
        # Start the timer, after which the event will occur ev_named_timer
        timer start named_timer $ numbers (waiting_time) t1
}

# Procedure request to enter the number
proc Play_TakeNumber {} {
    the puts "\ the n \ the n the IVR - the proc Play_TakeNumber the start \ the n \ the n"
         global playng_files
         global numbers
         global the param
         global the pattern
       
        # Check for any time a subscriber tries to dial
        the if {$ numbers (cur_try) <= $ numbers (max_try) {}
        the puts "\ the n \ the n the IVR - the proc current Play_TakeNumber the try is: $ numbers (cur_try) \ the n \ the n"
        incr numbers (cur_try)
        # Run the numbers pressed collection procedure from the caller
        leg collectdigits leg_incoming param pattern
        # Start losing files
        media play leg_incoming $ playng_files (takenumber)
        # Start the timer, after which the event will occur ev_named_timer
        timer start named_timer $ numbers (waiting_time) t1
       
        # If the attempt to more than $ numbers (max_try) - sever
        } the else {
                fsm setstate CALLDISCONNECTED
                media play leg_incoming $ playng_files (callafter)       
        }
}

# Transfer procedure call to the Secretary
proc GoToReception {} {
        the puts "\ the n \ the n the IVR - the proc GoToReception the start \ the n \ the n"
        global numbers
         # Stop the loss of media
        media stop leg_incoming
        # Change state
        fsm setstate CALLCONNECTED
       
        set digit $ numbers (reception)
       
        # Pass $ digit The function in CheckCallersAndConnect
        CheckCallersAndConnect $ digit
}

# Here, we check the entered or not entered callers numbers
proc CheckDestanation {} {
    the puts "\ the n \ the n the IVR - the proc CheckDestanation the start \ the n \ the n"
        global playng_files
         global numbers
         global digit The
         # Stop the loss of media
        media stop leg_incoming
       
        # Determine the value of a variable
    set status [infotag get evt_status]
        set digit [infotag get evt_dcdigits]
       
        # Compare the figures and statuses
        # If the entered number corresponds to that specified in the $ numbers (fast_reception),
        # change the digit number to the reception and transfer $ digit in CheckCallersAndConnect function
        # after changing the status to CALLCONNECTED,
        # whereby, when an event occurs ev_setup_done (connection to a number of the Secretary)
        # will be worked out procedure CallIsConnect
        the if {$ == $ digit The numbers (fast_reception) {}
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the reception the next \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (reception)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If you enter a number that corresponds to that specified in the $ numbers (fast_ckp), connect to the CCU
        # through CheckCallersAndConnect
        } Elseif {$ digit == $ numbers (fast_ckp)} {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the next the CKP \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (ckp)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If you enter a number that corresponds to that specified in the $ numbers (fast_fax), connect to the fax
        # through CheckCallersAndConnect
        } Elseif {$ digit == $ numbers (fast_fax)} {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation digit The digit The $ = \ Ngoing to the next fax \ the n \ the n"
                fsm setstate CALLCONNECTED
                set digit $ numbers (fax)
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If the status = cd_004 (entered the correct digits) - connect to the desired number
        # through CheckCallersAndConnect
        } elseif {$ the status == "cd_004" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate CALLCONNECTED
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit
        # If the status = cd_005 (coincidence with the dial plan) - connect to the desired number
        # through CheckCallersAndConnect       
        } elseif {$ the status == "cd_005" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate CALLCONNECTED       
                # Pass $ digit The function in CheckCallersAndConnect
                CheckCallersAndConnect $ digit       
        # If the status = cd_006 (dialed is not an existing number) - Play line of $ playng_files (noexist)
        # and change the status to TRYAGAIN, under the action of which the event occurs ev_media_done
        is invoked procedure Play_TakeNumber # (end of playing a sound file)
        } elseif {$ the status = = "cd_006" } {
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ = $ digit The digit The \ the n \ the n"
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noexist)
        # In all other cases, the change in the status TORECEPTION, under the action of which
        # event occurs ev_media_done (audio file playback end) will cause a procedure GoToReception
        } the else {
                 # We lose "your call is forwarded to the Secretary"
                fsm setstate TORECEPTION
                media play leg_incoming $ playng_files (toreception)               
                the puts "\ the n \ the n the IVR - the proc CheckDestanation the status the status = $ \ the n \ the n"
        }       
}

# Check the caller, if the same, we will change the display name
proc CheckCallersAndConnect {digit} {
        the puts "\ the n \ the n the IVR - the proc CheckCallersAndConnect the start \ the n \ the n"
       
        set callernumber [infotag get leg_ani]
       
         switch $ callernumber {
         "9120000000" {the set callInfo (displayInfo) "Director (mobile)" }
          "9130000000" {the set callInfo (displayInfo) "Buhgalter (mobile)"
         default {}        
        }
       
        leg setup $ digit callInfo leg_incoming
}

# Procedure for checking the state of the line after connecting the caller to the desired number
proc CallIsConnect {} {
        the puts "\ the n \ the n the IVR - the proc CallIsConnect the start \ the n \ the n"
        global playng_files       

# Define what is status
        set status [infotag get evt_status]
       
        # If the status is ls_000 (successful connection to the desired number), change in the status of CALLACTIVE
        the if {$ the status == "ls_000" } {
        fsm setstate CALLACTIVE       
       
        # If the status is ls_002 (nobody answered the call), run the procedure for requesting rooms
        } elseif {$ the status == "ls_002" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noanswer)
        # If the status - the wrong number, start the procedure for requesting rooms
        } elseif {$ the status == "ls_004" || the status == $ "ls_005" || the status == $ "ls_006" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (noexist)
        # If the status is ls_007 (subscriber busy), run the procedure for requesting rooms
        } elseif {$ the status == "ls_007" } {
                fsm setstate TRYAGAIN
                media play leg_incoming $ playng_files (busy)
        }
}

# Procedure Call interrupt
proc AbortCall {} {
        the puts "\ the n \ the n the IVR - the proc AbortCall the start \ the n \ the n"
        call close
}

Execution script #
init
#init_perCallVars

# This is a set of conditions, and arising from the state of the event data
# In fact, this is what describes the script
       
        # If in any state arises off event ev_disconnected, cause AbortCall
        the set ivr_fsm (any_state, ev_disconnected)                             "AbortCall, same_state"
       
        # If the condition occurs CALLCOMES ev_setup_indication event (incoming call)
        # runs Play_Welcome, and the state changes to same_state (ie remains the same),
        the set ivr_fsm (CALLCOMES, ev_setup_indication)                   "Play_Welcome, same_state"
       
        # If the condition occurs CALLCOMES ev_collectdigits_done event (finished entering digits)
        # runs CheckDestanation, and the state remains the same
        the set ivr_fsm (CALLCOMES, ev_collectdigits_done)                 "CheckDestanation, same_state"
       
        # If the condition occurs CALLCOMES ev_named_timer event (ended input wait timer digits)
        # runs GoToReception, and the state remains the same
        the set ivr_fsm (CALLCOMES, ev_named_timer)                                 "GoToReception, same_state"
       
        # If the condition occurs TORECEPTION ev_media_done event (ended losing file)
        # runs GoToReception, and the state remains the same
        the set ivr_fsm (TORECEPTION, ev_media_done)                          "GoToReception, same_state"
       
        # These settings describe the behavior of the script with an error in the room
        the set ivr_fsm (TRYAGAIN, ev_media_done)                          "Play_TakeNumber, TRYING"
        the set ivr_fsm (TRYING, ev_collectdigits_done)                         "CheckDestanation, same_state"
        the set ivr_fsm (TRYING, ev_named_timer)                                         "GoToReception, same_state"
       
        # If you are able to CALLCONNECTED event occurs ev_setup_done
        # (set / unset connection to the desired number) starts CallIsConnect, and the state remains the same
        the set ivr_fsm (CALLCONNECTED, ev_setup_done)                          "CallIsConnect, same_state"
       
        # These events work out off line of
        the set ivr_fsm (CALLACTIVE, ev_disconnected)                            "AbortCall, callDisconnected"
        the set ivr_fsm (callDisconnected, ev_disconnected)                  "AbortCall, same_state"
        the set ivr_fsm (callDisconnected, ev_media_done)                   "AbortCall, same_state"
        the set ivr_fsm (callDisconnected, ev_disconnect_done)          " AbortCall, same_state "

i'm facing the same problem with app-b-acd-aa-2.1.2.2
could you share your correctly running script please.

Hope it helps

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: