Closed hours/holiday hours per office

We are have 8 offices and 100 employees… We are in the process of switching to freepbx from mitel on our first office. Everything seems to work great and has given us many needed features we didn’t have with our old mitel system. We have gotten to a point where we are setting up closed hours/holiday hours and setting up that seems to be pretty straight forward. We were able to set it up for our main office lines/DIDs just fine. Currently with our mitel system, we were able to setup a call flow like this…
incoming call to any DID → rings extension 2 times → forwards to a work group that makes decisions depending on business hours/holidays and routes call to appropriate place… whether it be an ivr, ring group, voicemail, etc. We were wondering if there is a way to do this in freepbx without having to create custom time groups and time conditions for every extension/DID? How would something like this be accomplished?
Thank you in advance for any help regarding this matter!

Dynamic routes can likely do what you need:

Dynamic Routes Module - PBX GUI - Documentation (

Dynamic Routes User Guide - PBX GUI - Documentation (

Dynamic Routes - Working Examples - PBX GUI - Documentation (

You can also write your own custom dialplan in asterisk directly (not GUI):

Custom Destinations Module - PBX GUI - Documentation (

Custom Destinations User Guide - PBX GUI - Documentation (

I encourage you read up and ask any follow-up questions. The forum is very helpful for walking through specific issues with your approach and helping resolve them.

Thank you for your answer! We will definitely go through the referenced links and if we have more questions will reach back out. We will update once we get to that point.

1 Like

Both of those ways look like they would work. We are thinking we would like to try using dynamic routes… anyone have any suggestions on how we could approach this? I am thinking we would use 1 dynamic route per office that would check the time conditions some how and depending on the DID that was called, route to the extension or appropriate destination. Does that sound like I am thinking about this right? Or maybe there is a simpler way of achieving the same result?

I don’t fully understand the ask here, but it sounds like you want a common call handling scenario for many DIDs, but with the final step in the process being unique per DID. If that roughly describes what you want, then you could do a call flow like:

  1. Inbound route per DID
  2. Ring local extension 10sec
  3. Configure local extension unanswered calls to go to ring group, time condition, wherever. Have as many steps here as you need
  4. unanswered call finally goes to VM of original dialed extension

You can accomplish step 4 with a single dynamic route configured with asterisk variable defined as ${FROM_DID} and then set whatever final destination you want for each DID.

Thank you everyone for your answers so far. They have guided us in the right direction I feel. I have a question that has come up after going through all of this… Is there a way to have a dynamic route take the result of an agi script and just dial that instead of using the dynamic route entries? For example, if we in our script are able to use logic and discover the extension that needs to be the destination after this whole process, can we then just have that extension be the next step? Instead of matching the result to then link to an option in the entries listed below in the dynamic route?

The reason I ask this is because we are thinking of doing it all this way:
DID → extension for 2 rings → dynamic route that calls on a script (Script would determine office hours, holiday, physical office of extension, etc.) and would return the final destination (using extensions or voicemail) as a variable that we would want the system to just dial as opposed to choosing an option in the dynamic route entries. Does that sound like it would work?

Yes, you can just continue the agi to dial whatever you want (don’t return to the custom destination essentially).

But if you are going to do that no need to build a dynamic route, just send it to a custom destination that engages your AGI and whatever else you want. This would be done in dial plan instead of the GUI.

Links for custom destination are in the earlier post.

That works great for a DID! Thank you for your help. I am curious if there is a variable like that for the original extension? Or how would you handle extension calls as they wouldn’t match a DID?

Thank you for your help! We have been playing with all of these options and it really feels like the sky is the limit.

1 Like

${AMPUSER} is populated with the calling extension number for local calls.

When a call goes from a DID to an extension and then to a dynamic route, does it see that the extension dialed the dynamic route? In other words, if calling a DID rang extension 1000 and no one answered and the call then went to the dynamic route, would ${AMPUSER} = 1000? Also would that value hold through the entire call flow? Thank you for all your help!

No. There are variables populated with the called extension but they would be different depending on the call scenario.

Thanks for all your help with all of this! It really has helped us a ton. Okay, so would you strip out the extension with something like regex and assign it a variable in the dynamic route? Do you have any examples of using ${AMPUSER} that could guide us in the right direction? Maybe it would be easier to just have the internal calls bypass the dynamic route somehow? Our issue is this… We setup something similar to what you suggested above.
DID → extension (10 seconds) → dynroute (time conditions) → if during office hours → our normal flow until it reaches a dynroute that uses ${FROM_DID} to determine the user to leave a voicemail. If it is outside our office hours or a holiday it goes directly to the dynroute to decide which user to leave voicemail. This all works great thanks to your suggestion. The only issue is if someone calls internally. Then there is no DID so the dynroute doesn’t know where to send the call. During office hours its all good but after hours doesn’t seem to work maybe due to an extension being dialed instead of a DID. We have offices in different time zones so the calling internally after hours happens quite a bit. Is there a suggestion on how to handle this problem?

If the use case is always a direct dialed extension, then you might be able to use the Channel variable ${EXTTOCALL}

oh cool… does that include extensions dialed by use of a DID? Sorry for all the questions… and thanks again for your help.

You can drop a DumpChan() into your dialplan to see all available variables


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