Introducing a new way to review your PRs.

Read the announcement

frappe / helpdesk

Modern, Streamlined, Free and Open Source Customer Service Software

View on GitHub

20 documents · Updated Nov 23, 2026

docs / work-routing-and-slas

Work routing and service levels

Helpdesk routes open tickets to support agents through conditions, teams, and assignment schedules. It also tracks whether agents can take work and whether tickets meet response and resolution targets. Holiday calendars and working hours define when service time counts, while the desk keeps assignment and SLA state visible to agents. Read this page with Service operations, Ticket management, and Dashboards and ticket analytics for the wider service flow.

Work routing

Assignment rules decide which users receive a ticket when its fields match a rule. A rule has an assignment condition, an optional unassignment condition, an assignment method, a priority, a user pool, and active days. The desk presents these as settings so teams can change routing without changing ticket data.

The assignment method controls how work moves through the user pool:

MethodRouting purpose
Round RobinShare work in turn across the pool.
Load BalancingPrefer users with less current work.
Weighted DistributionGive users a relative share of work.
Based on FieldRoute from a ticket field rather than the rule’s presence-aware pool.

References: desk/src/components/Settings/Assignment Rules/AssignmentRulesList.vue#L8-L15 desk/src/components/Settings/Assignment Rules/AssignmentRuleView.vue#L119-L289 desk/…/assignmentRules.ts• L4-27

Conditions exist in both a structured form and a legacy expression form. The structured form supports the desk settings UI. The legacy form remains readable so older rules can continue to work until an engineer recreates them in the current editor.

References: desk/src/components/Settings/Assignment Rules/AssignmentRuleView.vue#L139-L187 desk/src/components/Settings/Assignment Rules/AssignmentRuleView.vue#L215-L269 helpdesk/…/assignment_rule.py• L17-32

Team routing

An HD Team is a group of agents that gives tickets a shared routing target and a shared visibility boundary. Creating a team also creates its linked ticket assignment rule for open tickets assigned to that team. The rule removes work when the ticket moves to another team and includes every day in its assignment schedule.

Team changes stay linked to that rule. Membership updates replace the rule’s users, while weighted routing keeps each member’s existing weight when possible and gives new members the default weight. A disabled team or a team with no agents disables the linked rule. Renaming a team updates the rule conditions, and deleting a team removes that rule.

Team membership and assignment membership should describe the same people. The system warns when a linked rule contains a user who is not in the team. If an open ticket changes teams, an assignment to a user outside the new team is cleared when the new team has an enabled rule with users.

Teams can be disabled. A team can also ignore ticket restrictions, which lets its agents see tickets beyond their normal team scope. These controls affect access as well as routing, so a change to team settings can change both who receives work and who can view it.

References: helpdesk/…/hd_team.json• L27-57 helpdesk/…/hd_team.py• L22-119 helpdesk/…/test_hd_team.py• L11-148 desk/…/TeamEdit.vue• L168-203 helpdesk/…/hd_ticket.py• L1358-1434

Agent availability

Agent availability is the current presence state used to show whether an agent is ready for work. Each agent has one enabled HD Agent Status, and the status belongs to a category such as Active, Away, or Unavailable. The system always keeps at least one enabled Active status so new agents have a usable default.

For presence-aware assignment methods, the routing preference is:

  1. Prefer Active agents.
  2. Use Away agents when no Active agent is in the rule’s pool.
  3. Use Unavailable agents only when no other pool member can receive the ticket.

This preference is a routing aid, not a hard block. It prevents a ticket from staying unassigned when every suitable agent is away or unavailable. Based on Field rules do not use this pool filter because the ticket field determines the user.

References: helpdesk/…/assignment_rule.py• L23-64 helpdesk/…/hd_agent_status.json• L35-58

The desk shows the agent’s current status and the time of its last change. A status can also have an expiry time, which returns the agent to the default status when it ends. Status changes use one shared server write path and live events so all connected desks can keep the same view.

Desk state

Desk state connects the agent’s own availability with shared live presence and ticket assignment views. The signed-in agent can change status from the profile or availability menu. The desk updates the local view first, queues writes in order, then accepts the server result or restores the confirmed state if a write fails.

The desk handles temporary statuses as a client-side timer with a visibility check. This lets a sleeping browser catch up when it becomes visible again, while the server event remains the source of truth for the stored status and expiry.

Ticket assignment data is enriched with presence for agents using the desk. Customer-facing reads receive assignee names without internal availability details. This keeps routing context useful to agents without exposing desk presence as customer data.

References: desk/…/agentStatus.ts• L54-141 desk/…/agentStatus.ts• L168-339 helpdesk/…/api.py• L750-777 desk/…/AssignTo.vue• L120-145

This sequence shows how an availability change reaches the server and other agent desks.

sequenceDiagram
    participant Agent as Agent
    participant Desk as Agent desk
    participant Server as Helpdesk server
    participant Other as Other desks
    Agent->>Desk: Change availability
    Desk->>Server: Save HD Agent status
    Server-->>Desk: Validate and stamp change time
    Server-->>Other: Broadcast availability update
    Desk-->>Agent: Refresh presence and assignment views

References: desk/…/agentStatus.ts• L126-141 desk/…/agentStatus.ts• L279-339 helpdesk/…/hd_agent.py• L20-95

Service level agreements

An SLA policy defines the service time promised for a ticket. A policy can match ticket conditions, apply to selected priorities, set first-response and resolution targets, and define its valid date range. A default policy may catch tickets that do not match a conditional policy, but a site can also run without one.

Policy selection considers whether the policy is enabled and in date, whether it includes the ticket priority, its rank, and its condition. The default policy is considered last. A blank condition on a non-default policy does not match every ticket.

When a policy attaches, the ticket receives a default priority if it has none and starts its SLA clock. The policy then calculates response and resolution deadlines from its working hours and holiday list. Resolution tracking is optional. A paused ticket stops its active target window and records hold time for later resolution calculation.

Changes that remove a priority, disable a policy, or remove its default role can detach open tickets on their next update. The backend warns when such a change affects tickets that still use the policy.

The ticket SLA state communicates the next service obligation:

StateMeaning
First Response DueNo first response exists and its target has not been met.
Resolution DueThe first response is complete but the ticket is not resolved.
PausedThe ticket is on a paused status before the target is breached.
FulfilledRequired response and resolution work finished within target.
FailedA response or resolution target was missed.

The desk shows first-response and resolution cards only when a policy is attached. Each card can show the target time, actual response or resolution time, fulfillment duration, and delay. Delay can show both working-time delay and total calendar delay when the policy has enough data to calculate both.

References: helpdesk/…/utils.py• L12-52 helpdesk/…/hd_service_level_agreement.py• L24-117 helpdesk/…/hd_service_level_agreement.py• L163-207 desk/…/useSLA.ts• L51-181 desk/…/TicketSLA.vue• L63-141

Working hours and holiday calendars

An HD Service Holiday List defines dates that do not count toward SLA time. It has a valid date range and can contain one-off holidays and weekly days off. The desk offers calendar and list views so service owners can maintain the same calendar used by policies.

Each SLA also defines working days and start and end times. A workday can include one break. Deadline and elapsed-time calculations skip non-working days, listed holidays, time outside working hours, and breaks. Updating a holiday list causes linked open tickets to recalculate their SLA state and targets, so calendar changes can move due dates without a ticket edit.

References: helpdesk/…/hd_service_holiday_list.py• L17-83 helpdesk/…/hd_service_holiday_list.py• L85-106 helpdesk/…/hd_service_level_agreement.py• L119-160 helpdesk/…/hd_service_level_agreement.py• L388-462 desk/…/HolidayView.vue• L120-169

The main relationship is:

flowchart LR
    Ticket[Ticket] --> Match[Match an SLA policy]
    Match --> Policy[SLA policy]
    Policy --> Priority[Priority target]
    Policy --> Hours[Working hours]
    Policy --> Calendar[Holiday calendar]
    Priority --> Deadline[Response and resolution deadlines]
    Hours --> Deadline
    Calendar --> Deadline
    Deadline --> State[Due, paused, fulfilled, or failed state]

References: helpdesk/…/utils.py• L12-52 helpdesk/…/hd_service_level_agreement.py• L209-386

Supporting backend extensions

The Helpdesk backend extends the framework’s assignment rule behavior instead of replacing the general rule model. It adds presence-aware user selection for standard rotation methods and keeps team-linked rules aligned with team membership. Ticket hooks also enforce the team boundary when a ticket’s team changes.

The backend owns SLA selection, target calculation, pause handling, and current agreement status. It validates that each SLA priority has the required targets and that workday breaks are complete and inside the workday. A scheduled refresh updates the status of open tickets that remain on an SLA, while ticket changes recalculate targets and completion data. The desk consumes this state for display; it does not decide whether a ticket has breached its service target.

