Forwarding the call via R2/ISDN channel

Version 1
    This document was generated from CDN thread

    Created by: Jean Lofrano on 10-08-2012 09:28:57 AM
    Hi team!!!
     
    I have a solution working properly. But I have a problem of the sizing.
    The script has the flow:
    Incoming call > third part PBX >> ISDN/R2 integration >> Router with TCL script.
    The user can to hear the welcome prompt, but when the user choose the option to forward the call for HelpDesk the integration will busy 2 channels.
    It can be a problem for me, because the environemnt has in around 1500 people.
    Is there any feature for the router leave the call after a transfer?
    thanks.
     
     
     
    proc CallHelpDesk { } {
    global CallerID
    puts "Fowarding to Help Desk"
    set callinfo(originationNum) $CallerID
    set callinfo(alertTime) 10
    set destination 79889

    puts "FAZENDO CHAMADA"
    leg setup $destination callinfo leg_outgoing
    #fsm setstate CALLEDHELPDESK
    }
     
    proc CheckCallSetup { } {
    puts "IT7 ------------ chamada realizada"
    set statuscall [infotag get evt_status]
    switch $statuscall {
    "ls_000" {
    puts "CHAMADA ATIVA"
    set incoming [infotag get leg_incoming]
    puts "Parte 2"
    set outgoing [infotag get leg_outgoing]
    connection create $incoming $outgoing
    }
    defaul {
    puts "CHAMADA FALHOU"
    }
    }
    puts "CHECK CALL SETUP ACABOU"
    }

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Raghavendra Gutty Veeranagappa on 10-08-2012 09:50:04 AM
    Hi Jean,

    could you please share your complete script so that it will be  easy for us to analayse the issue.

    Thanks,
    Raghavendra

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Jean Lofrano on 13-08-2012 09:10:38 AM
    #Params
    #
    # web-server
    #    IP Address or DNS Name of webserver
    # welcome-prompt
    #    path+filename of welcome message
    # attemps
    #    number of times to repeat the imput

    # web returns
    # return: 1 = valid
    #         0 = invalid/wrong
    #    CALL_CENTER = Special account
    #         x >=2



    # initialize the parameters that configured from IOS CLI
    proc InitializeConfiguration { }  {
        puts "IT7: initializing Homologação"
        global WebServer
        global WelcomePrompt
        global Attemps
        global CallerID
        global NovaSenha
        global WebReturn1
        global count
        global count1
        global counter

        #other variables
        global Response1
        global Response2
        global Response3

        #webserver
        if [infotag get cfg_avpair_exists web-server] {
           set WebServer [string trim [infotag get cfg_avpair web-server]]
        } else {
           set WebServer "10.80.3.91:7778"
        }



        #welcome message
        if [infotag get cfg_avpair_exists welcome-prompt] {
           set WelcomePrompt [string trim [infotag get cfg_avpair welwome-prompt]]
        } else {
         
           set WelcomePrompt "flash:/Fem/ola2.wav"
       

        }

        #attemps   
        if [infotag get cfg_avpair_exists attemps] {
           set Attemps [string trim [infotag get cfg_avpair attemps]]
        } else {
           set Attemps 3
        }

       
        puts "IT7: initialized"
    }


    proc ActionCallPrepare { } {

        puts "AGUARDANDO INICIO"
        timer start call_timer0 2
    }

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

    proc CallHelpDesk { } {
           global CallerID

           puts "Fowarding to Help Desk"

           set callinfo(originationNum) $CallerID
           set callinfo(alertTime) 10
           set destination 79889


           puts "FAZENDO CHAMADA"
           leg setup $destination callinfo leg_outgoing

           #fsm setstate CALLEDHELPDESK
    }


    proc CheckCallSetup { } {

         puts "IT7 ------------ chamada realizada"

         set statuscall [infotag get evt_status]
         switch $statuscall {

                            "ls_000" {

                                     puts "CHAMADA ATIVA"

                                     set incoming [infotag get leg_incoming]
                                     puts "Parte 2"
                                     set outgoing [infotag get leg_outgoing]

                                     connection create $incoming $outgoing

                                     }

                             defaul {
                                    puts "CHAMADA FALHOU"
                                    }
                            }

          puts "CHECK CALL SETUP ACABOU"

    }


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



    #procedure to play audio file on incoming dial peer
    proc ActionPlayWelcome { } {
        puts "IT7: playing audio Welcome"

        global WelcomePrompt
        global CallerID

        leg setupack leg_incoming
        leg proceeding leg_incoming
        leg connect leg_incoming

        set CallerID [infotag get leg_ani]

        puts "IT7: Caller ID $CallerID"

        media play leg_incoming $WelcomePrompt

        puts "IT7: Audio played Welcome"
    }

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

    #procedure to play Question 1
    proc ActionPlayQuestion1 { } {
       
        global counter

        set counter 0

       set Question1Param(interruptPrompt) true
       set Question1Param(terminationKey) #
       set Question1Param(enableReporting) true
       set Question1Param(maxDigits) 1
       set Question1Param(dialPlan) true
       set Question1Pattern(1) "1"
       set Question1Pattern(2) "2"
       set Question1Pattern(3) "3"
       
        puts "IT7: playing question 1"

        media play leg_incoming "flash:/Fem/opcoes.wav"

        puts "IT7: played question 1"

        leg collectdigits leg_incoming Question1Param Question1Pattern

        fsm setstate COLLECTEDQUESTION1

    }

    proc ActionPlayQuestion1Again { } {
       
        global counter

        if { $counter < "2"} {

        incr counter

        puts "$counter"

        puts "IT7: playing question 1 again"

        media play leg_incoming "flash:/Fem/opcoes.wav"

        puts "IT7: played question 1 again"
        } else {

              

               puts "IT7 --------------------------> ERRO"
     
               media play leg_incoming "flash:/Fem/aguarde.wav"

               puts "Por favor aguarde enqto sua ligacao e transf para help"
      
               fsm setstate HELPDESK

               }


    }  


    #coleta os digitos da questao 01
    proc ActionCollectQuestion1 { } {
        puts "IT7: collecting question 1"

        set Question1Param(interruptPrompt) true
        set Question1Param(terminationKey) #
        set Question1Param(enableReporting) true
        set Question1Param(maxDigits) 1
        set Question1Param(dialPlan) true
        set Question1Pattern(1) "1"
        set Question1Pattern(2) "2"
        set Question1Pattern(3) "3"

        leg collectdigits leg_incoming Question1Param

        puts "IT7: collected question 1"
    }

    #send collected digits through web
    proc Action1 { } {
        puts "IT7: try to send web"
        global WebServer
        global Response1
        global CallerID
        global count
        global count1

        set StatusCollectDigits [infotag get evt_status]

        puts "IT7: cpf $StatusCollectDigits"

        #matched pattern
        if {$StatusCollectDigits == "cd_005"} {

           puts "IT7: starting web"

           set Response1 [infotag get evt_dcdigits]
          

           puts "Choose: $Response1"

           if { $Response1 == "3"} {

           puts "aguarde, transferindo para o help-desk"

           media play leg_incoming "flash:/Fem/aguarde.wav"

           fsm setstate HELPDESK
          
           }
          
          if { $Response1 == "2"} {

          puts "password change"
          
           set count 0

           set count1 0
               
           media play leg_incoming "flash:/Fem/alteracao-cpf.wav"

           fsm setstate PLAYEDQUESTION2

           }


          if { $Response1 == "1"} {

          puts "user unlock"
         
          set count 0

          set count1 0
         
          media play leg_incoming "flash:/Fem/desbloqueio-cpf.wav"

          fsm setstate PLAYEDQUESTION2

         }


         if { $Response1 > "3"}  {

       

         puts "Invalid option"

         media play leg_incoming "flash:/Fem/opcao-invalida.wav"
         fsm setstate PLAYEDWRONG1


         }
      
         


        } else {

        puts "IT7: error - playing error audio"

        media play leg_incoming "flash:/Fem/opcao-invalida.wav"
        fsm setstate PLAYEDWRONG1

        puts "IT7: error - played error audio"

        }
        puts "IT7: end try to send web"
    }

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


    #play question 2, second time
    proc ActionPlayQuestion2Again { } {
       
        global count
        global Response1
       
        if { $count < "2"} {

        incr count

        puts "$count"


        puts "IT7: playing question 2 again"

        media play leg_incoming "flash:/Fem/solicita-cpf.wav"

        puts "IT7: played question 2 again"

        } else {

               puts "IT7 --------------------------> ERRO"
     
                if { $Response1 == "1"}  {

                puts "IT7 --------------------------> ERRO 1"      

               media play leg_incoming "flash:/Fem/desbloqueio-erro.wav"

               fsm setstate HELPDESK

               puts "Por favor aguarde enqto sua ligacao e transf para help" 

               }


               if { $Response1 == "2"} {

                puts "IT7 --------------------------> ERRO 2"

               media play leg_incoming "flash:/Fem/alteracao-erro.wav"

               fsm setstat HELPDESK

               puts "Por favor aguarde enqto sua ligacao e transf para help"

               }

               

               }


    }  


    #coleta os digitos da questao 02
    proc ActionCollectQuestion2 { } {
        puts "IT7: collect question 2"

        set Question2Param(interruptPrompt) true
        set Question2Param(terminationKey) #
        set Question2Param(maxDigits) 11
        set Question2Param(dialPlan) true
        set Question2Pattern(1) "..........."
      

        leg collectdigits leg_incoming Question2Param

        puts "IT7: collected question 2"
    }


    proc Action2 { } {
        global WebServer
        global Response2
        global CallerID
        global count

      

        set StatusCollectDigits [infotag get evt_status]

        #matched pattern
        if {$StatusCollectDigits == "cd_005"} {

           set Response2 [infotag get evt_dcdigits]
         
      set URL http://$WebServer/URA/ValidarCPF?telefoneorigem=$CallerID&cpf=$Response2
       


        puts "IT7: URL Validacao #2 $URL"

           ::httpios::geturl $URL -command httpCallback2

        } else {

        media play leg_incoming "flash:/Fem/cpf-invalido.wav"
        fsm setstate PLAYEDWRONG2
        }
    }


    proc httpCallback2 { token } {

        global WebServer
        global Response1
        global WebReturn1
        global CallerID
        

       if {[::httpios::status $token] == "ok"} {
          set WebReturn1 [string trim [::httpios::data $token]]
       }

       if { $WebReturn1 >= "2" } {

          puts "Abril validating the UserKey $WebReturn1"

           if { $Response1 == "1"} {

                    set URL http://$WebServer/URA/DesbloquearConta?telefoneorigem=$CallerID&user_key=$WebReturn1
                   
                   ::httpios::geturl $URL -command httpCallbackSMS
                   
                   


                     }



                    if { $Response1 == "2"} {
         
                    media play leg_incoming "flash:/Fem/solicita-telefone.wav"
         
                    fsm setstate PLAYEDQUESTION3

                    }
         
        


       }


      if { $WebReturn1 == "CALL_CENTER" } {

       puts "aguarde, transferindo para o help-desk"

              media play leg_incoming "flash:/Fem/aguarde.wav"

              fsm setstate HELPDESK
      
      }
     
      if { $WebReturn1 == "0" } {

                      media play leg_incoming "flash:/Fem/cpf-invalido.wav"
                      fsm setstate PLAYEDWRONG2

      
       }
    }




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

    #diz a questao 3 denovo
    proc ActionPlayQuestion3Again { } {

        global count1
        global Response1

        if { $count1 < "2"} {

        incr count1

        puts "$count1"  

        puts "IT7: playing question 3 again"

        media play leg_incoming "flash:/Fem/solicita-telefone.wav"

        puts "IT7: played question 3 again"
        } else {

                puts "IT7 --------------------------> ERRO"
     
                if { $Response1 == "1"}  {

                puts "IT7 --------------------------> ERRO 1"      

               media play leg_incoming "flash:/Fem/desbloqueio-erro.wav"

               puts "Por favor aguarde enqto sua ligacao e transf para help" 

               fsm setstate HELPDESK

               }


               if { $Response1 == "2"} {

                puts "IT7 --------------------------> ERRO 2"

               media play leg_incoming "flash:/Fem/alteracao-erro.wav"

               puts "Por favor aguarde enqto sua ligacao e transf para help"

               fsm setstate HELPDESK

               }


               }

    }  


    #coleta os digitos da questao 03
    proc ActionCollectQuestion3 { } {

        set Question2Param(interruptPrompt) true
        set Question2Param(terminationKey) #
        set Question2Param(maxDigits) 10
        set Question2Param(dialPlan) true
        set Question2Pattern(1) ".........."

        leg collectdigits leg_incoming Question2Param
    }


    #Action 03 of second Question
    proc Action3 { } {
        global WebServer
        global Response1
        global Response2
        global Response3
        global WebReturn1
        global CallerID

        set StatusCollectDigits [infotag get evt_status]

        #matched pattern
        if {$StatusCollectDigits == "cd_005"} {

           set Response3 [infotag get evt_dcdigits]

           set URL http://$WebServer/URA/ValidarTelefone?telefoneorigem=$CallerID&user_key=$WebReturn1&telefone=$Response3

      
       
        puts "IT7: URL Validacao #3 $URL"

           ::httpios::geturl $URL -command httpCallback3

        } else {

        media play leg_incoming "flash:/Fem/telefone-invalido.wav"
        fsm setstate PLAYEDWRONG3


        }

    }

    proc httpCallback3 { token } {
        global WebServer
        global Response1
        global Response2
        global Response3
        global WebReturn1
        global CallerID
        global Choose


       if {[::httpios::status $token] == "ok"} {
          set WebReturn [string trim [::httpios::data $token]]
       } else {
          set WebReturn 0
       }

       if { $WebReturn != "0" } {

          puts "IT7--------------------------------> OK FINAL !"



          if { $Response1 == "1"} { 

          puts "password unlocking"  

          set URL http://$WebServer/URA/DesbloquearConta?telefoneorigem=$CallerID&user_key=$WebReturn1

          puts "IT7: URL Unlock $URL"

          ::httpios::geturl $URL -command httpCallbackSMS
          }



          if { $Response1 == "2"} {

          puts "password changing"
         
          set URL http://$WebServer/URA/AlterarSenha?telefoneorigem=$CallerID&user_key=$WebReturn1

          puts "IT7: URL Reset $URL"

          ::httpios::geturl $URL -command httpCallbackSMS

          }


      } else {
         
          if { $Response1 == "1"} {

          media play leg_incoming "flash:/Fem/telefone-invalido.wav"
          fsm setstate PLAYEDWRONG3
         
          } else {

                  media play leg_incoming "flash:/Fem/telefone-invalido.wav"
                  fsm setstate PLAYEDWRONG3     
                 
                  }

       }
    }



    #------------------------------------------------------------------------------
    #proc httpCallbackReset { token } {
    # global WebServer
    # global CallerID
    # global Response1

    #   if {[::httpios::status $token] == "ok"} {
    #     set Password [string trim [::httpios::data $token]]
    # } else {
    #   set Password 0
    # }

    # if { $Password == "1" } {
    #  puts "IT7 ---> SENHA GERADA: $Password"
     
    #  set URL http://$WebServer/URA/MandarSMS?telefoneorigem=$CallerID&cpf=$Response1&password=$WebReturn
     
    #  puts "IT7: URL Enviar SMS $URL"
     
    #  ::httpios::geturl $URL -command httpCallbackSMS
     
     
    # } else {
      
    #  puts "IT7 -------------------------> SENHA NAO FOI GERADA !"
     
    #  media play leg_incoming "flash:/informacaoincorreta.wav"  
    #  fsm setstat CALLDISCONNECT
    # }
    #}


    proc httpCallbackSMS { token } {

            global Response1
        


    if {[::httpios::status $token] == "ok"} {
          set feedback [string trim [::httpios::data $token]]
       } else {
       set feedback 0
    }

    puts "IT7 ---> Retorno final: $feedback"

    if { $feedback == "1"} {
      puts "THE END"


                    if { $Response1 == "1"} {
                   
      media play leg_incoming "flash:/Fem/desbloqueio-ok.wav"
      fsm setstate CALLDISCONNECT

                    } else {

                           media play leg_incoming "flash:/Fem/alteracao-ok-2.wav"
             fsm setstate CALLDISCONNECT

                           }


       } else {
     
                    if { $Response1 == "1"} {

                    puts "IT7 --------------------------> ERRO ENVIANDO MENSAGEM"
      media play leg_incoming "flash:/Fem/desbloqueio-erro.wav"

                    } else {

                           puts "IT7 --------------------------> ERRO ENVIANDO MENSAGEM"
             media play leg_incoming "flash:/Fem/alteracao-erro.wav" 
                            }

                      

       }
        
    }

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






    # disconnect the call
    proc ActionDisconnect { } {
        puts "IT7: Call Disconnected"
        call close
    }



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



    InitializeConfiguration

    set ScriptFSM(any_state,ev_disconnected)                "ActionDisconnect         same_state"

    set ScriptFSM(CALL_INIT,ev_setup_indication)            "ActionCallPrepare        PREPARED"
    set ScriptFSM(PREPARED,ev_call_timer0)                  "ActionPlayWelcome        PLAYEDWELCOME"

    set ScriptFSM(PLAYEDWELCOME,ev_media_done)              "ActionPlayQuestion1      PLAYEDQUESTION1"
    set ScriptFSM(PLAYEDWRONG1,ev_media_done)               "ActionPlayQuestion1Again PLAYEDQUESTION1"

    set ScriptFSM(COLLECTEDQUESTION1,ev_collectdigits_done) "Action1                  CALLDISCONNECT"

    set ScriptFSM(HELPDESK,ev_media_done)                   "CallHelpDesk             CALLEDHELPDESK"
    set ScriptFSM(CALLEDHELPDESK,ev_setup_done)             "CheckCallSetup           ESTABLISHEDCALL"

    set ScriptFSM(PLAYEDWRONG2,ev_media_done)               "ActionPlayQuestion2Again PLAYEDQUESTION2"
    set ScriptFSM(PLAYEDQUESTION2,ev_media_done)            "ActionCollectQuestion2   COLLECTEDQUESTION2"
    set ScriptFSM(COLLECTEDQUESTION2,ev_collectdigits_done) "Action2                  CALLDISCONNECT"

    set ScriptFSM(PLAYEDWRONG3,ev_media_done)               "ActionPlayQuestion3Again PLAYEDQUESTION3"
    set ScriptFSM(PLAYEDQUESTION3,ev_media_done)            "ActionCollectQuestion3   COLLECTEDQUESTION3"
    set ScriptFSM(COLLECTEDQUESTION3,ev_collectdigits_done) "Action3                  CALLDISCONNECT"


    set ScriptFSM(CALLDISCONNECT,ev_disconnected)    "ActionDisconnect    same_state"
    set ScriptFSM(CALLDISCONNECT,ev_media_done)      "ActionDisconnect    same_state"
    set ScriptFSM(CALLDISCONNECT,ev_disconnect_done) "ActionDisconnect    same_state"

    fsm define ScriptFSM CALL_INIT

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Jean Lofrano on 13-08-2012 09:12:24 AM
    Hi Raghavendra,

    I posted the full script bellow.

    Can you give me a idea?

    Thanks.

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Raghavendra Gutty Veeranagappa on 14-08-2012 02:00:32 AM
    Hi Jean,

    Thanks for sharing the script, there is a feature called TBCT, Two B-Channel Transfer (TBCT) is a call-transfer standard for ISDN interfaces. This feature enables a Cisco voice gateway to request an NI-2 switch to directly connect two independent calls. The two calls can be served by the same PRI or by two different PRIs on the gateway. This feature is based on Telcordia GR-2865-CORE

    For more information you can refer below link.
    http://www.cisco.com/en/US/docs/ios/voice/ivr/configuration/guide/ivr_tbct.html

    Thanks,
    Raghavendra

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Jean Lofrano on 04-09-2012 04:00:15 PM
    Hi,

    I saw the document today and I have met the follow:

    Restrictions

    •TBCT supports the National ISDN-2 (NI-2) standard for T1 only. E1 interfaces are not supported.


    And unfortunately, I ´m working with E1 interface.

    Too bad.

    Is there another path for us?

    Thank you!

    Subject: RE: Forwarding the call via R2/ISDN channel
    Replied by: Raghavendra Gutty Veeranagappa on 05-09-2012 02:03:14 AM
    Hi Jean,

    TBCT is for T1 interface where as European Telecommunications Standards Institute (ETSI) explicit call transfer(ECT) for E1 interface.

    For ETSI Call Transfer, the switch type should be primary-net5. you can refer below link for ETSI.

    http://www.cisco.com/en/US/docs/ios/voice/ivr/configuration/guide/ivr_tbct.html#wp1014035

    Thanks,
    Raghavendra