Proper way to route calls based on time

So, is the proper way to do this to link one time condition to another, and then to another, and then to another?
Trying to figure out how to word this… So lets start with what I want to do. Starting at 0:00
If its between 00:00 and 09:00, send it to ivr “Closed”
If its between 09:00 and 17:00 send it to ivr “We are open”
If its between 17:00 and 21:00 send to IVR “After hours service”
If its between 21:00 and 23:59 send it to IVR “Closed”

So I guess first off, are those the time groups I should set? And then set the time conditions based off the time groups? And if so, should each time conditions on Non match lead to another time time condition?

Having a hard time explaining this… So the flow would go like this.
Incoming call routes to this time condition:
If it matches the time group ‘between 00:00 and 09:00’, route call to IVR “closed”, if it doesn’t route it to:
A time condition. If it matches time group ‘between 09:00 and 17:00’ route to IVR “Open”, if it doesn’t route to:
A time condition. If it matches time group "Between 17:00 and 21:00’ route to IVR “After hours service”, if it doesn’t…

Whew. I hope I was able to explain that. Basically, is that the “proper” way, or the “best practices” way? Or is there a better, or “better practice” way to do it?
Sorry for the long windedness, I just wanted to be sure I explained it correctly. In addition, please feel free to correct any errors I may have in my time groups (Should it be between 00:00 and 08:59. Its possible to just set between 21:00 and 09:00, and it will recognize next day automatically) etc.

Proper is relative, and time conditions were built for your use case. There may be a more optimized way to do this using one dynamic route, if interested.
Dynamic Routes Module - PBX GUI - Sangoma Documentation (atlassian.net)
Use Dynamic Routes to Execute a shell script - FreePBX / Tips and Tricks - FreePBX Community Forums

You could set an Asterisk variable by nesting a strftime command inside IF and SET commands to provide a value representing the four states your route could be in, then make four routes on the dynamic route that go to each of the four states.

Information about Asterisk Function strftime | Voip-info.org

Asterisk cmd Set - VoIP-Info

Asterisk func if - VoIP-Info

This is nicer in my opinion because everything is in one dynamic route, vs multiple time conditions. Besides using Asterisk commands, you could also use a MySQL query or the AGI to calculate the time and provide the value, if you prefer.

Of course, if you prefer not to, there is nothing wrong with your approach either.

I am just starting to realize how much of a nightmare time condition routing is. Everything needs to be created backwards to avoid an endless set of windows appearing to need to create the new time group. OMG!
Please, someone, program a better/easier way to do this.

I am not sure what a better way would be. Admittedly I’ve used it for years now but how would you setup a top line item in a workflow to go to something that hasn’t been created yet?

You are supposed to design your workflow/call flow first (either in your head or on paper or some sort of digital software) and then start by creating the items on the bottom/end of your call flow chart back up to the ingress point into your phone system.

1 Like

This is why FreePBX is great, you can do this yourself and contribute it back to the project, or you can pay someone to do it for you and contribute it to the project, or you can submit a feature request to the company to see if they will do it (They seldom do).

Thats why I like the Dynamic Route approach with an AGI script that spits back rounded times. You are still having to define each state (four in this case), but it’s all inside one object instead of multiple time conditions.

1 Like

Well, I found out I was making this far more difficult then it needed to be. Originally I was using 6 time conditions, but by finding out where they overlapped, I brought it down to 2.
Overall, I think I have it all resolved.

1 Like

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