Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

auto-assign a ticket without assigning it in the help topic

How do I auto-assign a ticket to a single user on the computer to attend a request without assigning it in the help topic ?.

For example, I have 5 people in support in 1 team, but I want the tickets to be assigned to one person, while that person attends a ticket, another person is automatically assigned the next and so on, until he reassigns the first one.

Comments

  • So what you are after is to load balance the ticket assignments?
    Interesting idea actually, maybe it could be done on a team basis?

    There is no built in such feature but i don't think it should be so difficult to make.
  • There was a mod posted last year that does this.  I would check the mods section.  It may need updating as I think that it might have been for 1.9.  
  • Exactly Micke1101 , it would be a load balance of the ticket assignments.
  • ntozier , Can you help me locate it if it exists? And how do you install a mod?
  • Q: Can you help me locate it if it exists?
    A: You would have to search for it.  I would google: "osticket round robin assignment" an see what comes up.

    Q: And how do you install a mod?
    A: You make the edits listed in the mod to your files, or over write the files with the supplied files.  Depends on who wrote the mod and how invasive it is.
  • I think that unfortunately I will have to change helpdesk because this option is necessary for me :(
  • @luchospace I looked into how this could be done and it looks like a small modification (a little more if you want to make it more efficient but not a great deal)

    Could you outline the exact conditions?
    Consider vacation setting?
    Will it be the one with the least amount of tickets assigned to them that are open?
    Should it be toggable?
    On a team basis?
    Systemwide?
    Any other things that needs to be considered?
  • Could you outline the exact conditions? Support load of (x) agents in an environment where we all do the same tasks
    Consider vacation setting? yes and the work schedule of a daily agent or schedule rotation, depends on how complex
    Will it be the one with the least amount of tickets assigned to them that are open? Yes, the one that is available or has the least number of assignments
    Should it be toggable?
    On a team basis? Can be a team to have it more orderly, I think
    Systemwide? Of course, the work must be divided among the members of the same group
    Any other things that need to be considered?
  • edited June 7
    Try this

                //Auto assignment.
                if (!isset($vars['staffId']) && $topic->getStaffId())
                    $vars['staffId'] = $topic->getStaffId();
                elseif (!isset($vars['teamId']) && $topic->getTeamId() && $team = Team::lookup($topic->getTeamId())){
    $staffStat = null;
    $staffToAssignTo = null;
    foreach ($team->getMembers() as $staff) {
    $temp = Ticket::getStaffStats($staff)['open'];
    if(!$staff->onVacation() && $staff->isactive() && (!$staffStat || $staffStat > $temp)){
    $staffStat = $temp;
    $staffToAssignTo = $staff;
    }
    }
    if($staffToAssignTo)
    $vars['staffId'] = $staffToAssignTo->getId();
    }
  • @luchospace this is not the best way to do it, you could probably make a orm query to find out which one has the least tickets assigned to them and you could then get rid of a couple of checks here, but this is a quick test of concept.

    So on your topic assign the team with the people that you want to load balance on.
  • Berezuev wrote a plugin for this: https://github.com/berezuev/osticket-spreader

    Could be good
  • Looks good indeed, but it doesn't seem to take into consideration teams, vacation or if the staff is even still active.

    It seems to distribute it on all staff members that exist.

    A common thing that I've seen so far in the existing ones is that they insist on keeping count on who was the staff member that last got a ticket assigned to them.
    I'm not sure that is the proper way but I could be wrong.
  • I also thought about a different approach that could be more appropriate.
    One could have a cron job that checks if there is a ticket that is not assigned to anyone in the team and if there's a staff member with no tickets, then it'll assign the ticket to that staff member.

    This way staff won't work on multiple tickets at once and it would act more like a true loadbalancer.
  • Forgive me for asking the obvious question, why not just let the agents manually claim the next ticket after they finish one? Low-tech, but it seems to works well for most places. 

  • We should not wait for a boss to assign them or an agent to choose manually, personally this missing option super needed to this Helpdesk.

    Micke1101 I will use your code, I hope it works without problems and thank you very much for your support
  • Hello Micke1101 , I entered your code but I'm having problems with the assignments since now it is only assigned to a person.
  • Hello Micke1101 , I entered your code but I'm having problems with the assignments since now it is only assigned to a person. 

    In other words, he does not go to the next agent and always stays in one.
  • @luchospace, try this instead then.

    Should be converted into ORM, but should work for now.

    //Auto assignment.
                if (!isset($vars['staffId']) && $topic->getStaffId())
                    $vars['staffId'] = $topic->getStaffId();
                elseif (!isset($vars['teamId']) && $topic->getTeamId()){
                    $sql='SELECT A1.`staff_id` FROM 
                    (SELECT `staff_id` FROM `ost_team_member` WHERE `team_id` = 1 AND `staff_id` > 0) A1
                    LEFT JOIN 
                    (SELECT `staff_id`, COUNT(*) AS `count` FROM `ost_ticket` WHERE `status_id` = 1 GROUP BY `staff_id`) A2
                    ON A1.`staff_id` = A2.`staff_id`
                    ORDER BY A2.`count` ASC 
                    LIMIT 1';

                    if(($res=db_query($sql)) && db_num_rows($res))
                        while($row=db_fetch_row($res))
                            $vars['staffId'] = $row[0];
                }
  • edited June 20
    How do I convert it to ORM?

    I'm already testing your updated code, hope it works now.

    Thank you Micke1101 
  • Error DB Error #1146


    [SELECT A1.`staff_id` FROM

                   
    (SELECT `staff_id` FROM `ost_team_member` WHERE `team_id` = 1 AND
    `staff_id` > 0) A1

                   
    LEFT JOIN

                   
    (SELECT `staff_id`, COUNT(*) AS `count` FROM `ost_ticket` WHERE
    `status_id` = 1 GROUP BY `staff_id`) A2

                    ON
    A1.`staff_id` = A2.`staff_id`

                   
    ORDER BY A2.`count` ASC

                   
    LIMIT 1]

     

    Table 'tickets.ost_team_member' doesn't exist<br />
    <br />

    ---- Recular ----<br />

    #0 (raíz)/include/mysqli.php(177):
    osTicket->logDBError('DB Error #1146', '[SELECT A1.`sta...')<br />

    #1 (raíz)/include/class.ticket.php(2783):
    db_query('SELECT A1.`staf...')<br />

    #2 (raíz)/open.php(42): Ticket::create(Array, Array,
    'Web')<br />

    #3 {main}

  • Looks like you changed the default table prefix, just change ost_ to what you set as the default table prefix.

    Or you could replace the tables with the variables.
    ...'ost_team_member'... -> ...'.TEAM_MEMBER_TABLE.'...
    ...'ost_ticket'...->...'.TICKET_TABLE.'...
  • edited June 21
    yes Micke1101, change the prefix and fix the problem.

    Now the other problem that I am having is that if I solve a ticket or the close, reassign me another ticket and is not assigned to the next agent. If I have a ticket without closing then I assign the next agent.

    Is there any adjustment to the code to run balanced? In this way there are agents who will be very difficult to be assigned and will be without a ticket.

    Thanks again Micke1101 
  • The problem is that the results are ordered by your id in the database and i think remembering who got a ticket last will be a bit of a strain, i may be able to look at it later but for now you can try and edit this line
    ORDER BY A2.`count` ASC

    ORDER BY A2.`count` ASC, RAND()
  • @luchospace

    Ok i think this is what you're looking for

    Now the first criteria will be to have the lowest amount of tickets, but if 2+ agents have the same amount of tickets it will be the one that have waited for a ticket the longest that gets it.

    //Auto assignment.
                if (!isset($vars['staffId']) && $topic->getStaffId())
                    $vars['staffId'] = $topic->getStaffId();
                elseif (!isset($vars['teamId']) && $topic->getTeamId()){
                    $sql='SELECT A1.`staff_id` FROM 
                    (SELECT `staff_id` FROM '.TEAM_MEMBER_TABLE.' WHERE `team_id` = 1 AND `staff_id` > 0) A1
                    LEFT JOIN 
                    (SELECT `staff_id`, COUNT(*) AS `count` FROM '.TICKET_TABLE.' WHERE `status_id` = 1 GROUP BY `staff_id`) A2
                    ON A1.`staff_id` = A2.`staff_id`
                    LEFT JOIN
                    (SELECT `staff_id`, MAX(`timestamp`) AS `timestamp` FROM '.THREAD_EVENT_TABLE.' WHERE `state` = \'assigned\' GROUP BY `staff_id`) A3
                    ON A1.`staff_id` = A3.`staff_id`
                    ORDER BY A2.`count` ASC, A3.`timestamp` DESC
                    LIMIT 1';

                    if(($res=db_query($sql)) && db_num_rows($res))
                        while($row=db_fetch_row($res))
                            $vars['staffId'] = $row[0];
                }
Sign In or Register to comment.