The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Индекс форумов
Составление сообщения

Исходное сообщение
"Нужна помощь по  TCL IVR  !!!!!! плиз !!"
Отправлено ATeam, 20-Сен-06 15:19 
>>
>>proc act_CallSetup { } {
>>    global destination
>>    global account
>>
>>    set callInfo(accountNum) $account
>>    set dnis [infotag get leg_dnis]
>>    leg setup $dnis callInfo leg_incoming
>>
>>}
>>
>
>>    set dnis [infotag get leg_dnis]
> Взять номер набора равным номеру income dialpeer.
>>    leg setup $dnis callInfo leg_incoming
> Для вызова с другого номера стоит переписать примерно так :
>
>>proc act_CallSetup { } {
>>    global destination
>>    global account
>>
>>    set callInfo(accountNum) $account
>>#  set dnis [infotag get leg_dnis]
>>#   leg setup $dnis callInfo leg_incoming
>>   leg setup $destination callInfo leg_incoming
>>
>>}
>
>Посторите примеры встроенных скриптов.

Смысл в том, что при  
set destination [infotag get evt_dcdigits]

он в остальных процедурах ждёт нажатия цифр и потом их заносит в
эту переменную , а в данном случае он почему то туда засовывает called number ((

proc init { } {
    global param1
    global beep
    global param2
    global param3

    set beep 0

    set param1(interruptPrompt) true
    set param1(abortKey) *
    set param1(terminationKey) #

    
    set param2(interruptPrompt) true
    set param2(abortKey) *
    set param2(terminationKey) #
    set param2(dialPlanTerm) true

    set param3(interruptPrompt) true
    set param3(abortKey) *
    set param3(terminationKey) #
}

proc init_ConfigVars { } {
    global accountLen
    global pinLen
    global retryCnt
    global operatorNum
    global warnTime
    global totalLang
    global prefix
    global prefix1
    global prefix2

    set accountLen [string trim [infotag get cfg_avpair uid-len]]
    set pinLen [string trim [infotag get cfg_avpair  pin-len]]
    set retryCnt [string trim [infotag get  cfg_avpair retry-count]]
    set operatorNum [string trim [infotag get cfg_avpair  redirect-number]]
    set warnTime [string trim [infotag get cfg_avpair  warning-time]]

    #Language related variables
    set totalLang [string trim [infotag get med_total_languages]]
}

proc init_perCallVars { } {
    global selectCnt
    global count
    global fcnt
    global ani
    global dontPlayAmount
    global destBusy
    global noTimeLimit
    global promptFlag
    global promptFlag2
    global noPlay
    global outgoingDisconnect

    set selectCnt 0
    set count 0
    set fcnt 0
    set dontPlayAmount 0
    set destBusy 0
    set noTimeLimit 0
    set promptFlag 0
    set promptFlag2 0
    set noPlay 0
    set outgoingDisconnect 0

    set ani [infotag get leg_ani]
    
}

proc act_Setup { } {

    global totalLang
    global param1
    global selectCnt

    init_perCallVars
    infotag set med_language 1

    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming

    #Lang selection
    puts "\nTotalLanguages=$totalLang"
    if { $totalLang < 1 } {
    act_Cleanup
    return
    }
    
    if { $totalLang == 1 } {
    media play leg_incoming _welcome.au
    fsm setstate ONELANG
    return
    }

    set param1(maxDigits) 1
    leg collectdigits leg_incoming param1

    #Get the map and use it...not this way ???
    media play leg_incoming _welcome.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au
    
}


proc act_LangSelect { } {
    global param1
    global selectCnt
    global retryCnt

    set status [infotag get evt_status]
    
    #Collect Success ...matched pattern
    if {$status == "cd_005"} {
    set status [infotag set med_language [infotag get evt_dcdigits] ]

    if { ($status == "language not supported") ||
         ($status == "language not specified in configuration") } {
        
        incr selectCnt
        if {$selectCnt < $retryCnt} {
        #Get the map and use it...not this way ???
        
        set param1(maxDigits) 1
        leg collectdigits leg_incoming param1
        media play leg_incoming  %c1 _wrong_lang_sel.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au
        
        fsm setstate same_state
        return
            } else {
        media play leg_incoming %c1 _generic_final.au
        fsm setstate CALLDISCONNECT
        return
            }
    }
    #Get the card No
    act_GetCard
    }
    
    #Collect timeout/Abort
    if { ($status == "cd_001") ||
     ($status == "cd_002")} {

    incr selectCnt
    if {$selectCnt < $retryCnt} {
        leg collectdigits leg_incoming param1
        media play leg_incoming  %c1 _no_lang_sel.au %s1000 %c1 _lang_sel1.au %s1000 %c2 _lang_sel2.au
        
        fsm setstate same_state
        } else {
        media play leg_incoming %c1 _generic_final.au
        fsm setstate CALLDISCONNECT
        }
    }        
    
    
}

proc act_GetCard { } {

    global cardLen
    global accountLen
    global pinLen
    global count
    global param1
    global promptFlag

    set cardLen [expr $accountLen + $pinLen]

    set param1(maxDigits)  $cardLen

    leg collectdigits leg_incoming param1
    if {$count == 0} {
    media play leg_incoming _enter_card_num.au
    } else {
    if {$promptFlag == 1 } {
        media play leg_incoming  _invalid_digits.au
    }
    if {$promptFlag == 2 } {
        media play leg_incoming _auth_fail.au
    }
    if {$promptFlag == 3} {
        media play leg_incoming _no_card_entered.au
    }
    }

}

proc act_GotCardNumber { } {
    global count
    global retryCnt
    global promptFlag
    global account
    global pin
    global accountLen
    global cardLen
    global pinLen
    global ani

    set status [infotag get evt_status]

    # Do we need to calculate len ???
    if {$status == "cd_005"} {
    set number [infotag get evt_dcdigits]
    set numberLen [ string length $number ]
    if { $numberLen == $cardLen } {
            set account [ string range $number 0 [expr $accountLen -1]]
            set pin [ string range $number $accountLen [expr $cardLen -1]]
        
        #Do authorize
        aaa authorize $account $pin  $ani "" leg_incoming
        } else {
            incr count
            set promptFlag 1
            if {$count < $retryCnt} {
        act_GetCard
        fsm setstate same_state
            } else {
        media play leg_incoming _final.au
        fsm setstate CALLDISCONNECT
        }
        }
    return
    }
    
    #timeout
    if {$status == "cd_001"} {
    set number [infotag get evt_dcdigits]
    puts "\nNUMBER=$number"
    set numberLen [ string length $number ]
    if { $numberLen == 0 } {
        incr count
        set promptFlag 3
        if {$count < $retryCnt} {
        act_GetCard
        fsm setstate same_state
        } else {
        media play leg_incoming  _final.au
        fsm setstate CALLDISCONNECT
        
        }
        return
    }
    if { $numberLen == $cardLen } {
            set account [ string range $number 0 [expr $accountLen -1]]
            set pin [ string range $number $accountLen [expr $cardLen -1]]
        
        #Do authorize
        aaa authorize $account $pin  $ani "" leg_incoming
        } else {
            incr count
            set promptFlag 1
            if {$count < $retryCnt} {
        act_GetCard
        fsm setstate same_state
            } else {
        media play leg_incoming _final.au
        fsm setstate CALLDISCONNECT
        }
        }
    return
    }
    
    #Aborted
    if {$status == "cd_002"} {
    act_GetCard
    fsm setstate same_state
    return
    }
    
    #timeout/fail(disconnected)/invalid_no
    #shd we play a diff prompt for disconnected...what is disconnected???
    if {($status == "cd_001") ||
    ($status == "cd_007") ||
    ($status == "cd_006")} {
    incr count
        set promptFlag 3
        if {$count < $retryCnt} {
        act_GetCard
        fsm setstate same_state
        } else {
        media play leg_incoming  _final.au
        fsm setstate CALLDISCONNECT
        
    }
    return
    }
}


proc act_FirstAuthorized { } {

    global count
    global retryCnt
    global promptFlag


    set status [infotag get evt_status]

    
    puts "\n aaa authorize Status=$status"
    if { $status == "ao_000" } {
    act_GetDest
    return
    } else {
    if { [infotag get aaa_avpair_exists h323-return-code] } {
        set returnCode [infotag get aaa_avpair h323-return-code]
    } else {
        #No return code from radius
            media play leg_incoming _no_aaa.au
        fsm setstate CALLDISCONNECT
            return
    }

    incr count
        set promptFlag 2
        if { $count < $retryCnt } {
        act_GetCard
        fsm setstate CARDSELECTION
        } else {
        #First authorize failed
        act_firstAuthorizeFailed $returnCode
        fsm setstate CALLDISCONNECT
        }
        return 0
    
    }
    fsm setstate CALLDISCONNECT
}


proc act_firstAuthorizeFailed { returnCode } {
    
    #play prompt accordind to failure vsa code ??? get returnCode
    media play leg_incoming _final.au
}

proc act_secondAuthorizeFailed { returnCode } {
    
    #play prompt accordind to failure vsa code ??? get returnCode
    media play leg_incoming _final.au
}

proc act_GetDest { } {
    global destination
    global fcnt
    global promptFlag2
    global destBusy
    global param2

    if { [infotag get aaa_avpair_exists h323-credit-amount] } {
    set amt [infotag get aaa_avpair h323-credit-amount]
    } else {
    media play leg_incoming _no_aaa.au
    fsm setstate CALLDISCONNECT
    return
    }

    set param2(ignoreInitialTermKey) true
    leg collectdigits leg_incoming param2
    if {$fcnt == 0} {
        if {$amt == 0} {
            media play leg_incoming _zero_bal.au
        fsm setstate CALLDISCONNECT
        } elseif {$amt > 999999.99} {
           media play leg_incoming _invalid_amt.au _dollars.au %s1000 _enter_dest.au
        } elseif {$destBusy == 1} {
         set destBusy 0
            media play leg_incoming _dest_busy.au
        } else {
        media play leg_incoming _you_have.au %a$amt %s1000 _enter_dest.au
        }
    } else {
        if {$promptFlag2 == 1} {
            media play leg_incoming _reenter_dest.au
        }
        if {$promptFlag2 == 2} {
            media play leg_incoming _author_fail.au
        }
        if {$promptFlag2 == 3} {
            media play leg_incoming _no_dest_entered.au
        }
    }
    
}


proc act_GotDest { } {
    global fcnt
    global retryCnt
    global promptFlag2
    global destination
    global ani
    global account
    global pin
    global dontPlayAmount

    set status [infotag get evt_status]

    #matched dialplan
    if {$status == "cd_004"} {
    set destination [infotag get evt_dcdigits]
    aaa authorize $account $pin  $ani $destination leg_incoming
    return
    }

    #aborted
    if {$status == "cd_002"} {
    if {$dontPlayAmount == 1} {
        act_Just_GetDest
    } else {
        act_GetDest
    }
    fsm setstate same_state
    return
    }


    incr fcnt
    if {$fcnt < $retryCnt} {
    #timeout
    #shd we play a diff prompt for disconnected...what is disconnected???
    if {$status == "cd_001" } {
        set promptFlag2 1
    }
    #fail(disconnected)
    if {$status == "cd_007" } {
        set promptFlag2 3
    }    
    #for all other cases like cd_006(invalid no)
    set promptFlag2 1
    if {$dontPlayAmount == 1} {
        act_Just_GetDest
    } else {
        act_GetDest
    }
    fsm setstate same_state
    } else {
    media play leg_incoming _dest_collect_fail.au
    fsm setstate CALLDISCONNECT
    }
    
    
}

proc act_SecondAuthorized { } {

    global account
    global destination
    global noTimeLimit
    global creditTime
    global warnTime
    global promptFlag2
    global fcnt
    global retryCnt
    global noPlay
    
    set callInfo(accountNum) $account

    if { [infotag get aaa_avpair_exists h323-return-code] } {
    set returnCode [infotag get aaa_avpair h323-return-code]
    } else {
    #No return code from radius
    media play leg_incoming _no_aaa.au
    fsm setstate CALLDISCONNECT
    return
    }
    
     if {$returnCode == 13} {
     # allow user to make toll-free calls
     set noTimeLimit 1
     leg setup $destination callInfo leg_incoming
     return
     }
     #this is same as above ???
     if {$returnCode == 52} {
     # Redirect to customer service using redirect number
     set noTimeLimit 1
     leg setup $destination callInfo leg_incoming
     return
     }

    set status [infotag get evt_status]
    puts "\n aaa authorize Status=$status"

    if { $status == "ao_000" } {
    if { [infotag get aaa_avpair_exists h323-credit-time] } {
        set creditTime [infotag get aaa_avpair h323-credit-time]
    } else {
        media play leg_incoming _no_aaa.au
        fsm setstate CALLDISCONNECT
        return
    }

    if {$creditTime == "uninitialized"} {
            media play leg_incoming _no_aaa.au
        fsm setstate CALLDISCONNECT
        return
        } elseif {$creditTime == "unlimited"} {
        set noTimeLimit 1
        # play mesg only if time left is  20 secs > warntime
        } elseif {[expr $creditTime - $warnTime] < 20} {
        set noPlay 1
        media play leg_incoming _you_have.au %t$creditTime
        } else {
        media play leg_incoming _you_have.au %t$creditTime
        }

    } else {
    #Authorization failed
    act_PlayReturnCode $returnCode
    if { $returnCode == 4 } {
        #special Case ???...no retry check also
        set noTimeLimit 1
        return
    } else {
        fsm setstate CALLDISCONNECT
        return
    }

    incr fcnt
        set promptFlag2 2
    if { $fcnt < $retryCnt } {
            act_GetDest
        fsm setstate GETDEST
        
        } else {
            #second authorize failed
        act_secondAuthorizeFailed $returnCode
        fsm setstate CALLDISCONNECT
        
        }
    fsm setstate CALLDISCONNECT
    }
    
    
}

proc act_PlayReturnCode {returnCode} {

    switch $returnCode {
    3  { media play leg_incoming _account_blocked.au }
    4  { media play leg_incoming  _zero_bal.au }
    5  { media play leg_incoming _card_expired.au }
        7  { media play leg_incoming _blocked.au }
        9  { media play leg_incoming _dest_blocked.au }
        12 { media play leg_incoming _not_enuf.au }
    default { media play leg_incoming _no_aaa.au }
    }
    
}

proc act_CallSetup { } {
    global destination
    global account

    set callInfo(accountNum) $account
    leg setup $destination callInfo leg_incoming

}

proc act_CallSetupDone { } {
    global warnTime
    global creditTime
    global noPlay
    global noTimeLimit
    global param3

    set status [infotag get evt_status]

    set param3(interruptPrompt) true
    set param3(enableReporting) true

    
    if {$status == "ls_000"} {
    
    if { ($noTimeLimit == 1) ||
         ($creditTime == "unlimited") ||
         ($creditTime == "uninitialized") } {
        #no timer
    } else {
        if {$creditTime < $warnTime} {
        if {$noPlay == 1} {
            timer start leg_timer  [expr $creditTime -1] leg_incoming
        } else {
            timer start leg_timer [expr $warnTime - 4] leg_incoming
        }
        fsm setstate CALLLASTACTIVE

        } else {
        set delay [expr $creditTime - $warnTime]
        timer start leg_timer $delay leg_incoming
        fsm setstate CALLACTIVE
        }
    }
    #for longpound
    leg collectdigits leg_incoming param3
        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")
     } {
    act_DestBusy
    return
    }
    # leg setupFail
    set tone [infotag get evt_status]
    playtone leg_incoming $tone
    timer start leg_timer 5  leg_incoming
    fsm setstate CALLDISCONNECT
    
}
proc act_HandleOutgoing { } {
    global outgoingDisconnect

    if { [infotag get evt_legs] == [infotag get leg_outgoing] } {
    puts "\nOutgoing Disconnected"
    connection destroy con_all
    set outgoingDisconnect 1
    return
    }
    call close
    fsm setstate CALLDISCONNECT

}


proc act_LongPound { } {
    global duration

    if { [infotag get evt_digit] != "#" } {
    fsm setstate same_state
    return
    }

    set duration [infotag get evt_digit_duration]
    if { $duration < 300 } {
    fsm setstate same_state
    return
    }


    connection destroy con_all
    
}
proc act_Just_GetDest { } {
    global destination
    global fcnt
    global promptFlag2
    global pound
    global destBusy
    global param2
    global outgoingDisconnect

    set param2(ignoreInitialTermKey) true
    leg collectdigits leg_incoming param2
    if {$fcnt == 0} {
    if {$outgoingDisconnect == 1} {
        set outgoingDisconnect 0
        media play leg_incoming _disconnect.au %s1000 _enter_dest.au
    } elseif {$destBusy == 1} {
        set destBusy 0
        media play leg_incoming _dest_busy.au
    } else {
        media play leg_incoming _enter_dest.au
    }
    } else {
        if {$promptFlag2 == 1} {
            media play leg_incoming _reenter_dest.au
        }
        if {$promptFlag2 == 2} {
            media play leg_incoming _author_fail.au
        }
        if {$promptFlag2 == 3} {
            media play leg_incoming _no_dest_entered.au
        }
    }
}


proc act_ConnDestroyed { } {
    global dontPlayAmount


    leg disconnect leg_outgoing
    init_perCallVars
    set dontPlayAmount 1
    act_Just_GetDest
    
}

proc act_DestBusy { } {
    global destBusy
    
    #current debitcard implementation
    set destBusy 1
    act_Just_GetDest
    fsm setstate GETDEST

}

proc act_ActiveTimer { } {
    global noPlay
    global warnTime
    global creditTime
    global incoming
    global outgoing

    set incoming [infotag get leg_incoming]
    set outgoing [infotag get leg_outgoing]

    if {$noPlay == 1} {
    timer start leg_timer  [expr $creditTime -1] leg_incoming
    } else {
        connection destroy con_all
    timer start leg_timer [expr $warnTime - 4] leg_incoming
        fsm setstate CALLWARN
    }
    
}

proc act_CallWarnDestroy { } {
    global warnTime
    media play leg_incoming _you_have.au %t$warnTime
}

proc act_CallWarnMedia { } {
    global incoming
    global outgoing

    connection create $incoming $outgoing  
}

proc act_LastActiveTimer { } {
    connection destroy con_all
    media play leg_incoming _disconnect.au
}

proc act_Ignore { } {
# Dummy
    puts "Event Capture"
}

proc act_Cleanup { } {
    call close
}

requiredversion 2.0
init

#Get Variables
init_ConfigVars

#----------------------------------
#   State Machine
#----------------------------------
  set fsm(any_state,ev_disconnected)   "act_Cleanup  same_state"
  
  set fsm(CALL_INIT,ev_setup_indication) "act_Setup  LANGSELECTION"

  set fsm(ONELANG,ev_media_done) "act_GetCard  CARDSELECTION"

  set fsm(LANGSELECTION,ev_collectdigits_done) "act_LangSelect CARDSELECTION"

  set fsm(CARDSELECTION,ev_collectdigits_done) "act_GotCardNumber  AUTHORIZE"
  
  set fsm(AUTHORIZE,ev_authorize_done)  "act_FirstAuthorized    GETDEST"

  set fsm(GETDEST,ev_collectdigits_done) "act_GotDest SECONDAUTHORIZE"

  set fsm(SECONDAUTHORIZE,ev_authorize_done) "act_SecondAuthorized PLACECALL"

  set fsm(PLACECALL,ev_media_done)   "act_CallSetup PLACECALL"
  set fsm(PLACECALL,ev_setup_done)   "act_CallSetupDone  CALLACTIVE"

  set fsm(CALLACTIVE,ev_leg_timer)    "act_ActiveTimer CALLLASTACTIVE"
  set fsm(CALLLASTACTIVE,ev_leg_timer) "act_LastActiveTimer CALLDISCONNECT"
  set fsm(CALLACTIVE,ev_digit_end)     "act_LongPound       CONNDESTROY"
  set fsm(CALLLASTACTIVE,ev_digit_end) "act_LongPound       CONNDESTROY"

  set fsm(CALLWARN,ev_destroy_done)    "act_CallWarnDestroy same_state"
  set fsm(CALLWARN,ev_media_done)      "act_CallWarnMedia   CALLLASTACTIVE"

  set fsm(CONNDESTROY,ev_destroy_done) "act_ConnDestroyed GETDEST"

  set fsm(CALLACTIVE,ev_disconnected)   "act_HandleOutgoing  CONNDESTROY"
  set fsm(CALLDISCONNECT,ev_media_done) "act_Cleanup         same_state"
  set fsm(CALLDISCONNECT,ev_disconnect_done)  "act_Cleanup   same_state"
  set fsm(CALLDISCONNECT,ev_leg_timer)        "act_Cleanup   same_state"
  
  fsm define fsm CALL_INIT

 

Ваше сообщение
Имя*:
EMail:
Для отправки новых сообщений в текущей нити на email укажите знак ! перед адресом, например, !user@host.ru (!! - не показывать email).
Более тонкая настройка отправки ответов производится в профиле зарегистрированного участника форума.
Заголовок*:
Сообщение*:
  Введите код, изображенный на картинке: КОД
 
При общении не допускается: неуважительное отношение к собеседнику, хамство, унизительное обращение, ненормативная лексика, переход на личности, агрессивное поведение, обесценивание собеседника, провоцирование флейма голословными и заведомо ложными заявлениями. Не отвечайте на сообщения, явно нарушающие правила - удаляются не только сами нарушения, но и все ответы на них. Лог модерирования.



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру