Skip to content

SLA & Escalation

The SLA system in @nx/helpdesk tracks two deadlines per ticket: first response time and resolution time. When thresholds are crossed, BullMQ workers automatically escalate and dispatch notifications.

Default SLA Levels

PriorityCodeResponseResolution
Low10024 hours72 hours
Normal2008 hours24 hours
High3004 hours12 hours
Urgent4001 hour4 hours

Data Model

SlaPolicy

ColumnTypeDescription
idbigintSnowflake ID
namejsonbPolicy name (i18n: {en, vi})
prioritysmallintPriority level (100/200/300/400)
responseTimeMinutesintAllowed response time (minutes)
resolutionTimeMinutesintAllowed resolution time (minutes)
warningThresholdPercentsmallintWarning threshold (default 75%)
criticalThresholdPercentsmallintCritical threshold (default 90%)
escalationRulesjsonb[]Auto-escalation rule definitions
businessHoursOnlybooleanCount only within business hours
isActivebooleanWhether the policy is in effect

SlaTracker

Tracks SLA progress per ticket:

ColumnTypeDescription
ticketIdbigintFK → Ticket
slaPolicyIdbigintFK → SlaPolicy
responseDeadlinetimestampResponse deadline from ticket creation
resolutionDeadlinetimestampResolution deadline
firstResponseAttimestampActual first response timestamp
resolvedAttimestampActual resolution timestamp
firstResponseStatus / resolutionStatusenumOK / WARNING / BREACHED (SlaStatuses)
warningTriggeredAttimestampWhen the warning was sent
breachTriggeredAttimestampWhen the breach was recorded

SlaEscalation

History of escalation events:

ColumnTypeDescription
ticketIdbigintFK → Ticket
levelsmallintEscalation level (1/2/3)
reasontextReason for escalation
escalatedAttimestampEscalation timestamp
handledBybigintAgent who handled the escalation

SLA Breach Flow (End-to-End)

Auto-Applied SLA Tags

TagConditionDescription
SLA_BREACHEDExceeds 100% of deadlineSLA violated
OVERDUEDeadline has passedPast resolution deadline
CRITICAL_BREACHExceeds 150% of deadlineCritical violation, triggers re-assignment

REST API

SLA policies are served under /sla-policies (RestPaths.SLA) by SlaController — full endpoint reference rendered live from /v1/api/helpdesk/doc/openapi.json. Endpoint tables are intentionally not hand-maintained.

SLA Use Cases

Use CaseDescription
CreateSlaPolicyUseCaseCreate a new SLA policy
UpdateSlaPolicyUseCaseUpdate SLA parameters
DeleteSlaPolicyUseCaseRemove a policy
GetSlaPolicyByIdUseCaseGet policy details
ListSlaPoliciesUseCaseList all policies
InitializeSlaTrackerUseCaseCreate tracker when ticket is created
MarkFirstResponseUseCaseRecord the first agent response
MarkResolvedUseCaseRecord ticket resolution
CalculateBatchSlaStatusUseCaseBatch-calculate SLA statuses
BulkMarkSlaWarningUseCaseBulk-apply warning flags
BulkMarkSlaBreachedUseCaseBulk-apply breach flags
TriggerSlaCheckUseCaseManually trigger a check
ProcessEscalationUseCaseProcess a single escalation event
RunSlaMonitorUseCaseExecute one SLA monitor scan pass

Workers

WorkerQueueFrequencyFunction
sla-monitor.workerhelpdesk.sla-monitorCron (1 min)Scans trackers approaching or past deadline
escalation.workerhelpdesk.escalationDelayed jobHandles Level 2 and Level 3 escalation

Reassignment to a senior agent on Level 2+ is currently disabled in code (notification only). See Operations → Known Issues.

Compensation (CompensationCalculatorService)

When an SLA breach occurs, compensation is calculated against a matrix:

CriterionDescription
Customer tierVIP / PREMIUM / STANDARD
Ticket priorityLOW / NORMAL / HIGH / URGENT
Breach durationTime elapsed past the deadline
Escalation levelOnly triggers from Level 2 onward

Results are persisted to the Compensation table for offline processing.

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.