Tuesday, December 27, 2011

Controlling the CCX script flow based on time and date variables

This post is the second of two that are dedicated to Cisco unified contact center express (UCCXor CCX) scripting. In this one I'll explain how variables can be used for time/date based script control. The first post can be found here. This example was created with a CCX system integrated with Cisco Unified Communication Manager (CUCM) also known as Cisco CallManager.

A common things to do in a UCCX script is to present different option to callers based on the time they are calling. If it's after hours, they should be getting a closed message and the same goes for holidays. Creating a static script behavior that is based on the "time of day" and "day of week" general steps is one way to do that, but it requires script editing whenever there is a change and it requires a script per customer in multiple queue scenario.
Another option is to act based on a database or XML file query, both are valid but require deeper programming skills and premium licensing (for the SQL query option).

There is another option that I have recently used and would like to discuss here. With this option a date variable is defined in the script and compared to other variables (which are also parameters) and the script behavior is determined based on those comparisons. By using parameters, the open/closed hours can be controlled outside of the script from the CCX appadmin interface.

To further explain here is how this can be implemented in order to check for a weekend day and act differently if this is a weekend day.
First define a date variable and call it currentDayTime, make sure it is initialized as D[now] which means it will be set to the current CCX server system time.

This is how it will look in script editor:

Now define two integer variables and set them to be a parameter, those would be used to configure the weekend days. The variables are initialized in the script to 1 and 7 which correspond to Sunday and Saturday, but this can be adjusted to other days since it's a parameter.
The relevant lines in the script editor would look like the following:

In the uccx script use an IF condition to check if the current day is a weekend day and define what to do based on the comparison. Here is how the IF condition would look like:

The xxx.dow method in a date variable represent the day of week in a numeric value of 1 through 7. This IF can be nested to check for public holidays and more variables/parameters for additional functionality. In order to check for the current hour, use the xxx.hod method, which represent the hour of the day in 0 through 23 values.

Clear as mud, right?  :)

Comment if you have questions and I'll be happy to explain.


  1. Thank for the good guide.i was searching for how to get "day of the week" and "week of the month".
    i implemented this in my requirement it is working fine... :-)
    Reg:Velu S

  2. Do you need to refresh the application if you update the parameters?

    1. If you just update the parameters value without editing the script than it shouldn't be required, but I usually save and refresh anyway.

      If editing the script than an upload and a refresh is required.

  3. How would you use this method for checking time of day as well as day of week?

    1. Hi, you can use a logical 'and' to check for day and time,

      another option is to use an if statement so that if its on a day that is a weekday, check for the hour and queu or play a prompt based on the results.

      good luck!