To implement the round-robin assignment algorithm, I've employed two queues: one for storing all available agents and another for storing unassigned tickets.
- When a new agent registers on our platform, we save their details in the database.
- We add the agent to the agent queue since they are currently available for handling tickets.
- When a user creates a support ticket, we check if there's an available agent in the queue.
- If an agent is available, we assign the ticket to that agent and remove them from the queue.
- If no agent is available, we place the upcoming ticket in the support tickets queue.
- Every 40 seconds, a cron job checks the availability of agents in the agent queue and any pending tickets in the support ticket queue.
- If an agent and a ticket are both available, we assign the ticket to the agent and remove both from the queues.
- If a ticket is resolved, the agent can use an API to mark the ticket as resolved by specifying their ID and the ticket ID.
- We update the statuses of both the ticket and the agent.
- The agent is then added back to the agent queue since they are now available for handling new tickets.
- A GET request retrieves all details of sorted, filtered, and paginated support ticket data.
$ git clone https://github.com/prabhpreet-code/Support-Ticket-Management-System.git
$ cd Server
$ npm install
Open MongoDB Compass and create & update .env
$ nodemon server.js
$ cd Client
$ npm install
$ npm run dev
This flow ensures efficient handling of support tickets by dynamically assigning them to available agents and maintaining a streamlined process for agent availability and ticket resolution.