Create Extension Groups

Hi

We have the FreePBX 13.0.159 installed.
Want to group extensions into different groups like: Group A (dept A), Group B (dept B), Group C (dept C), Group D (dept D) etc
Then want to create some rules to say:

  • Group A can call all groups
  • Group B can call only Group B
  • Group C can call Group A and B but not D
  • etc

Is there any free or commercial module that would allow one to do this?

Is this possible with creating custom contexts? I am not familiar, and is there any resource to show how to create custom contexts and configure extensions to be part of them?

Any assistance would be appreciated.

Maybe the commercial Class of Service module?

http://wiki.freepbx.org/display/FCM/Class+of+Service

COS does not presently restrict extension to extension calling. I believe this can be done with Custom Contexts, but not 100% sure.

Thanks. Any assistance as to how this can be done would be really welcome.

Is there any one in this forum who can please assist with this or point me in the right direction?
What is a good resource to setup custom contexts if that is the way to go…

There are lots of people that can help you with this, but not many that will give you the code and then support it for free. Especially since you haven’t really provided the level of detail one would need to accomplish something like this.

Requests like this come up every few months. We just wrapped up a huge discussion about it maybe four weeks ago. In that discussion (which included some custom context code), it seems to me we decided that managing who can call whom was handled by checking the extension number and checking for a range of reasonable destination.

Here’s the link to that discussion. Limit internal calls to specific extensions.. It was the third entry when I Googled “asterisk limit extensions internal calls”.

Thank you Dave.
Let me know what detail you will need and I would be happy to have your help.
There are various departments (about 15) each have a variable number of extensions (5 or 6).
All extensions are numbered with 9XXXX format.
We need three types of rules which can basically be summarized like this:

  • Group A can call all groups
  • Group B can call only Group B
  • Group C can call Group A and B but not D
  • etc

So any department (group) will fall into one the above scenarios.

I did see the thread you mentioned and it was helpful but I would appreciate your check and confirmation of some questions:

I am assuming that there is no way to do this independent of extension numbering? In other words, I cannot number extensions with any 9XXXX pattern and then make extensions part of a Directory for example, and manipulate it somehow to achieve the goal?

If the above is not possible, then am I right to assume that we will need to provide structured numbering to the group extensions? i.e. Group A 91XXX, Group B 92XXX, Group C 93XXX, etc.

So if we have to do this using dial plans and custom contexts, then first off, I guess I need to edit the extensions_custom.conf file and input any of the rules we arrive at in that file, is that right?

Would the below dial plans work: ?

[from-Group-A] ; Group A can call all groups
exten => _9XXXX,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

[from-Group-B] ; Group B can call only Group B
exten => _[13-9]!,1,Goto(app-blackhole,congestion,1)
exten => _9XXXX,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

[from-Group-C] ; Group C can call Group A and B but not D or others
exten => _[4-9]!,1,Goto(app-blackhole,congestion,1)
exten => _9XXXX,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

[from-Group-D] ; Group D can call all groups except group B and C
exten => _[23]!,1,Goto(app-blackhole,congestion,1)
exten => _9XXXX,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

Finally, in order to make an extension part of a specific context, do we just edit the extension’s context field in the GUI?

Your input and assistance is appreciated.

In a context, the number after the exten= is the number being dialed, and your example looks like your hoping that it’s the source extension.

So, if your context is [from-group-b] and you set the extension context is set to that, you can use rules like these to limit your outbound calls.

So, set the phones in group B to use the [from-group-b] and use something like exten=>9[124]XXX,1,Goto(from-internal,${EXTEN},1) to allow calls from group B to phones in groups A, B, and D (if I’ve got your scheme figured out).

If group A can call anyone, just set their context to “from-internal”. There’s no reason to set up special rule for them, unless you want to do it for consistency.

1 Like

Thanks Dave
One question, can we have a rule to send a call within a specific context to a directory just as in IVR Direct Dial enabled?

[from-Group-B] ; Group B can call only Group B
exten => _[13-9]!,1,Goto(app-blackhole,congestion,1)
exten => _9XXXX,1,Goto(from-internal,${EXTEN},1) ; HERE WE WANT TO SENT THE CALL TO A DIRECTORY INSTEAD OF DOING SOME PATTERN MATCHING. IS THIS POSSIBLE?
exten => h,1,Hangup()

I’d start with something more like this:

exten=>411,1,Goto(directory,1) exten=>[139]XX,1,Goto(app-blackhole,congestion,1)

IIRC, the underscore is a wildcard, so any number that matches one of your extensions at the end would match. Good luck trying to figure that one out later…

Another approach would be to use conditionals in an ‘s’ context. For example:
`[from-Group-B] ; Group B can call only Group B’
exten=>s,1,Noop(Call from Group B)
exten=>s,n,If($DEST<101),…

There are probably a hundred ways to skin this cat. I’m sure someone with more context writing experience will join in and correct my mistakes. @Dicko usually joins in about here… :smile:

As a brief comment, the “custom contexts” module will take care of most of this, but read the “caveates” , which basically restate that you will need to group your “grouped extensions” in your own contexts in /etc/asterisk/extensions_custom.conf and you will need to study the asterisk “rules of inclusion” as you allow/deny/weight the “standard” contexts exposed , and how asterisk performs “extension matching”, perhaps :-

http://the-asterisk-book.com/1.6/einleitung-regex.html

( you might well be surprised :wink: )

it will go a fair way to making FreePBX “multi tenanted” but there are many other things like voicemail and trunking that need massaging and most have found to be basically ultimately unsustainable except for the most skeletal systems.

Good Luck though.