How to forward to extension from trunk number range

Hello, sorry I don’t know the correct term for this so i tried to describe it.

I have a trunk with the main number +491234 33333 0 and the 0 could be 0->9999 depending of registered extension.

So I basically want to redirect +491234 33333 123 -> to extension 123, +491234 33333 777 to 777 etc.
I also have ring groups and queues.

As FreePBX seems to not support these (it is a common feature at least here in germany) I added this to /etc/asterisk/extensions_custom.conf

[from-special-trunk]
exten => _+49123433333XX,1,Goto(from-did-direct,${EXTEN:-2},1)
exten => _+49123433333XXX,1,Goto(from-did-direct,${EXTEN:-3},1)
exten => _+49123433333XXXX,1,Goto(from-did-direct,${EXTEN:-4},1)
include => from-pstn

This works pretty well but only for extensions and not for ring groups and queues.
If I understood it correctly the FreePBX way is to add inbound routes for every single extension, this is something I really really want to avoid at 300+ extension.

Is there a way to do it for ring groups and queues too or to do it completely different ?

best regards

To include Ring Groups and Queues, you would need to change the context from from-did-direct to ext-group and ext-queues respectively.

tx for quick reply

So I need to do it this way (I am currently not able to test) ?

exten => _+49123433333XXXX,1,Goto(ext-group,${EXTEN:-4},1)
exten => _+49123433333XXXX,1,Goto(ext-queues,${EXTEN:-4},1)
exten => _+49123433333XXXX,1,Goto(from-did-direct,${EXTEN:-4},1)

No, that won’t work. I’m rethinking my previous advice. What you need is a context that includes all the dialplan you need to reference. The context from-internal is such a context, but I’m reluctant to advise sending external calls directly to the from-internal context for security reasons.

I think in your shoes, rather than using from-internal, I would make my own context that looks like this:

[external-includes]
include => ext-group
include => ext-queues
include => from-did-direct

[from-special-trunk]
exten => _+49123433333XX,1,Goto(external-includes,${EXTEN:-2},1)
exten => _+49123433333XXX,1,Goto(external-includes,${EXTEN:-3},1)
exten => _+49123433333XXXX,1,Goto(external-includes,${EXTEN:-4},1)
include => from-pstn
1 Like

I need to test it a bit further but it looks working perfectly.

Thank you !

1 Like

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