Call Redirecting Problem

System Informations:
-Asterisk 16.10

Created Scenario:

  1. A-agent run [RCOUT_MANUEL_A] (DIAL,1) dialplan by originate.
  2. same => n,Dial(PJSIP/${OPEXTEN},15,tTg) calls A-agent.
  3. A-agent answers the call by automatic. And [RCOUT_MANUEL_A] (ANSWERED,1) has been executed.
  4. The Number determined by A-agent at the [RCOUT_MANUEL_A] (ANSWERED,1) is called.
  5. A-agent redirects the call to Dialplan [ar_aktar] (s,1) by using AMI Redirect for transfer the call to B-agent.

Problem:
After the transfer is made, the called number is connected to the B-agent. The softphone of the A-agent shuts down. However, [RCOUT_MANUEL_A] (ANSWERED, 1) does not continue to execute until B-Agent ends the call. So A-agent’s dialplan hangs until B-agent ends the call.
Please help :slight_smile:

;where the call starts

[RCOUT_MANUEL_A]
exten => DIAL,1,NoOp()
same => n,Verbose(1, RCOUT_MANUEL 1 {OPEXTEN} - {CHANNEL(linkedid)})
same => n,Set(RCUID={CHANNEL(linkedid)}) same => n,Set(RCTIP={CUT(RCUID,-,1)})
same => n,Set(RCKID={CUT(RCUID,-,2)}) same => n,Set(RCAID={CUT(RCUID,-,4)})
same => n,Dial(PJSIP/${OPEXTEN},15,tTg)
same => n,Hangup()

