Prevent Teacher Phones from Ringing During School Hours

Hi everyone,

I work at a school district, and I’m trying to configure our FreePBX system so that teacher phones do not ring during school hours, but admin phones still do.

I’ve seen some people suggest using Time Conditions with Time Groups, but I’m not sure how to apply that logic specifically to teacher extensions while leaving admin extensions unaffected.

My goals:

  • During school hours: External calls should not ring teacher extensions, but should still ring admin phones.
  • After hours: Both teachers’ and admin phones can ring as usual.

What’s the best way to structure this in FreePBX? Should I be using Ring Groups, Follow Me settings, or something else in combination with Time Conditions?

Any guidance or examples would be greatly appreciated!

Thanks in advance.

How do external calls get to the teacher phones now? What kind of call routing is currently in place?

At this point, I’m still in the process of configuring the system. I don’t have any SIP trunks set up yet, but the teacher extensions are already configured and accessible through the IVR. Once the SIP setup is complete, each teacher extension will be assigned its own DID.

What do you want to happen to calls to a teacher’s DID during school hours? Route them to the teacher’s Voicemail?

How Many Teachers DIDs have you got?

Correct, I want to route it to the teacher’s voicemail or send it to the front desk. I am talking about 300 extensions.

I work in a school district too. Something I set up in my configuration file was basically this (I don’t have the files in front of me, so basically pseudocode):

Call comes from the outside to _123456XXXX
XXXX matches an extension
Look up that extension’s Account Code
If Account Code ends with (or equals, depending on how you want to set it up) 1:
–True, this extension is a classroom number and should be sent straight to VM during school hours (which I have set somewhere else)
–False (is equal to or ends with 0), this is an admin’s number and should not be subject to forwarding during school hours - let the call go through
–outside the defined school hours, it will ring through to the classroom

How I had my account code set up for 30+ schools: I’d have it be something like 2071 (207 corresponds to one of our elementary schools). I have the school hours broken down for M,T,Th,F, and a separate one for W (early release days), and for each school level (elementary, middle, high).

1 Like

And each extension has a dedicated DID? So 300 DIDs?!

My initial solution of using Time Group and Time Conditions is going to be very cumbersome to manage with that many DIDs. I’m thinking perhaps Dynamic Routes but that’s something I’m not very conversant with yet.

Let me flip it in my head and also wait to see if more experienced folks have a better solution.

Is the DID the only way external calls get routed to the extensions? Do any IVRs or Queues/Ring Groups route external calls to these teacher extensions?

I am quite new on FreePBX. Can you share some examples or screenshot?

Here’s kind of what I have. It’s been a while since I visited it (our FreePBX is just a test server, not production - we’re still stuck with our current PBX for a while).

The Account Code I’m talking about is in Extensions → Advanced:

In this case, this breaks down to:

216 - an elementary school
1 - a classroom phone (meaning it should be subject to forwarding during school hours)

In extensions_custom.conf, I have in part (note that I am not super good at dial plan programming, so there may be more efficient ways, or correct ways - it did at least work when I tested around, for what it’s worth):

[from-pstn] ; call from the outside world
exten => _123456XXXX,1,Noop
same => n,Set(classext=${EXTEN:-4}) ; takes the last four digits of that called number
same => n,Set(loccode=${DB(AMPUSER/${classext}/accountcode)}) ; grab the account code for the four-digit extension
same => n,Set(ignore=${loccode:-1}) ; ignore flag - if it's 1, ignore (not a classroom); 0 is a classroom
same => n,GotoIf($[ ${ignore} = 1 ]?allowcall:sethours)

...

;set hours for school days
same => n(sethours),Noop()
same => n,Set(hours_elem_nonwed=8:40-15:17)
same => n,Set(hours_elem_wed=8:40-14:00)

...

same => n(loc2160),Goto(elemhours) ; elementary school 1

...