References: helpdesk/hooks.py• L77-81 helpdesk/hooks.py• L124-127 helpdesk/…/hd_ticket.py• L984-1018 helpdesk/…/hd_ticket.py• L1538-1565 helpdesk/…/hd_service_level_agreement.py• L24-207 helpdesk/…/test_hd_service_level_agreement.py• L244-349

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the team member table and the linked assignment-rule user pool aligned, especially for weighted rules.
  • Keep team-generated assignment and unassignment conditions aligned with the team name, open-ticket scope, assignment days, and enabled state.
  • Preserve both structured and legacy condition fields when changing assignment-rule editing or validation.
  • Keep agent status categories, enabled-state validation, default availability, expiry timestamps, and live update payloads compatible.
  • Recheck queued status writes and expiry recovery when changing the desk presence store or the server status update path.
  • Recheck ticket team-change behavior when changing team visibility restrictions or assignment-rule lifecycle hooks.
  • Keep SLA priority targets, policy rank, date range, working-day windows, and holiday dates consistent with the ticket fields used for due dates and agreement status.
  • Preserve the distinction between a blank conditional policy and a default policy when changing SLA selection.
  • Recalculate linked open tickets when changing holiday-list contents or the SLA policy attached to that list.
  • Keep desk SLA labels aligned with backend states, including pause state and working-time delay fields.

Important failure modes

TriggerConsequenceGuard
A linked assignment rule contains a user who is not a team member.Routing and team ownership can disagree.The backend warns on rule validation; update the team and rule together.
A team has no agents or is disabled.Its linked rule cannot assign work.Add an agent and enable the team before expecting automatic routing.
All users in a rule are Away or Unavailable.The ticket can be assigned to a less suitable agent instead of waiting unassigned.Treat presence as a preference and review the fallback behavior before changing it.
The last enabled Active agent status is disabled or deleted.New agents have no valid default availability.Status validation blocks removal of the last enabled Active status.
A queued status write fails after a local update.The desk can show a status that the server did not save.Queue writes, reconcile server events, and restore the confirmed state on failure.
A temporary status expires while the browser is asleep.The agent can remain shown in the temporary state until the desk is seen again.Check expiry on visibility change and use the server event as the final state.
A holiday list changes while open tickets use its SLA.Due dates and agreement status can change after the calendar update.The holiday list recalculates linked open tickets.
An SLA has no matching priority or condition and is not the default.The ticket loses its SLA fields and has no SLA card in the desk.Keep supported priorities configured and use a suitable default only when fallback behavior is required.
A paused ticket is treated as resolved or active.Hold time and resolution targets become inaccurate.Use the ticket status category and recorded hold time when reading SLA state.
A workday break has only one boundary or falls outside the workday.SLA targets can use an invalid service window.SLA validation requires both break times and keeps them strictly inside the workday.

Key files

FileWhy to read it
helpdesk/…/hd_team.pyShows how teams create, sync, disable, rename, and remove their linked routing rule.
helpdesk/…/test_hd_team.pyShows the guarantees for team rule creation, condition updates, member sync, weights, and disablement.
helpdesk/…/hd_team.jsonShows the team controls for members, disablement, visibility restrictions, and the linked rule.
helpdesk/…/assignment_rule.pyShows the availability preference used during automatic assignment.
helpdesk/…/hd_agent.pyShows agent availability validation and live update behavior.
helpdesk/…/hd_ticket.pyShows team-bound assignment cleanup, SLA attachment, and ticket visibility rules.
helpdesk/…/utils.pyShows how an enabled policy is selected for a ticket.
helpdesk/…/hd_service_level_agreement.pyShows how policy validation, working time, holds, deadlines, and agreement status relate.
helpdesk/…/test_hd_service_level_agreement.pyShows the guarantees for policy fallback, policy changes, breaks, holidays, and hold time.
helpdesk/…/hd_service_holiday_list.pyShows holiday validation and recalculation of linked open tickets.
desk/…/agentStatus.tsShows how the desk keeps agent presence, expiry, live events, and queued writes current across sessions.
desk/src/components/Settings/Assignment Rules/AssignmentRuleView.vueShows the desk model for conditions, schedules, methods, and user pools.
desk/…/TeamEdit.vueShows how operators manage team members, restrictions, and the linked rule.
desk/…/useSLA.tsShows how backend SLA fields become concise desk states and labels.
desk/…/HolidayView.vueShows how operators maintain the calendar that drives SLA time.