Redirect calls from external to VM


(United States) #1

I work for a school district using FreePBX 15. Is there a way to enable the external call to classroom extension to go directly to VM without ringing the phone during class hours, but keep it so internal extensions are able to ring through or transfer a call in directly? For example, we do not want parents calling teachers directly during call hours of 7am-3pm. In an emergency situation, they can call the office, and then the office staff can transfer the call directly into the room\relay the message to the teacher. Before 7am or after 3pm the phone can operate as normal. While allowing all non-classroom phones to operate as normal all the time.

Some details to note, all schools have an IVR with direct-dial enable, only some classroom extension have DID, most are internal extension only,


(Dave Burgess) #2

There’s a thread here that I’m going to pull and let’s see if it helps.

All external calls, as well as local and intercom calls, go first to the PBX and then the extension (or VM, or whatever) is bridged into the existing call and the two end are connected. That’s the back-to-back part.

So, given that, there are several scenarios that you need help with:

  1. Incoming direct call to a teacher’s extension. There’s really no such thing - the inbound call goes to the PBX and the PBX calls the teacher’s extension. In this case, you can run the inbound call through a time condition and route it to voicemail instead of the extension. That one’s easy by routing the Inbound Route to a Time Condifion and going to town from there.
  2. Intercom/internal calls. Once again, these are extension to PBX which dials out to the other extension. Since they aren’t coming in on the Inbound Route, you should be good to go.
  3. Calls get answered by an IVR with direct dial. The direct dial here is a local (internal) call. You’ve already gotten past the Time Condition, so you have to come up with another way. Do Not Disturb on the phone is a non-starter (internal calls won’t work), so you have to come up with another approach.

I’d probably start my research with checking out the option for direct dialing through the directory. That way, if they get to the IVR, they can only dial extensions that allow for interruption (lunch room, janitor, office, etc.). Make that your “day time” IVR.

Set up a second IVR that allows for direct dial to any extension and turn that one on at 3:00. Seems like a lot of extra work, though.

As far as I know, there’s no ‘extension level’ logic that can help you, at least not yet. You could right a context that looks at the CID of the call and send it to the phone if the call originated locally and VM is it’s external. Make that your ‘from-internal’ and route the calls based on time and source.

There might be a couple commercial modules that might allow for something like this, but I just can’t think of an easy way to do this without code.


(United States) #3

Sounds like there isn’t anything built into FreePBX for this. I have been doing some digging and let me know if this makes sense\possible or if I’m totally offbase. (Sorry if my terminology is incorrect, still learning dialplan\agi\etc).

All of my User Manager accounts are created with AD sync, I would add to their description the word “classroom” or something along that line to identify that they will not get calls during classhours.

My thought is to add a custom dialplan under extension_custom.conf that sends extension to an AGI script (php\python) to check against SQL database querying table userman_user to look up their extension and if the description contains the word “classroom”. if true it will modify the extension and prefix with * to send it directly to VM, if false proceed as normal.

I just need to figure out the timepiece if the above is possible.


(Dave Burgess) #4

A less “out and back” approach would be to daily (?) run through a batch routine that scans through the Asterisk Database. This way you can access them directly from the dialplan and they are persistent.

Use the Asterisk cli command ‘database put classroom 123 *123’ to set the value. Set it for every extension (e.g., 123) and set it either to the extension or the VM extension.

This adds a level of flexibility where people with three or four extensions can get all of the VM at one extension.

You’ll still need a dialplan, but at least you won’t have to reach out to MySQL every time. You can use ‘deltree’ to remove the entire classroom tree at the end of the day and rebuild it a minute before you are ready to redirect in the morning. Update your “from-internal-classroom” context to reset the extension to the ‘stored’ extension and you should be good to go.


(United States) #5

Thanks this is very helpful! This sounds promising. I got some work ahead of me but this was very helpful!!

Can dialplan do logic check, IE check the current time and if between X and Y?


(Dave Burgess) #6

Yes, but it probably doesn’t have to:

  1. Set up your time conditions/Call Flow Control so that you control the times when the filter is in place.
  2. Send all calls during that period to the context via a Misc Destination. I think it’s MiscDest - there are like four of these things and they confuse me.
  3. Hook the Misc Dest so that it points at your new context. Make this context do the ‘replacement’ work.
  4. Jump back to the “from-pstn” context with the EXTEN reset.

(system) closed #7

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