Automated Ticket Routing by Timezone (with Code)

Implement a ticket router that routes each issue to the staffed support region based on real local time, handling DST and fallback. Full TypeScript code

miércoles, 29 de julio de 2026 • 4 min read • Q2BSTUDIO Team

Optimiza tu soporte con enrutamiento follow-the-sun

Companies with global operations face a constant challenge: providing uninterrupted technical support without running night shifts in every office. The classic solution is follow-the-sun routing, which automatically assigns each ticket to the region that is currently in business hours. However, the technical implementation hides a complexity that many underestimate: daylight saving time changes, overnight coverage windows, and the need for a fallback when no hub is operational.

At Q2BSTUDIO we have worked with multiple companies to design intelligent routing systems, integrating cloud AWS/Azure, AI and process automation. This experience has taught us that a timezone-based ticket router is not purely an operations problem, but a software engineering challenge that requires precise time handling, fault tolerance, and an extensible architecture.

The naive approach hardcodes UTC offsets, but this breaks twice a year when clocks change. Worse, if your server is in one zone and your team in another, the server's local time is useless. The correct solution is to delegate time calculation to a timezone API that returns the real local time for each hub, including DST status. Thus, instead of manually adding or subtracting hours, you directly compare the local time string (e.g., "09:30:00") with the coverage window defined in your configuration.

Modeling support hubs is the next step. Each hub should have an identifier, an IANA zone (like "Europe/Berlin"), a dictionary of hours per weekday (open and close), a list of local holidays, and a priority for tie-breaking. It is also advisable to include the languages it handles, to preferentially route to a hub that speaks the customer's language. The configuration should be in a separate file, not embedded in the routing logic, so that coverage changes do not require code modifications.

The decision logic reduces to three steps: determine which hubs are open in their local time, select the best among them (by language, priority, and a stable tie-break), and return a fallback if none are open. The fallback is crucial: a ticket should never be left unassigned. Instead, it is sent to an on-call hub configured to receive out-of-hours tickets. This is better than dropping a ticket or sending it to a hub with no one there.

In addition to routing, it is very useful to enrich the ticket with the customer's local time. Knowing whether the customer writes at 3 AM or 2 PM changes the tone of the response. An additional call to the same timezone API, but using the requester's IP, provides their city, country, and local time. This data can be added as an internal comment in the ticketing system (Zendesk, Freshdesk, etc.) so the agent has context.

The technical implementation can be done in any language, but here we use TypeScript to show the pattern. An HTTP client is defined that queries the API with a timeout (1.5 seconds) and caches the result per zone for 30 seconds, to avoid hammering the endpoint during ticket spikes. Then the isOpenNow function takes a hub, gets its local time, extracts the weekday from the response, and compares the current time with the window defined for that day. It also handles overnight windows (e.g., 22:00 to 06:00) by checking if the current time falls into the previous day's carryover.

When multiple hubs are open, they are sorted first by language match, then by numeric priority, and finally by identifier (for stability). The first in the list is the destination. If none are open or all calls fail, the predefined fallback hub is used.

A common mistake is not considering that the hub's local time may be unavailable due to a network error or rate limit. The function should return an "unknown" status instead of "false", because a failure does not mean "closed". This avoids routing to a hub that might be open but could not be verified, or closing the door to all hubs when only one failed.

Integration with helpdesk systems like Zendesk is straightforward: a trigger in the helpdesk sends a POST to your endpoint when a ticket is created. Your service runs the routing and then updates the group or region of the ticket via the corresponding API. It is important that the endpoint returns an error code (e.g., 502) if the assignment fails, so that the Zendesk trigger can apply a fallback rule.

From Q2BSTUDIO's perspective, this type of solution fits perfectly into software process automation projects. The routing logic can be extended with AI agents that classify tickets by urgency or sentiment before sending them to the appropriate hub. It can also be integrated with Business Intelligence dashboards (Power BI) to analyze response times by region and optimize coverage windows.

Cybersecurity should not be neglected: timezone APIs must be authenticated with a key, and the routing endpoint must be protected against injections and abuse. Q2BSTUDIO offers cybersecurity and pentesting services to ensure that your cloud infrastructure (AWS/Azure) is robust against attacks.

In summary, automatic ticket routing by timezone is a piece of software that appears simple but requires attention to detail. With an architecture based on real-time APIs, externalized configuration, and a solid fallback, any global company can offer 24/7 support without duplicating teams. If you are considering implementing such a system or need advice on custom software development, at Q2BSTUDIO we can help you design a scalable, secure, and business-adapted solution.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.