Dynamically exclude own extension from queue or ring group

I want to suppress calls from all extensions to themselves so that your phone doesn’t ring when you’re calling a ring group or queue you’re in. @lgaetz already recommended using a dialplan hook. I used macro-dialout-one-predial-hook and macro-dial-ringall-predial-hook for that and this works in fact well, but not for ring groups. When calling a ring group you are in, the phone rings, but when answering on a different line, it hangs up (like it should before even ringing).
That’s the code I used, I used it the same in macro-dial-ringall-predial-hook:

exten => s,1,NoOp(Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf)
exten => s,n,ExecIf($["${CALLERID(num)}"="${CONNECTEDLINE(num)}"]?Hangup())
exten => s,n,MacroExit

Also I wanted to ask if just hanging up the call is best practice or if there is a better way to suppress that call.

Thanks for your help!

Hey @AdFun7911

I have gone thru how dialing a ring group works in detail, and I’m not seeing a supportable way to use a dialplan hook to suppress calls to one extension when dialing a ring group. If you dump a call trace to pastebin, you will see the rough sequence of events is as follows:

dialparties.agi is called which determines all members of the ring group and builds the dial string
dialplan hook
dial application uses the dial string built by the agi

The only thing you can do with the hook at the point in the call flow when it’s called, is to manipulate the dial string, which is stored in channel variable ${ds}. This string is quite complicated and it would be difficult to reliably isolate the destination from that string and remove it. It’s complex enough that you would prob need your own AGI file to do it.

The other thing you could do is to hack the dialparties.agi file to exclude the destination extension from the dial string when it’s built, but that would be overwritten every time modules are updated (core?).

The only way I can advise doing this is to replace your ring groups with queues that are configured to work identically to a ring group. I believe that when queue members are dialed, a separate dialplan hook is generated before every dial to each extension.

1 Like

Hey @lgaetz

Thanks for this detailed elaboration! I already feared that when the dial hook was only invoked once, even though I hoped there is another way of doing it.
I think you’re right about using queues instead of ring groups. I didn’t use them before, because I couldn’t find the “Send Progress” option for queues. In ring groups I can switch that to “No”, but otherwise people who are calling from outside don’t hear a ringtone. One option would be to set “Queue No Answer” to “No” (like it usually is) and play the ringing as Music on Hold, but this means that received automated calls start playing before being answered by a human.

Is there a way to set that for queues, too?

There’s the ‘signal ringing’ available as an advanced option in the inbound route, that may resolve. Otherwise I think the only way to do that is to set the queue to answer the channel and MOH set to ‘ring only’ that will play ringing to your callers.

1 Like

That’s it! It works flawlessly. Thanks a lot!

1 Like

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