Playing greeting message by time. (Depending on the time)

Version 1
    This document was generated from CDN thread

    Created by: Oleksandr Zasimovich on 27-12-2011 05:00:39 AM
    Hello, colleagues!!!
    Please, help me solve my task for my work! I can not make himself this task
    Help me fix it and finish the tcl-script, where the welcome message (.au) varied depending on the time. In the morning (from 8:00 till 19:00) playing morning.au, in the evening (from 19:00 till 8:00) playing evening.au

    Here is my script:

    # Script Locked by: khom
    # Script Version: 2.0.1.0
    # Script Name: its_CISCO
    # Script Lock Date: Wed Jul  2 09:22:04 2003
    #------------------------------------------------------------------
    # November 27, 2001, Satish Ananthanarayana (sanantha@cisco.com)
    #        
    # Copyright (c) 2001 by cisco Systems, Inc.
    # All rights reserved.
    #------------------------------------------------------------------
    #        
    # Description:
    # This is a TCL IVR script for the IOS Telephony Service and
    # Call Manager (CM) offload scenario. The IVR script plays a
    # welcome prompt to the user and prompts the user to enter a
    # destination number when the user dials the auto-attendant number
    # (aa-pilot configured in the CLI). The script collects the digits that
    # the user has entered and hands the call to the enhanced session
    # application (named Default).  The session application
    # returns once there is a disconnect (if the call is established)
    # or if a call setup problem occurs.
    # The operator support is also included, if the user does not dial
    # any number or enters "0" the user will be transfered to an operator
    # (if operator number is configured in the CLI). If the user enters
    # an invalid number, the user will be prompted again to re-enter
    # the number for upto 3 times before disconnecting the call.
    #
    #-------------------------------------------------------------------
    #        


    proc init { } {
        global param1
        global selectCnt
        global callInfo
        global legConnected
        set param1(interruptPrompt) true
     set param1(initialDigitTimeout) 6
        set param1(abortKey) *
        set param1(terminationKey) #
        set selectCnt 0
     set selectCnt 2
     set selectCnt 3
     set selectCnt 4
     set selectCnt 5
        set legConnected false
    }
    proc init_ConfigVars { } {
        global destination
        global aaPilot
        global oprtr
        global oprtra
        global oprtrb
     global oprtrc
     global oprtrd
    # aa-pilot is the IVR number configured on the gateway to be used by the customer
    # operator is the operator number for assisted calling
        if [infotag get cfg_avpair_exists aa-pilot] {
            set aaPilot [string trim [infotag get cfg_avpair aa-pilot]]
        } else {
            set aaPilot "NONE"
        }
        if [infotag get cfg_avpair_exists operator] {
            set oprtr [string trim [infotag get cfg_avpair operator]]
        } else {
            set oprtr "NONE"
        }
     

     if [infotag get cfg_avpair_exists operatora] {
            set oprtra [string trim [infotag get cfg_avpair operatora]]
        } else {
            set oprtra "NONE"
        }
     if [infotag get cfg_avpair_exists operatorb] {
            set oprtrb [string trim [infotag get cfg_avpair operatorb]]
        } else {
            set oprtrb "NONE"
        }
        if [infotag get cfg_avpair_exists operatorc] {
            set oprtrc [string trim [infotag get cfg_avpair operatorc]]
        } else {
            set oprtrc "NONE"
        }
     if [infotag get cfg_avpair_exists operatord] {
            set oprtrd [string trim [infotag get cfg_avpair operatord]]
        } else {
            set oprtrd "NONE"
        }
    }
    proc init_perCallVars { } {
        puts "\nproc init_perCallvars"
        global ani
        global digit_enabled
        global fcnt
        global retrycnt
        global dnis
        set fcnt 0
        set retrycnt 6
        set ani ""
        set dnis ""
        set digit_enabled "FALSE"
        set ani [infotag get leg_ani]
        puts "\nANI $ani"
        set dnis [infotag get leg_dnis]
        puts "\nDNIS $dnis"
    }
    proc act_Setup { } {
        global param1
        global selectCnt
        global dest
        global beep
        global callInfo
        global dnis
        global fcnt
        global aaPilot
        global oprtr
        global busyPrompt
        global legConnected
        puts "proc act_Setup"
        set busyPrompt flash:en_dest_unreachable.au
        set beep 0
        init_perCallVars
        infotag set med_language 1
        if { ($dnis == "") || ($dnis == $aaPilot) } {
            leg setupack leg_incoming
         leg proceeding leg_incoming
         leg connect leg_incoming
            set legConnected true
     puts "\nNo DNIS\n"
            set param1(dialPlan) true
            leg collectdigits leg_incoming param1
            media play leg_incoming flash:morning.au
        } else {
            set fcnt 6
     leg setupack leg_incoming
            handoff callappl leg_incoming default "DESTINATION=$dnis"
            fsm setstate HANDOFF
        }

    }
    proc act_GotDest { } {
        global dest
        global callInfo
        global oprtr
     global oprtra
     global oprtrb
     global oprtrc
     global oprtrd
        global busyPrompt
        puts "\n proc act_GotDest"
        set status [infotag get evt_status]
        set callInfo(alertTime) 20
        if {  ($status == "cd_004") } {
            set dest [infotag get evt_dcdigits]
     if { $dest == "0" } {
      set dest $oprtr
     }
     
     if { $dest == "2" } {
      set dest $oprtra
     }
     if { $dest == "3" } {
      set dest $oprtrb
     }
        if { $dest == "4" } {
      set dest $oprtrc
     }
     if { $dest == "5" } {
      set dest $oprtrd
     }

            handoff callappl leg_incoming default "DESTINATION=$dest"
        } elseif { ($status == "cd_001") || ($status == "cd_002") } {
     set dest $oprtr
            handoff callappl leg_incoming default "DESTINATION=$dest"
        } else {
     if { $status == "cd_006" } {
      set busyPrompt flash:en_dest_unreachable.au
     }
            puts "\nCall [infotag get con_all] got event $status collecting destination"
     set dest [infotag get evt_dcdigits]
     if { $dest == "0" } {
      set dest $oprtr
      handoff callappl leg_incoming default "DESTINATION=$dest"
     }
     
     if { $dest == "2" } {
      set dest $oprtra
     handoff callappl leg_incoming default "DESTINATION=$dest"
     }
     if { $dest == "3" } {
      set dest $oprtrb
     handoff callappl leg_incoming default "DESTINATION=$dest"
     }
        if { $dest == "4" } {
      set dest $oprtrc
     handoff callappl leg_incoming default "DESTINATION=$dest"
     }
     if { $dest == "5" } {
      set dest $oprtrd
     handoff callappl leg_incoming default "DESTINATION=$dest"
     }
     

      else {
             act_Select
     }
        }
    }

    proc act_CallSetupDone { } {
        global busyPrompt
        global legConnected
        set status [infotag get evt_handoff_string]
        if { [string length $status] != 0} {
            regexp {([0-9][0-9][0-9])} $status StatusCode
            puts "IP IVR Disconnect Status = $status"
            switch $StatusCode {
              "016" {
                  puts "\n Connection success"
                  fsm setstate CONTINUE
                  act_Cleanup
              }
              default {
                  if { $legConnected == "false" } {
                      leg proceeding leg_incoming 
                      leg connect leg_incoming 
                      set legConnected true
                  }
                  puts "\n Call failed.  Play prompt and collect digit"
                  if { ($StatusCode == "017") } {
                      set busyPrompt flash:en_dest_busy.au
                  }
                  act_Select
              }
            }
        } else {
            puts "\n Caller disconnected"
            fsm setstate CALLDISCONNECT
            act_Cleanup
        }
    }
    proc act_Select { } {
        global destination
        global promptFlag2
        global destBusy
        global param1
        global fcnt
        global retrycnt
        global busyPrompt
       
        puts "\n proc act_Select"
        set promptFlag2 0
        set param1(interruptPrompt) true
        set param1(abortKey) *
        set param1(terminationKey) #
        set param1(dialPlan) true
        set param1(dialPlanTerm) true
        leg collectdigits leg_incoming param1
        if { $fcnt < $retrycnt } {
         media play leg_incoming $busyPrompt %s500 flash:en_reenter_dest.au
     incr fcnt
         fsm setstate GETDEST
        } else {
     act_DestBusy
        }
    }
    proc act_DestBusy { } {
        puts "\n proc act_DestBusy"
        media play leg_incoming flash:en_disconnect.au
        fsm setstate CALLDISCONNECT
    }
    proc act_Cleanup { } {
        call close
    }
    requiredversion 2.0
    init
    init_ConfigVars
    #----------------------------------
    #   State Machine
    #----------------------------------
      set fsm(any_state,ev_disconnected)   "act_Cleanup  same_state"
     
      set fsm(CALL_INIT,ev_setup_indication) "act_Setup  GETDEST"
      set fsm(GETDEST,ev_collectdigits_done) "act_GotDest HANDOFF"
      set fsm(HANDOFF,ev_returned)   "act_CallSetupDone  CONTINUE"
     
      set fsm(CALLDISCONNECT,ev_media_done) "act_Cleanup  same_state"
     
      fsm define fsm CALL_INIT
    # Script Approval Signature: C/775c

    Subject: RE: Playing greeting message by time. (Depending on the time)
    Replied by: Anusha Kannappan on 02-01-2012 12:51:29 AM
    Hi Oleksandr,

    You can make use of the command 'clock' for getting the value of time and store in a variable. Later based on the timing you can play the audio files as per your requirement. Here is the syntax for the same

    clock
    This command performs one of several operations that can obtain or manipulate strings or values that represent some amount of time.
    Syntax
    clock option arg arg

    For more details you can refer to the developer guide in the below link

    http://www.cisco.com/en/US/docs/ios/voice/tcl/developer/guide/tclivrv2_ch3.html

    Thanks,
    Anusha

    Subject: RE: Playing greeting message by time. (Depending on the time)
    Replied by: Oleksandr Zasimovich on 03-01-2012 03:11:59 AM
    Anusha, thank you very much for your reply!
    Forgive my insistence, but could you give an example part of the script in my case, please, I'm not very good at programming unfortunatelly
     
    Thanks,
    Oleksandr

    Subject: RE: Playing greeting message by time. (Depending on the time)
    Replied by: Anusha Kannappan on 03-01-2012 04:30:40 AM
    Hi Oleksandr,

    You can make use of the following command to get the clock value

    set time_hh [clock format [clock seconds] -format "%H"]

    And based on the value you get for 'time_hh' do a simple check whether it is coming under morning or evening then play the respective audio files.

    If still help needed you can open a SR with developer services contract for this request.
    http://developer.cisco.com/web/devservices

    Thanks,
    Anusha