Randomizing the allocation of booking in your team project would make sense if you want a more even distribution of booking between your resources.

By default Timekit will book the first resource that is available via the findtime/team request or listed first in the project inside the TImekit admin panel. This is done to give you full control over the priority of your booking allocation but if this doesn't apply to your use case this article should help.

What can be done?

Booking-js does allow us to hook into different callbacks during the booking process including a findTimeTeamSuccessful callback. This callback is triggered when booking-js get a successful response from the Timekit API with resources and their available time. There are many more callbacks you can hook into. See a complete list of callbacks and features here.

How does the random allocation work?

So how do you randomize the resources so it is not always the same resources that will be being booked first? Here is the code needed to make this happen:

window.timekitBookingConfig = {
  name: 'Timekit Randomize Resources',
  timekitFindTime: {
    buffer: '0 minutes',
    length: '30 minutes',
    start: '-1 hour',
    future: '2 hour'
  callbacks: {
    findTimeTeamSuccessful: function(response) {
      var numResponses =;
      for (var i = 0; i < numResponses; i++) {[i].users = shuffle([i].users);
      return response;

 function shuffle(array) {
  var currentIndex = array.length,
    temporaryValue, randomIndex;
    // While there remain elements to shuffle...
    while (0 !== currentIndex) {
      // Pick a remaining element...
      randomIndex = Math.floor(Math.random() * currentIndex);
      currentIndex -= 1;
      // And swap it with the current element.
      temporaryValue = array[currentIndex];
      array[currentIndex] = array[randomIndex];
      array[randomIndex] = temporaryValue;

 return array;

So in the findTimeTeamSuccessful callback booking-js will receive the complete response from the Timekit API including the selected time and the available resources.
In this response all we need to do is to randomize the order in which the resources are listed. For that we have created this little shuffle function that takes the resources in the returned response and mixes them up. By returning the shuffled array booking-js, will still pick the first one in the list, but since this is now random, we won't always book the same resource. Hooray!

Why is the custom shuffle function also needed?

The short answer is array.sort does not produce true-random results but by introducing. 

Note: The more correct answer is in this blogpost - nerd alert, this is very geeky stuff:

Did this answer your question?