Skip to content

Agent & Assignment

@nx/helpdesk manages the support agent team with a dual assignment system: manual assignment via the API and auto-assignment via AutoAssignTicketUseCase running on a BullMQ worker.

Data Model

Agent

ColumnTypeDescription
idbigintSnowflake ID
merchantIdbigintTenant scope
userIdbigintUnique link to a User in @nx/identity
statusenumONLINE / AWAY / OFFLINE / BUSY
isAvailablebooleanWhether the agent accepts new tickets
skillsvarchar[]Skills (e.g. ['billing', 'technical'])
languagesvarchar[]Supported languages (default ['vi'])
maxConcurrentTicketssmallintConcurrent ticket cap (default 10)
currentTicketCountintNumber of currently active tickets
averageResponseTimeintAverage first-response time (minutes)
averageResolutionTimeintAverage resolution time (minutes)
slaComplianceRatedecimalSLA compliance rate (0.0 − 1.0)
customerSatisfactionScoredecimalCSAT score
schedulejsonbWorking schedule (hours/days off)

AgentGroup

Groups of agents organized by department or skill set.

ColumnTypeDescription
idbigintSnowflake ID
merchantIdbigintTenant scope
namejsonbGroup name (i18n: {en, vi})
descriptionjsonbGroup description
isActivebooleanActive flag

AgentGroupMember

Junction table linking AgentAgentGroup.

REST API

Agents (/agents), agent groups (/agent-groups), and assignment rules (/assignment-rules) — full endpoint reference rendered live from /v1/api/helpdesk/doc/openapi.json. Endpoint tables are intentionally not hand-maintained.

Use Cases

Agent

Use CaseDescription
CreateAgentUseCaseCreate agent, link to userId
UpdateAgentUseCaseUpdate skills, status, schedule
DeleteAgentUseCaseSoft-delete agent
GetAgentByIdUseCaseGet details by ID
GetAgentByUserIdUseCaseGet agent by userId
ListAgentsUseCasePaginated agent list
GetAgentTicketsUseCaseFetch tickets by agent

Auto-Assignment

Use CaseDescription
AutoAssignTicketUseCaseOrchestrates finding the best available agent
FindBestAgentUseCaseSelects agent by skills + lowest workload
FindSeniorAgentUseCaseFinds a senior agent for escalations

Auto-Assignment Flow

Agent Selection Criteria (FindBestAgentUseCase)

  1. isAvailable = true and status != OFFLINE/BUSY
  2. currentTicketCount < maxConcurrentTickets — not overloaded
  3. Skill match against ticket.category required skills (when applicable)
  4. Lowest currentTicketCount among eligible agents — load balancing

AssignmentRule

Configurable rules that override the default assignment logic:

CriterionDescription
categoryIdApply only to a specific ticket category
priorityTicket priority level
keywordsKeywords in subject/description
targetAgentIdAssign directly to a specific agent
targetGroupIdAssign to an agent group
WorkerQueueFunction
assignment.workerhelpdesk.assignmentRuns AutoAssignTicketUseCase
escalation.workerhelpdesk.escalationRuns FindSeniorAgentUseCase on Level 2+ SLA breach

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