Simple tcl script for Play a Audio and forward call to Called number

Version 1
    This document was generated from CDN thread

    Created by: W S H Fernando on 17-11-2013 09:34:28 PM
    Hi Team

    I need a simple tcl script to play a audio in incoming call and then forward it to called number, no other options are needed such as digit collect and etc. can please anyone share a sample script for this ? this will be a great help, because i'm new to TCL.


    Subject: RE: Simple tcl script for Play a Audio and forward call to Called number
    Replied by: Raghavendra Gutty Veeranagappa on 20-11-2013 03:23:13 AM
    Hi Fernando,
    please use the below sample code. modify audio file name accordingly.

    #procedure to play audio file
    proc act_Media { } {
        global dest
        set dest [infotag get leg_dnis]

        leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming
        media play leg_incoming
    # setup the call, connect caller to called party
    proc act_Setup { } {
        global dest
        puts ">>> Tcl: proc act_Setup <<<"
        puts ">>> TCL:Final Dest: $dest <<<"   
        leg setup $dest callInfo leg_incoming     
    proc act_CallSetupDone { } { s    
        set status [infotag get evt_status]
        puts "\n CALL STATUS = $status"
        if { $status == "ls_000"} {
            puts "\n You have sucessfully placed the call to the destination !"
        } else {        
            puts "\n Sorry your call was not connnected !"
            call close

    # disconnect the call
    proc act_Cleanup { } {
        puts ">>> Tcl: act_Cleanup <<<"
        call close

    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(PLACECALL,ev_setup_done)      "act_CallSetupDone CALLDISCONNECT"
    set fsm(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
    set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"

    fsm define fsm CALL_INIT