TCL Digit Collection problems - no digits only timeout error

Version 1
    This document was generated from CDN thread

    Created by: Michael Lee on 27-07-2012 02:13:16 AM
    Hi all,
     
    I'm new to the whole tcl scripting, and I'm having issues collecting digits from the IVR menu played as part of my script.
     
    I'm sure I've hit a basic (newbie) issue, any help would be great.
     
    thanks in advance.
     
    proc init { } {
        global PARAM
        global auClose
        global auOpen
        global configFail
        global langPrefix
        global auPrompt
        global storeStateFile
           
        set storeStateFile "flash:storestate"
        set PARAM(interruptPrompt) true
        set PARAM(initialDigitTimeout) 10
        set PARAM(abortKey) *
        set PARAM(terminationKey) #
        set PARAM(maxDigits) 1
        set pattern(1) "1"
        set pattern(2) "2"
    }

    proc init_ConfigVars { } {
        global PARAM
        global auClose
        global auOpen
        global configFail
        global langPrefix
        global auPrompt
           
        set configFail 0
        set auClose "NONE"
       
        act_Debug "In proc init_ConfigVars"
       
        if [infotag get cfg_avpair_exists lang-prefix] {
            set langPrefix [string trim [infotag get cfg_avpair lang-prefix]]
            act_Debug "Audio file language is $langPrefix"
        } else {
            set langPrefix "en"
            act_Debug "Language not configured; setting default to english"   
        }
       
        if [infotag get cfg_avpair_exists auclose] {
            set auClose [string trim [infotag get cfg_avpair auclose]]
                
        } else {
            set auClose "_cls_close.au"
            act_Debug "Configured Audio Prompt is $auClose" 
        }
       
        if [infotag get cfg_avpair_exists auopen] {
            set auOpen [string trim [infotag get cfg_avpair auopen]]
            act_Debug  "Configured Audio Prompt is $auOpen"      
        } else {
            set auOpen "_cls_open.au"
            act_Debug  "Configured Audio Prompt is $auOpen" 
        }

    }

    proc act_Setup { } {
        global PARAM
        global auClose
        global auOpen
        global configFail
        global langPrefix
        global storeState
        global auPrompt
        global storeStateFile
        set storeState 0
        set auPrompt $auOpen
        set PARAM(interruptPrompt) true
        set PARAM(initialDigitTimeout) 10
        set PARAM(abortKey) *
        set PARAM(terminationKey) #
        set PARAM(maxDigits) 1
        set pattern(1) "1"
        set pattern(2) "2"
       
        act_Debug "Entered process act_Setup"
        leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming
       
        if [file exists $storeStateFile] {
            act_Debug "Store is currently Closed"
            set storeState 1
            set auPrompt $auClose
            act_StoreState 1
        }
       
              act_Debug "TCL CLS: >>>> Playing Audio $langPrefix$auPrompt"
            leg collectdigits leg_incoming PARAM pattern
            media play leg_incoming $auPrompt _cls_menu.au
    }

    proc act_ChooseMenu { } {
        global PARAM
        global optionRetryCnt
        global retryCnt
        global promptMenu
        global status
        global optionSelected

        act_Debug "In proc act_ChooseMenu"

        set status [infotag get evt_status]
        act_Debug "call leg status = $status"
       
            if {$status == "cd_005" } {
                 set optionSelected [infotag get evt_dcdigits]
                act_Debug "User pressed digit $optionSelected"
       
             switch -exact $optionSelected  {
                 {1} {
                         act_Debug "Opening Store"
                         
                    }
                 {2} {
                         act_Debug "Closing Store"
                         
                        }                
                 default {
                     act_Debug "Exit key press; Close call"
                     fsm setstate CALLDISCONNECT
                     media play leg_incoming _aamnt_goodbye.au
                     }
              }
        }

    }

    proc act_StoreState {state} {
        global fileHandle
        global storeStateFile
        act_Debug "In proc act_StoreState, state = $state"
       
        if {$state}  {
                    file delete $storeStateFile
                    act_Debug "Store now Open, file deleted state = $state, filename = $storeStateFile"
                } else {
                         if [info exists $storeStateFile] {
                                    file delete $storeStateFile
                                        } else {
                            set fileHandle [open $storeStateFile "w"]
                            puts $fileHandle "Close"
                            act_Debug "Store now Closed"
                            close $fileHandle
                    }           
        }   
    }

    proc act_Cleanup { } {
        act_Debug "Entered process act_Cleanup"
        call close
    }

    proc act_Debug {comment} {
        puts -nonewline "TCL CLS: >>>> $comment <<<<"
    }

    requiredversion 2.0
    init
    init_ConfigVars
    #----------------------------------
    #   Finite State Machine (FSM).
    #----------------------------------
        set fsm(any_state,ev_disconnected)   "act_Cleanup same_state"
        set fsm(CALL_INIT,ev_setup_indication) "act_Setup MEDIAPLAY"
        set fsm(MEDIAPLAY,ev_media_done) "act_ChooseMenu GETOPTION"
        set fsm(GETOPTION,ev_collectdigits_done) "act_ChooseMenu same_state"
        set fsm(CALL_INIT,ev_disconnected) "act_Cleanup same_state"
       
        fsm define fsm CALL_INIT

    Subject: RE: TCL Digit Collection problems - no digits only timeout error
    Replied by: Michael Lee on 27-07-2012 03:38:54 AM
    Hi Anusha,

    Thank-you for your quick response.

    I will update the FSM, but I found the problem and why I wasn't receiving digits   I completely forgot the dtmf commands on the dial-peer

    Some times its just good putting the question out there.

    thanks,

    Mike

    Subject: RE: TCL Digit Collection problems - no digits only timeout error
    Replied by: Anusha Kannappan on 27-07-2012 03:20:05 AM
    Hi,

    Please change the FSM as below and give a try

      set fsm(any_state,ev_disconnected)   "act_Cleanup same_state"
      set fsm(CALL_INIT,ev_setup_indication) "act_Setup GETOPTION"
      set fsm(GETOPTION,ev_collectdigits_done) "act_ChooseMenu same_state"


      set fsm(CALL_INIT,ev_disconnected) "act_Cleanup same_state"
      
      fsm define fsm CALL_INIT

    Thanks,
    Anusha