Hey guys, I fixed this old plugin I found called osticket-spreader by berezuev.I am able to round-robin auto-assign tickets to my agents.I was wondering if there was anyone savvy with PHP who could help me deduce some things about this plugin's code.I'm trying to figure out, where it stores the selected "Agents" to auto-assign.What im trying to do, is create a PHP script that runs on a cronjob (task-scheduler), which deselects certain agents and selects other agents, this way I can automate times for when agents come into work and leave work.I'm not the most literate PHP coder, but I'm doing my best. Just needed help figuring out where this script stores your "Agent" selection.You can find it here on Github: https://github.com/berezuev/osticket-spreaderAlso, if you want this functioning and running on your osTicket 1.10.1, simply modify the code in spreader.php on line 25 from "model.created." to "ticket.created", and the auto-assignment should function just fine with no errors.

7 months later

Anybody know if this is possible yet? I would love to be able to auto-assign tickets to certain teams based on time of day.

At the very least could you send this requeset to the devs as an idea?

can you email me [neil at osticket dot com] the mod with your changes? And I can try to take a look. As a side note my job is keeping me busy today so I doubt that I will get to it today.

I believe that this feature is already on the feature request doc I made for the devs.

    ntozier

    Here's the github link with my corrections to the guy's code.

    He incorporated my changes, it works on version 1.9 and 1.10.X, I ran it on 1.9 and am currently running it on 1.10.4 with no issues.

    It unfortunately is broken on your newest version 1.11; can't get it to work there.

    Here's the link: https://github.com/berezuev/osticket-spreader

    I don't know if it easier to modify this code or to build one from the ground up. My company basically was looking for a way to break up auto-assignment of tickets into hourly-blocks. We have different helpdesk employees that come in at different shifts, and wanted to have the ticketing system assign to the respective teams/agents based on their hours.

    E.g. 6AM-9AM } Assign to Team A
    9AM - 11AM } Assign to Team B etc.

    Was hoping someone already had a mod out there that sorta did this, or was easily modifiable.

    Oh so since I can't get the mod to work, I've decided to jury-rig this using php to change the auto-assignment database value for help topics.

    Basically, a ticket comes in, it by default gets the help-topic "report a problem". Under the help-topic "report a problem" you can set auto-assignment.

    Ok groovy, so I thought, I could create a PHP script that runs on cron and changes the value of the 'auto-assign to' value to the team/agent I want to assign tickets to at the time the cron runs.

    Looked up where the value resides in the database and I'm confident it is located here, under the table "ost_help_topic".

    Ok, so good so far.

    Here is my code:

    <?php
    $servername = "localhost";
    $username = "myusername";
    $password = "mypassword";
    $dbname = "mydatabase";
    
    //Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    //Check connection
    if($conn->connect_error) {
            die("Connection failed:" . $conn->connect_error);
    }
    
    $sql = "UPDATE ost_help_topic SET team_id='7' WHERE topic_id=10";
    
    if (mysqli_query($conn, $sql)) {
            echo "Record updated successfully";
    } else {
            echo "Error updating record: " . mysqli_error($conn);
    }
    
    mysqli_close($conn);
    ?>
    

    I run the code and check the "team_id" value in the database, and lo and behold it has indeed been changed and updated.

    HOWEVER, when I go back to the Help-Topic page on osTicket the changes are not reflected there. The value is still left on the previous one, e.g. "Devs", even though I know that team has a different ID in the database.

    I tested created a ticket and seeing where the system auto-assigns and it still auto-assigns it to "Devs" even though my PHP code changes the value to another team, "Team A" in this example. And I see that the value in the database is the value for Team A.

    What am I missing here?

    Nevermind, obviously I was missing something, this method actually works flawlessly.

    You could then setup a cronjob to run whenever you want to assign a new team.

    So for example, you could create multiple versions of the same PHP script, and simply change the

    team_id='x'

    to suit your needs per each script.

    So for example have script 1 have the value 1 for team_id and have it run at 6AM on a cronjob, and now team 1 will be auto-assigned tickets.

    Have script 2 have the value 2 for team_id and have it run at 8AM on a cronjob and now team 2 will be auto-assigned tickets.

    So on and so forth. You'll just need to check in your database to see what IDs your teams have and then make the respective changes to the code.

    Pretty simple. Sorta an ugly jury-rigged way to do it, but it works and gets the job done how I needed it.

    Hope this helps someone else. Can be marked as closed.

    Write a Reply...