Ticket Auto Assign Process
This document is intended to describe the technical implementation of ticket auto-assign process that has been developed by the following story: https://commengine.atlassian.net/browse/CE-1093
Details of Auto Assign Process:
UI validation:
Whenever a user logged in to the system, it automatically set a timer that will check and validate the auto-assign process is to be started or not. The system will retrieve the auto-assign interval from the settings and check the difference between the current time and last assign time. If the current time reached the interval, the system will send a request to the server and the auto-assign process will start.
Back-end API process:
The entire auto-assign process workflow as below:
While UI sends requests to the server, system checks logged in users and validate interval time with last assign time. If the difference between the current time and the last assign time>= interval, it returns true otherwise, it stops the process. Last assign time is stored on global cache for the validation of the next interval
If the system passes the validation, it calculates the total handling capacity for all active users for the current interval only.
After that, the system invokes Facebook graph API for retrieving inbox conversations and feed (regular posts, visitor posts, recommendations, and ad posts) comments and filter according to the input criteria to search assignable ticket data.
After generating ticket data according to the calculated total handling capacity, the system distributes the tickets to all logged-in users with the round-robin method.
Then, the system invoked the stored Procedure ‘CreateBulkTickets’ to insert all the generated data at a time.
After inserting, system notifies users about the new assignment and
Finally, the system refreshes the inbox and feed streams.
Generating Ticket Data for Inbox and Feed
Ticket data generation process divided by two steps:
Generating Inbox Ticket Data
Generating Feed Ticket Data
Generating Inbox Ticket Data
Inbox ticket data are generated by the following steps:
Inbox conversations are retrieves by invoking Facebook conversations API with the given time frame.
After retrieving conversations data, it checks the conversations are already ticket or not.
If any item found as a ticket, remove it from the data list.
After preparing the filtered data, system checks the handling capacity again. If ticket data is less then total handing capacity, system again revokes the method recursively followed by the step 1 to 4.
Once ticket data count is equal to total handling capacity or reaches the date filter criteria, it stops invoking API calling and prepare the object for ticket input DTO.
Generating Feed Ticket Data
Feed ticket data are generated by the following steps:
The system runs an iteration over an array of 4 feed types such as [NewsFeed, AdPost, VisitorPost, Rating]
For each type, system invokes Facebook graph API with the given time frame and fetch comments and replies of page posts.
After retrieving posts data, it checks the comments and replies are already ticket or not.
If any item found as a ticket, remove it from the data list.
After preparing the filtered data, system checks the total feed handling capacity again. If ticket data is less then total feed handing capacity, system again revokes the method recursively followed by the step 1 to 4.
Once ticket data count is equal to total handling capacity or reaches the date filter criteria, it stops invoking API calling and prepare an object for ticket input DTO.
Distribution of tickets to logged-in users
Tickets will be distributed with the following thumb rule:
The ticket should be distributed equally
The ticket should be distributed as per individual handling capacity
Distribution mechanism can be understood by the following case studies:
Case Study 01:
For example: Logged-in users: 2
User 1: Handling capacity: 80
User 2: Handling capacity: 20
If total handling capacity is 100 and ticket count is 50, then average capacity will be 25 per each user.
- User 1 will get the 25 tickets and User 2 will get 20 tickets at the first iteration.
- Remaining 5 tickets will be distributed to the user 1 at the second iteration.
Case Study 02:
For example: Logged-in users: 2
User 1: Handling capacity: 20
User 2: Handling capacity: 80
If total handling capacity is 100 and ticket count is 50, then average capacity will be 25 per each user.
- User 1 will get the 20 tickets and User 2 will get 25 tickets at the first iteration.
- Remaining 5 tickets will be distributed to the user 2 at the second iteration.
Case Study 03:
For example: Logged-in users: 2
User 1: Handling capacity: 50
User 2: Handling capacity: 50
If total handling capacity is 100 and ticket count is 50, then average capacity is 25 per each user.
- User 1 will get the 25 tickets and User 2 will get 25 tickets at the first iteration.
Case Study 04:
For example: Logged-in users: 3
User 1: Handling capacity: 20
User 2: Handling capacity: 30
User 3: Handling capacity: 50
If total handling capacity is 100 and ticket count is 100, then average capacity is 33 per user.
- User 1 will get the 20 tickets, User 2 will get 30 tickets and User 3 will get 33 tickets at the first iteration.
- Remaining 17 tickets will be distributed to the user 3 at the second iteration.
Above case studies have been covered by the following validations:
Run an iteration over the logged in users, and
Calculate average distribution capacity per logged-in user (say: AvgCapacityPerUser)
Calculate current distributed ticket per user (say: currentDistributedTickets)
Calculate ticket handling capacity per user/interval (say: handlingCapacity)
If currentDistributedTickets>= handlingCapacity , set handlingCapacity value to ‘0’
handlingCapacity value ‘0’ means stop distribution for the user
6. If AvgCapacityPerUser>0 and AvgCapacityPerUser<handlingCapacity, then distribute tickets as per AvgCapacityPerUser
7. If AvgCapacityPerUser>0 and AvgCapacityPerUser>handlingCapacity, then distribute tickets as per handlingCapacity
8. After ending the iteration, if any ticket remains to be distributed, run recursive iteration from step 1 to 8 again.
These validation conditions are applied for both inbox and feed tickets distribution.
Note:
Equal distribution may differ according to the handling capacity per individual user and if assignable tickets count is odd.
The client browser sets a 5 min timer that checks and validates auto-assign interval. This timer will be reset and will start from the beginning of the user refreshes the browser. This means that if the user refreshes the browser just before the auto-assign process getting ready to start, it may delay max 5 min to start the process again.