same => n(elemhours),Noop(in elemhours) ;elementary forwarding check
same => n,GotoIfTime(${hours_elem_nonwed},mon&tue&thu&fri,*,*?schoolhours)
same => n,GotoIfTime(${hours_elem_wed},wed,*,*?schoolhours)
same => n,Goto(allowcall)

;send the call to voicemail, since it's school hours
same => n(schoolhours),Macro(vm,${classext},BUSY)

;let the call go through to the set, school is out of session or this phone is not a classroom phone
same => n(allowcall),Goto(from-internal,${classext},1)

I set it up this way so non-classrooms can get phone calls regardless of the time of day. Most all of our classrooms have their own DID.

I suppose what I have up there doesn’t allow 911 to call back directly if a classroom calls 911. I’ll need to look into that (luckily like I said, none of this is production).

1 Like

We do something similar to ksdpbx, but we utilize the accountcode field for other things, so our dialplan is slightly different.

We don’t give DIDs to every teacher, but this dialplan does in fact work on DID calls that go to an extension with the account code set

One of our typical account codes look like this:

es,abes,cdhsfeeder,ExternalToVM,secretary

ES meaning “elementary school”, ABES meaning the abbreviated name of the location, then the highschool it feeds into, then the external to voicemail code to signify call treatment, then the function of the phone or jobtitle of the user

This way we can use the account code field for different custom functions.

All of this is in our extensions_custom.conf

we override the from-did-direct context to hook in at that point:

; Override for custom dialplan to check account code and send to VM if found
[from-did-direct]
include => ext-direct-to-vm-custom
include => ext-findmefollow
include => ext-local

now the custom context:

[ext-direct-to-vm-custom]
; Direct to voicemail if accountcode field = ExternalToVM
exten => _XXXXX,1,Answer()
same => n,Set(EXTEN_ACCOUNTCODE=${DB(AMPUSER/${EXTEN}/accountcode)}) 
same => n,NoOp(========== ${EXTEN} ExternalToVM = ${REGEX("ExternalToVM" ${EXTEN_ACCOUNTCODE})} ==========)
same => n,GotoIfTime(08:00-15:00,mon-sun,,?EvalAccountCode:SendToEXT) ; systemwide time of day rule for classroom calls

; determine if account code field contains the string
same => n(EvalAccountCode),GotoIf($["${REGEX("ExternalToVM" ${EXTEN_ACCOUNTCODE})}" = "1"]?Direct2VM:SendToEXT)

; Here's where we send them to voicemail (we use skype for business, which needs a username instead of an extension)
same => n(Direct2VM),Set(username=${ODBC_EXT2UN(${EXTEN})}) 
same => n,GotoIf($["${username}" == ""]?BackToIVR)
same => n,Dial(PJSIP/${username}@skypeVM)
same => n,Hangup()

; If no ExternalToVM account code, or outside school hours, send the call on ahead
same => n(SendToEXT),Goto(from-internal,${EXTEN},1)
same => n,Hangup()

; In the event that they came from an IVR, send them back, or let the caller know they called someone with no VM assigned.
same => n(BackToIVR),Playback(cdir-sorry-no-entries)
same => n,Goto(${IVR_CONTEXT},-,1)
same => n,Hangup()

Hope this assists you in finding the right way to do it. Our dialplan involves some policy decisions, as we wrestled with the “should we let internal callers through to classrooms during instruction?” and realized that our teachers were so used to using the override code on the restrictions of the previous phone system, they were muscle memory dialing every internal number that way. So we decided that if you’re on a phone in the school system, and calling a number that could be a classroom, you’re probably aware that you’re potentially interrupting instruction, and probably aware when it’s important enough to do so. Thus, we allow internal calls to all extensions at all times.

It’s those pesky parents that inevitably decide to call classrooms during state testing that we wanted to curtail (and kids with cell phones in the back row calling the main number and putting in the extension of the phone in the front of the room).

2 Likes