Routing Calls Based on the Time of the Day
On this topic
In this article we’ll explain how to use the Create a condition component to route calls to different extensions depending on the time of the day, from a voice app created with the 3CX Call Flow Designer (formerly VAD).
The project for this application is installed along with the 3CX Call Flow Designer, in folder “Documents\3CX Call Flow Designer Demos”.
Step 1: Create the project
First, we need to create a new project. Open the CFD and go to “File > New > Project”, select the folder where you want to save it, and enter a name for the project. In this case we’ll name it “TimeBasedRouting”.
Step 2: Add the “Create a condition” component
Now we’ll add the Create a condition component:
- Drag a Create a condition component from the toolbox, and drop it into the design surface of the “Main” callflow. Then select the component added, go to the Properties window and rename it to “selectTimeRange”.
- Configure this component with 4 branches, and name them “from0to9”, “from9to12”, “from12to18” and “from18to0”:
- Now we need to set the Condition property for each branch. These are C# expressions, which must return true in order to execute the components inside the branch. Branches conditions are evaluated from left to right, so if the first branch condition is not met, the following is evaluated. So, in this case we’ll use the following conditions:
- For branch “from0to9”: DateTime.Now.Hour < 9
- For branch “from9to12”: DateTime.Now.Hour >= 9 && DateTime.Now.Hour < 12
- For branch “from12to18”: DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18
- For branch “from18to0”: we’ll leave this Condition empty, which means that the components from this branch will be executed when no other branch is executed.
Step 3: Add Transfer components
Now that we have our conditions ready, we need to add a Transfer component to each branch, so the call is transferred to a different internal extension in each case. To do this, drag a Transfer component from the toolbox, and drop it into the first branch. Then repeat the procedure to add 4 components, one into each branch. Configure each Transfer component with a different Destination. In our example, we’re setting the Destination property of each component to extensions 101, 102, 103 and 104 respectively.
Please note that the Destination property is an expression, therefore if you enter constant values, they should be quoted. This is because this property can also reference variables or be set with the result of a function invocation. In order to create a constant string value, we need to add quotes to it.
Step 4: Build and Deploy to 3CX Phone System
The project is ready. We just need to build and upload it to our 3CX Phone System server. To do this:
- Go to “Build > Build All”. The CFD will create the file “TimeBasedRouting.tcxvoiceapp”.
- Go to the “3CX Management Console > Call Queues”, create a new queue, configure it with name and extension, check the “Voice apps” option, and upload the file created by the CFD in the previous step.
- Save the changes to the queue. The voice app is ready to use. Make a call to the configured extension, and you should be transferred to a different destination depending on the time of the day.