Showing results for 
Search instead for 
Did you mean: 
Walkthrough Wednesdays

On/Off shift scripting

Hello all,
A bit stuck on a UCCX scripting puzzle. We have 3 teams one in the US, one in India, one in London. Each team has 2 employees. Everyone works the same hours 8am to 5pm Monday through Friday in their own respective time zones. And for the sake of this example let's say everyone is awake 7 am to 9:30PM.
I want a menu step that gives 3 options: routine issues, emergency issues, and red alert.
Option 1 (routine): will dial any team member within their shift hours. If no answer go to voicemail.
Option 2 (emergency) Will first dial anyone on shift if no answer or no one on shift then dial anyone off their normal shift BUT during their "waking hours". If no answer go to voicemail.
Option 3 (red alert) : will act as last effort which will dial the entire team all at once regardless of time of day. Try twice if no answer go to voicemail.
I originally set up my script where is goes to one region, checks time/day and dials if true, skips of not true. Then moves on to next region. The issue with this is the overlapping hours. Let's say it's 8AM in the US then both London and US are on shift then all calls would check the first region first then all calls would ring them without ever hitting region 2.
James Hawkins

There a probably multiple ways to do this but what  would probably try using XML files with the resource telephone listed as below and then read and rewrite them as calls are tried.









i.e. 11111 would be called for the first call and then would be placed as pref4 and the others would jump up a place.



Pretty clunky though

Thank you for the quick reply!


I would prefer the calls to be placed like a hunt group. So if there are overlapping hours, say London and US where 4 members on shift from both regions then dial all 4 hunt group style. the first to pick up terminates the call else go to voicemail. 


This should balance the workload across each individual. And ensures that the team member that is the least busy takes the call. 


You could try using Single Number Reach on CUCM in conjunction with CUCM broadcast hunt groups.

By setting up multiple pilots for different times and using multiple Line groups in your Hunt Lists you should be able to make things pretty granular.

It could work but with the different combinations of Regions 1,2 and 3 and on shift, off shift, and off hours. I think there would be something like 12 different hunt groups to add.  I was hoping to just check who's on shift and then dial those applicable numbers. 

I'm assuming these resources are not logged in are they? This is going to be hard to achieve specially if you want to call multiple people. UCCX works best when agents are logged in and controlling their state. What I would do in your case is send emails out to people with the attached VM.



No these numbers won't be in UCCX. The ultimate idea is to build a time and day based "hunt group" where the "hunt group's" numbers change dependant on the time of day. I figured scripting this would be easiest as TOD routing in CUCM doesn't seem to be the right solution for me. 

In fact...I came accross a post for a Random generated number call which I may be able to use. The post says:




String[] transfer_numbers = new String[] {"1000", "2000", "3000"}

java.util.Random rand = new java.util.Random()





Call Redirect (--Triggering Contact--, transfer_numbers[rand.nextInt(3)])





But I want the dailed numbers to also be string variables. Does anyone know how I can replace the 1000,200,3000 in the example with string 1, string 2, string 3?

You wont be able to do that in the variable pane unless the Strings are finals. So, just use Set steps in the script to set them like this:

Set transfer_numbers[0] = string1
Set transfer_numbers[1] = string2
Set transfer_numbers[2] = string3

Ok, yeah! I did have set steps that now set a String array.


Now I have Set steps that look like:

Set transfer_numbers[0] = 1234

Set transfer_numbers[1] = 5678

Set transfer_numbers[2] = 4321


A random generator that looks like the one I described above

  So in this case, what would my String look like?

I'm confused as to what you are trying to do. Can you rephrase or provide more detail?

For example say Region 1 on Hunt group 1234 and Region 2 on Hunt group 5678 are on shift at the same time. I would like both regions to be called equally. Ideally it would be nice if those two Hunt groups were treated as one for that particular shift overlap but there doesn't seem to be any functionality for that.

My idea is to use a random number generator that says if rand =0 then call 1234 or rand=1 call 5678
So if I use:

Set transfer_numbers[0] = 1234
Set transfer_numbers[1] = 5678
Set transfer_numbers[2] = 4321 (Region 3)

Call Redirect (--Triggering Contact--, transfer_numbers[rand.nextInt(3)])

String[] transfer_numbers = new String[] ????????
java.util.Random rand = new java.util.Random()

But when Region 2 goes off shift and Region 1 is the only one on shift then all calls go to 1234.

My question would be, firstly, if this would work in my use case and how would I be able to setup the above string to point to either 1234 or 5678 randomly with the condition that either of those could change according to the set steps and schedule. 

Have you thought about calling different Hunt Pilots for each of the combinations of teams on shift?  It would only be seven Hunt Pilot numbers, right?


Team 1

Team 2

Team 3

Team 1 & 2

Team 1 & 3

Team 2 & 3

Team 1 & 2 & 3


I'd have to go back and re-read your original post to get a better understanding of what you're trying to do.  Seems complicated, and the further we go down the path of random numbers and String arrays, the further away from a solution I think we'll find ourselves.  I'll do that and reply to the top level post.


Anthony Holloway
Cisco Employee

For Option 1 (Routing), do you see the system just randomly picking one person out of everyone to dial, and that's it? If one person, is the voicemail that person's voicemail, or a team voicemail?


For Option 2 (Emergency), same question for Option 1, and this also applies to the On Shift, and awake Persons.


For Option 3 (Red Alert), Is this like a broadcast Hunt?


Are the people answering on Cisco phones or how are they answering?

Option 1 - Ideally I would like a call to broadcast to all available agents on shift. If no answer go to a group voicemail. 

Option 2 - I would like for the system to first broadcast to anyone on shift if no answer go to off shift/awake then again if no answer go to voicemail. 


Option 3 - Yes, just a simple broadcast that dials anyone on the team. 


Each person will have a Cisco phone with SNR set up to their cell phone.

Content for Community-Ad

Spotlight Awards 2021