Hangup Hook To Put Back A Call Into A Queue

Home » Asterisk Users » Hangup Hook To Put Back A Call Into A Queue
Asterisk Users 2 Comments

hi, I hope someone can help me:-)
we’ve got a freepbx server. there are 2 special extensions (2001, 2002). if someone calls this extensions (or a call is forwarded to these extensions) and these extension hangup (not the caller party), then we’d like to put the calls back into a queue (1000) and wouldn’t like to hangup.

I read your description about hangup hooks:
https://community.freepbx.org/t/hooking-for-fun-and-income/57718

but still not able to implement it:-(
what I’ve done:
* found out in a hard way how to detect the current destination extension (because it’s turn out that CALLERID(dnid) is not working in case of forwarded call it’s show the original destination)
* write a macro-dialout-one-predial-hook and a hook marco like this:

[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf)
exten => s,n,GotoIf($[“${DEXTEN}”=“2001”]?special)
exten => s,n,GotoIf($[“${DEXTEN}”=“2002”]?special)
exten => s,n,MacroExit exten => s,n(special),NoOp(————— Push Special Hangup Handler
——————)
exten => s,n,Set(CHANNEL(hangup_handler_push)=back-to-1000-hangup,s,1)
exten => s,n,MacroExit

[back-to-1000-hangup]
exten => s,1,Noop(====== Entering user defined context back-to-1000-hangup =======)
exten => s,n,Queue(1000)
exten => s,n,Return

it seems to be called and seem to enter into to call but immediately hangup. first of all, in this case when in the hangup handler I will NOT like to hangup how should I finish the marco?:

Hangup Return MacroExit how to redirect the call to the queue?:

Queue(1000)
ChannelRedirect(${CHANNEL},,1000,1)
Gosub(ext-intercom,*801000,1())
dial-one,HhTtrM(auto-blkvm),1000
and what is the reason I can’t put the call back to the queue?
I know that I’m already in the hangup sequence, but still wouldn’t like to hangup. or this can’t be done in the hangup handler?

thank you for your help in advance.

regards.

Levente “Si vis pacem para bellum!”

2 thoughts on - Hangup Hook To Put Back A Call Into A Queue

  • Hangup handlers don’t allow you any control over the hangup process. You can’t stop it from occurring and in fact when it occurs the channel is already hung up. Anything that expects a live channel won’t work.

    You can’t do it from a hangup handler. The Dial option provides the g option[1] which can be used to continue dialplan execution when the called party hangs up, but I don’t work on FreePBX so I can’t comment on how best to use it there.

    [1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Application_Dial

  • It might work for you to branch on ${DIALSTRING} just after your Dial command, if you want to handle a BUSY, NOANSWER, or other result. But if the peer of that Dial hungup, then based on what Joshua said, it seems there’s no recovery.