Randomizing Resource Weights in Booking Forms

Modified on Thu, 4 Dec at 11:33 AM

Randomizing Resource Weights in Booking Forms

Hubhus booking forms allow you to dynamically control which calendar resources are prioritized when suggesting available times.

On this page

Jump to any section using the links below

How to randomize resource weights in a booking form

Hubhus booking forms allow you to dynamically control which calendar resources are prioritized when suggesting available times. One useful technique is to assign random weights to resources, so that no single user is consistently preferred. This can help distribute bookings more evenly or create fair rotation.


Recommended: inside an HTML component, which allows you to reuse the script across multiple booking forms.

Using an HTML component makes it easy to maintain and update the logic in one place and include it wherever needed.


Example: Assign random weights to all bookable resources

<script> // Generate a random weight for a resource function getRandomWeight(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } // Get the currently available calendar resources let resources = bookingForm.getCalendarResources(); // Assign a random weight (10–50) to each resource Object.values(resources).forEach(resource => { resource.weight = getRandomWeight(10, 50); }); // Apply the updated weights bookingForm.setCalendarResources(resources); </script>

How it works

  • bookingForm.getCalendarResources() retrieves the resources selected in the form

  • A random weight between 10 and 50 is generated

  • Higher weight = more likely to be selected

  • Weight is combined with transit minutes in Hubhus routing logic

  • Updated weights are applied with setCalendarResources()

This runs once when the form loads, meaning each customer sees a slightly different priority order — ideal for fairness or ad-hoc load distribution.


When to use this

  • To avoid the same installer/technician being suggested every time

  • To randomize resource priority for equal-load teams

  • To distribute bookings when all resources are equally suitable

  • For A/B testing of routing behavior

? Common searches

booking setup • calendar setup • appointment scheduling • booking configuration

? Also known as

appointment • scheduling • reservation • calendar event

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article