;when the operator opens
exten => ANSWERED,1,Answer()
same => n,Set(RCUID={CHANNEL(linkedid)}) same => n,Set(RCKID={CUT(RCUID,-,2)})
same => n,Set(RCDTID={CUT(RCUID,-,3)}) same => n,Set(RCAID={CUT(RCUID,-,4)})
same => n,Set(localchannel={CHANNEL(name)}); same => n,Verbose(1, RCOUT_MANUEL 2 - debug:{RCARAYAN:0:1}- {OPEXTEN} - {CHANNEL(linkedid)} - {CHANNEL(name)} - {STRFTIME({EPOCH},,%Y-%m-%d_%H:%M:%S)}) same => n,Set(CALLERID(num)={IF(["{RCARAYAN:0:1}" = “+”]?{RCARAYAN:1}{RAND(1000,99999)}:{RCARAYAN})}) same => n,Dial({RCCHANNEL},{RCTIMEOUT},tTgb(RCOUT_MANUEL_A^ARANDI^1({OPEXTEN}))U(RCOUT_MANUEL_A_CEVAP^{OPEXTEN})) same => n,GotoIf(["{DIALSTATUS}" = "ANSWER"]?kapat) same => n,Verbose(1, roooot codes {DIALSTATUS})
same => n,Set(GELEN={ODBC_RCOUTMANDIALEND({DIALSTATUS},{RCKID},{RCAID},{STRFTIME({EPOCH},%Y-%m-%d
%H:%M:%S)})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,Set(GELEN={ODBC_RCOUTMANDIALEND({DIALSTATUS},{RCKID},{RCAID},{STRFTIME({EPOCH},%Y-%m-%d
%H:%M:%S)})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,UserEvent(RCAramaDB,RCSP:sp_ast_rcout_manuel_DialEnd,RCKID:{RCKID},RCAID:{RCAID},RCUID:0,RCCID:0,RCEXTEN:0,RCDURUM:{DIALSTATUS},RCZID:{STRFTIME({EPOCH},,%Y-%m-%d_%H:%M:%S)}) same => n(atla),NoOp() same => n,UserEvent(RCAramaTetikle,RCTIP:{RCTIP},RCKID:${RCKID})
same => n(kapat),Hangup()

exten => ARANDI,1,Verbose(1, RCOUT_MANUEL 3 {RCCHANNEL} - {CHANNEL(linkedid)} - {CHANNEL(name)} - {CONTEXT} - {CHANNEL} - {EXTEN} - {STRREPLACE(CDR(start)," ","_")}) same => n,Set(RCUID={CHANNEL(linkedid)})
same => n,Set(RCKID={CUT(RCUID,-,2)}) same => n,Set(RCAID={CUT(RCUID,-,4)})
same => n,Set(__RCCID={CHANNEL(name)}) same => n,Set(GELEN={ODBC_RCOUTMANDIALBEGIN({RCKID},{RCAID},{ARG1},{RCUID},{RCCID},{STRREPLACE(CDR(start)," “,”_")})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,Set(GELEN={ODBC_RCOUTMANDIALBEGIN({RCKID},{RCAID},{ARG1},{RCUID},{RCCID},{STRREPLACE(CDR(start)," ","_")})=}) same => n,GotoIf(["{GELEN}" = "1"]?atla) same => n,UserEvent(RCAramaDB,RCSP:sp_ast_rcout_manuel_DialBegin,RCKID:{RCKID},RCAID:{RCAID},RCUID:{RCUID},RCCID:{RCCID},RCEXTEN:{ARG1},RCDURUM:0,RCZID:{STRREPLACE(CDR(start)," ","_")}) same => n(atla),NoOp() same => n,Set(CHANNEL(hangup_handler_push)=RCOUT_MANUEL_A,HANGUPHANDLER,1({ARG1}))
same => n,UserEvent(RCCreateChannel,RCKID:{RCKID},RCAID:{RCAID},RCDNID:{CHANNEL(accountcode)},CHANNEL:{RCCID},RCEXTEN:${ARG1})
same => n,Return()

;[hangup-handler]
exten => HANGUPHANDLER,1,Verbose(1, RCOUT_MANUEL 4 {RCCHANNEL} - {CHANNEL(linkedid)} - {CHANNEL(name)} - {CONTEXT} - {CHANNEL} - {EXTEN} - {CALLERID(num)} - {DIALSTATUS} - {HANGUPCAUSE} - {CDR(billsec,f)} - {STRFTIME({EPOCH},%Y-%m-%d_%H:%M:%S)})
same => n,Set(RCUID={CHANNEL(linkedid)}) same => n,Set(RCTIP={CUT(RCUID,-,1)})
same => n,Set(RCKID={CUT(RCUID,-,2)}) same => n,Set(RCAID={CUT(RCUID,-,4)})
same => n,Set(GELEN={ODBC_RCOUTMANHANGUP({RCAID},{HANGUPCAUSE},{STRFTIME({EPOCH},,%Y-%m-%d_%H:%M:%S)})=}) same => n,GotoIf(["{GELEN}" = "1"]?atla) same => n,Set(GELEN={ODBC_RCOUTMANHANGUP({RCAID},{HANGUPCAUSE},{STRFTIME({EPOCH},%Y-%m-%d_%H:%M:%S)})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,UserEvent(RCAramaDB,RCSP:sp_ast_rcout_manuel_Hangup,RCKID:0,RCAID:{RCAID},RCUID:0,RCCID:0,RCEXTEN:0,RCDURUM:{HANGUPCAUSE},RCZID:{STRREPLACE(CDR(start)," ","_")}) same => n(atla),NoOp() same => n,UserEvent(RCHangup,RCTIP:{RCTIP},RCKID:{RCKID},RCAID:{RCAID},RCDNID:{CHANNEL(accountcode)},SEBEP:{HANGUPCAUSE},RCEXTEN:${ARG1})
same => n,Return()

[RCOUT_MANUEL_A_CEVAP]
exten => s,1,Verbose(1, RCOUT_MANUEL 3 {RCCHANNEL} - {CHANNEL(linkedid)} - {CHANNEL(name)} - {CHANNEL} - {EXTEN} and {CALLERID(num)} - {CDR(answer,f)}) same => n,Set(RCUID={CHANNEL(linkedid)})
same => n,Set(RCKID={CUT(RCUID,-,2)}) same => n,Set(RCDTID={CUT(RCUID,-,3)})
same => n,Set(RCAID={CUT(RCUID,-,4)}) same => n,GoSub(RCAMD,s,1({RCKID},{RCAID},{RCISAMD})) ;AMD ----------
same => n,Set(RCSTATU={GOSUB_RETVAL}) same => n,Set(GELEN={ODBC_RCOUTMANDIALEND({RCSTATU},{RCKID},{RCAID},{STRREPLACE(CDR(answer)," “,”_")})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,Set(GELEN={ODBC_RCOUTMANDIALEND({RCSTATU},{RCKID},{RCAID},{STRREPLACE(CDR(answer)," ","_")})=}) same => n,GotoIf(["{GELEN}" = "1"]?atla) same => n,UserEvent(RCAramaDB,RCSP:sp_ast_rcout_manuel_DialEnd,RCKID:{RCKID},RCAID:{RCAID},RCUID:0,RCCID:0,RCEXTEN:0,RCDURUM:{RCSTATU},RCZID:{STRREPLACE(CDR(answer)," ","_")}) same => n(atla),NoOp() same => n,GotoIf(["{RCSTATU}" = "telesekreter"]?kapat) same => n,Set(RECDOSYA=/var/spool/asterisk/recording/{RCAID}-)
same => n,MixMonitor({RECDOSYA}sistem.wav,a) same => n,UserEvent(RCDialBegin_Op,RCAID:{RCAID},RCDTID:{RCDTID},RCUYE:{ARG1},RCDNID:${CHANNEL(accountcode)})
same => n,GoTo(bitir)
same => n(kapat),Hangup(16)
same => n(bitir),Return()

;where the call was transferred
[ar_aktar]
exten => s,1,NoOp(ar_aktar)
same => n,Answer()
same => n,Set(ARUID={CHANNEL(linkedid)}) same => n,Set(AREXAID={CUT(ARUID,-,4)})
same => n,Set(ARRAY(SONUC,__ARID,__ARKAMPANYAID,__ARDATAID,__ARDATANUMID,_ARKUYRUK)={ODBC_ARAKTARINFO({AREXAID},{STRFTIME({EPOCH},%Y-%m-%d%H:%M:%S)})=})
same => n,GotoIf(["{SONUC}" = “1”]?atla)
same => n,Set(ARRAY(SONUC,__ARID,__ARKAMPANYAID,__ARDATAID,__ARDATANUMID,_ARKUYRUK)={ODBC_ARAKTARINFO({AREXAID},{STRFTIME({EPOCH},%Y-%m-%d%H:%M:%S)})=})
same => n(atla),NoOp()
same => n,Set(ARCHANNEL={CHANNEL}) same => n,Verbose(1, ar 1 - {ARID}-{ARKAMPANYAID}-{ARDATAID}-{ARDATANUMID}) same => n,Set(CHANNEL(hangup_handler_push)=ar_aktar,hanguphandler,1) same => n,queue({ARKUYRUK},tn,300,ar_aktar_kuyruk_uye)
same => n(bitir),Hangup()

exten => hanguphandler,1,Verbose(1, ar_aktar 2 {ARID} - {CHANNEL(linkedid)} - {CHANNEL(name)} - {CONTEXT} - {CHANNEL} - {EXTEN} - {CALLERID(num)} - {DIALSTATUS} - {HANGUPCAUSE} - {CDR(billsec,f)} - {STRFTIME({EPOCH},%Y-%m-%d_%H:%M:%S)})
same => n,Set(GELEN={ODBC_ARAKTARHANGUP({ARID},{HANGUPCAUSE},{STRFTIME({EPOCH},,%Y-%m-%d_%H:%M:%S)})=}) same => n,GotoIf(["{GELEN}" = "1"]?atla) same => n,Set(GELEN={ODBC_ARAKTARHANGUP({ARID},{HANGUPCAUSE},{STRFTIME({EPOCH},%Y-%m-%d_%H:%M:%S)})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n(atla),NoOp()
same => n,UserEvent(RCHangup,RCTIP:g,RCKID:{ARKAMPANYAID},RCAID:{ARID},RCDNID:{ARDATANUMID},SEBEP:{HANGUPCAUSE},ARAKTAR:1)
same => n,Return()

[ar_aktar_kuyruk_uye]
exten => s,1,NoOp()
same => n,Verbose(1, ar_aktar 3 1:{ARID} - {ARDATANUMID} - {CHANNEL(name)} - {CONTEXT} - {CHANNEL} - {EXTEN})
same => n,Set(RECDOSYA=/var/spool/asterisk/recording/{ARID}-) same => n,Set(GELEN={ODBC_ARAKTARKUYRUK({ARID},{CALLERID(num)},{STRFTIME({EPOCH},%Y-%m-%d_%H:%M:%S)})=})
same => n,GotoIf(["{GELEN}" = “1”]?atla)
same => n,Set(GELEN={ODBC_ARAKTARKUYRUK({ARID},{CALLERID(num)},{STRFTIME({EPOCH},,%Y-%m-%d_%H:%M:%S)})=}) same => n,GotoIf(["{GELEN}" = "1"]?atla) same => n(atla),NoOp() same => n,UserEvent(RCCreateChannel,RCKID:{ARKAMPANYAID},RCAID:{ARID},RCDNID:{ARDATANUMID},CHANNEL:{ARCHANNEL},RCEXTEN:{CALLERID(num)})
same => n,UserEvent(RCDialBegin_Op,RCAID:{ARID},RCDTID:{ARDATAID},RCUYE:{CALLERID(num)},RCDNID:{ARDATANUMID},ARAKTAR:1)
same => n,MixMonitor(${RECDOSYA}sistem.wav,a)
same => n,Return()

;codes that transfer the call
const action = new asterAmiio.Action.Action(‘Redirect’);
action.Channel = data.Channel;
//action.ExtraChannel = data.ExtraChannel;
action.Exten = data.Exten;
//action.ExtraExten = data.ExtraExten;
action.Context = data.Context;
//action.ExtraContext = data.ExtraContext;
action.Priority = data.Priority;
//action.ExtraPriority = data.ExtraPriority;
asterAmiClient.send(action, (err, astData) => {
fn({ err: err, data: astData });
});

Can you try AMI BlindTransfer instead ?

I have tried it. It didnt work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.