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

[MOD] Staff Reply to Tickets (IMAP)

135

Comments

  • are you adding it to the subject of the email?
  • Tried both the subject and body

    Yes, I have added it to both the subject and the body of the email.

    The thread says it can go in both areas.

    So frustrated. This is the coolest Mod.

    Thanks for replying, let me know if you have any other thoughts.

    Kindly,

    Webb
  • are you seeing the tickets being added to osticket as new tickets, or added to the original?
  • Hi Webb,

    Sorry to hear you are having issues with the mod.
    Do you have any other mods in place? The reason I ask is there was another user who had an issue due to a conflict between this mod and another.

    Also just wanted to confirm you are replying with the #actions from the staff account? At present these are not available accepted from the requester (that may not have been clear in the readme).

    Let me know how you get on.

    Jemson
  • Thank you for the reply

    Hello,

    I listed my biggest "mod" which is really just the Responsive template. I wanted to do the html email mod, but fortunately I haven't yet. So this ought to be clean.

    Now that you point out the email must be sent from the Staff, I think that may be the issue. Let me have a Staff or Admin send the message and see what happens.

    I'm fairly certain that's the issue. I'm feeling very optimistic.

    Regards,

    Webb
  • Apologies for the confusion on that.

    I had made these functions available to staff only as majority of the time the requester A) wouldn't know they were possible and B) if they did, shouldn't have the ability to choose which staff member the ticket is assigned to, make internal notes etc.

    If you are still having issues after testing with a staff member's reply please let me know and I will be happy to look into it further for you.
  • Big thank you to Jemson for this great mod! ;)

    Maybe a good improvement would be to remove the commands from the agent reply before adding it to the ticket. I don't want customers to see the commands :(
  • Jemson;39252 said:
    Please see below latest update.

    - Added a reply separator to outgoing emails to staff (ticket message updates)
    - Added the strip function on the incoming mail from staff to remove the text below the separator.
    - Included the ability to insert "#close" into email subject to close a ticket.
    By the way... I'm receiving the staff emails without the reply separator, so the quote of the email received is included in the new reply :(

    Also I think I found a bug...

    When you close the ticket using the #close command, no information about who closed the ticket is stored, i.e.
    tickets shows this:
    Closed By: — Unknown —
    It should say the name of the staff person who closed the ticket (like happens when you do from SCP).
  • Hi n0user!

    Thanks for the acknowledgement and constructive feedback.

    Are you running 1.7ST? The reason I ask is I am unable to replicate either of the two issues you described.

    The below lines in class.ticket.php take care of the adding of the reply separator so as long as you have it on globally in the config under Admin Panel->Settings->Email, it should work.
    <             if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
    < $msg['body'] =\"\n$tag\n\n\".$msg['body'];


    Also with the "Closed By" component I correctly get an internal note entered with the date, subject of "Email Action", Submitting user, and a note of "Ticket has been closed via email."


    Just back tracking to your previous suggestion of removing the #actions from the reply, I do quite like that idea. I had not thought of stripping them out of the reply and had really only considered "Send/Don't send reply" if there was a #action. Will be pretty easy to implement that feature and will look to add it in the next few days.

    Thanks again, and let me know any other info you have on the two bugs reported.
  • Jemson;41885 said:
    Hi n0user!

    Thanks for the acknowledgement and constructive feedback.

    Are you running 1.7ST? The reason I ask is I am unable to replicate either of the two issues you described.
    Thanks to you for giving us this great mod! ;)

    Yes I'm running 1.7 without any mods, only yours.

    I get the reply separator in the customer side emails, but not in alerts for the staff (currently only using the admin user).
    Jemson;41885 said:

    The below lines in class.ticket.php take care of the adding of the reply separator so as long as you have it on globally in the config under Admin Panel->Settings->Email, it should work.
    <             if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
    < $msg['body'] =\"\n$tag\n\n\".$msg['body'];

    Well I think that is just the problem. That code is in the auto-reply part, that email goes to customer not to staff.

    In fact, that part is exactly the same in the original class.ticket.php file (without your mod). Maybe you forgot to add that to the staff part in the last update to the mod?

    I added it to the staff part and now it works :) This is how it looks

            //Send alert to out sleepy & idle staff.
    if($alertstaff && $email
    && $cfg->alertONNewTicket()
    && ($msg=$tpl->getNewTicketAlertMsgTemplate())) {

    $msg = $this->replaceVars($msg, array('message' => $message));

    [COLOR=\"Red\"] // Include reply separator for using below for admin and staff
    if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
    $msg['body'] =\"\n$tag\n\n\".$msg['body'];[/COLOR]

    $recipients=$sentlist=array();
    //Alert admin??
    if($cfg->alertAdminONNewTicket()) {

    $alert = str_replace('%{recipient}', 'Admin', $msg['body']);
    $email->sendAlert($cfg->getAdminEmail(), $msg['subj'], $alert);
    $sentlist[]=$cfg->getAdminEmail();
    }

    Also with the "Closed By" component I correctly get an internal note entered with the date, subject of "Email Action", Submitting user, and a note of "Ticket has been closed via email."
    Yes, I get that note too. And my name is in it. But that it's in the ticket thread. I'm talking about the top part of the ticket, where you can see all general information for the ticket. The "Closed By:" field just on top of the "SLA Plan:"
    Just back tracking to your previous suggestion of removing the #actions from the reply, I do quite like that idea. I had not thought of stripping them out of the reply and had really only considered "Send/Don't send reply" if there was a #action. Will be pretty easy to implement that feature and will look to add it in the next few days.
    I think it'll be pretty easy to remove the commands, just filtering the content with str_replace function maybe?
  • I have to agree on the removing commands from the email, it is something I was meant to bring up as a suggestion before but then I completely forgot about it xD

    Also not sure if you saw my previous suggestion or not as it received no response:
    Would it be possible for email commands to be recognised in initial ticket creation emails?

    A lot of the time we will create tickets ourselves via email after we've received a phone call or have something to do in the office, so it would be pretty handy if it could detect we are staff and allow us to do #claim, #close (if the incident was resolved instantly over the phone), etc. in the initial email.
  • About removing the commands, I did a simple test for removing the command #internal from email body. It worked as expected.

    Below in red color is the modified code to allow removing the #internal command from the response just before this is inserted as a note in the ticket.

            //Check if tagged as internal and post as a note instead.
    if(($vars['subject'] && preg_match (\"/#internal/\", $vars['subject'], $action)) OR ($vars['response'] && preg_match (\"/#internal/\", $vars['response'], $action))) {

    [COLOR=\"Red\"] // Remove command before inserting the note into the system
    $vars['note'] = preg_replace(\"/#internal/\", '', $vars['response']);[/COLOR]
    if(!($response=$this->getThread()->addNote($vars, $errors)))
    return null;


    Maybe the most easy will be to create a separate function with the appropiate code to filter out all commands, and then call it from every place it needs to filter commands (must be always the last previous step to insert the data in the system).

    What do you think Jemson?
  • Hi all,

    Sorry for taking so long to reply, have been extremely busy of late and have been migrating my companies hosted environment to a new platform (meaning I haven't had my build platform to play with).

    n0user;
    I did some testing though on my environment with the staff reply separator before the move and didn't have any issues. That said I have made a bunch of changes to mine for the new CC mod I am working on, so it is entirely possible I left it out of the posted 4.1 mod and readded it in my other adaptations. I will check it out again once my systems have migrated though.

    preg_replace will work as you have posted below, but I think it might be cleaner to use str_replace and throw all the #actions into an array.


    Pawned;
    Sorry I didn't respond to your earlier question, I looked back and I think I missed it as it was the last response on page 6 and I jumped forward to page 7 on next login. Anyway, that certainly should be possible, and I do quite like the idea. The ticket creation happens in a separate include to the rest of the adaptations, so as n0user suggested it may now make sense to create a function around the actions so it can be called from either location.
    I should be able to look at this and at least figure out how best to implement in the next few days.


    Also as mentioned above I am also writing a mod for the ability to CC other emails, and automatically add any email addresses the requester CCs to the list. It's about 95% complete but I am in two minds about whether to incorporate this into this mod or run it as a separate mod. I am leaning toward integrating the two together but would be interested in your thoughts?

    Lastly, I will be travelling overseas for the next month from this coming weekend, so please don't be offended if I don't respond to any questions or feedback over this time :) I will see what I can get done over the next couple of days in relation to the few tweaks above, but I won't be able to complete the CC component until after I return.

    Thanks again for the support.
  • n0user,

    I finally got my build environment back today and did a fresh install of OS ticket on a brand new Centos host then copied over the two php files as attached in patch 4.1

    I claimed the ticket and sent an update in as the requester. I received the update via email on the account assoicated with the staff user and the reply separator was in place. I then responded to the email with #close in the body and the ticket closed successfully and correctly displayed the "Closed By: " in the ticket summary. I have also check my (CC) modified files from my original build system and there are no differences in the functions relevant to the reply.

    Based on this I am convinced there is some issue with your build or install. My original build system was an ubuntu build and I have today rebuilt on centos and in both cases have had no issues such as you have reported. Did you install via git clone, or downloading and extracting the zip? (Not that it should matter, but I downloaded the zip in both cases). Also are you modifying the original files or installing mine over the top?
  • Jemson;42026 said:
    n0user,
    Based on this I am convinced there is some issue with your build or install. My original build system was an ubuntu build and I have today rebuilt on centos and in both cases have had no issues such as you have reported. Did you install via git clone, or downloading and extracting the zip? (Not that it should matter, but I downloaded the zip in both cases). Also are you modifying the original files or installing mine over the top?
    I did a fresh install of OS Ticket downloading the zip file, and simply copy your files over this installation.

    No other mods applied.

    So I don't know what may happen... :confused:

    By the way, +1 to adding attachments to emails (both from clients and staff). I think that would be very useful, specially for me because I'm using OS Ticket as an email only support helpdesk (so my customers simply don't know where the install is, and anyway I have the web access closed to them).
  • Jemson,
    Thanks you for this mod!
    I'd like to leave some suggestions:
    If use 2 or more depts alerts recieve to staff only from one alert e-mail address, but clients recieve e-mails from dept e-mail address.
    Need that staff recieve alerts from dept e-mail adress and can answer to this address.
  • @noUser - code worked for me for stripping out #internal out of the internal note.

    Now I just need something to strip ALL #actions out of $msg['body'] before it sends to the user :)
  • In response to my last post,

    I have effectively stripped out #assign from the email to users and what gets posted in osticket...

    (only stripping out #assign here - I only have released #assign and #internal to staff and I used n0user's method for #internal)

    In class.ticket.php - I replaced:

    $email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments);


    with:
    $msg['body'] =  preg_replace(\"/#assign:.([^\s]+)/\", '', $msg['body']);
    $email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments);


    and this:
            if(($vars['subject'] && preg_match (\"/#internal/\", $vars['subject'], $action)) OR ($vars['response'] && preg_match (\"/#internal/\", $vars['response'], $action))) {
    $vars['note'] = preg_replace(\"/#internal/\", '', $vars['response']);
    $vars['title'] = 'Ticket Updated via email';
    if(!($response=$this->getThread()->addNote($vars, $errors)))
    return null;

    } else {

    if(!($response = $this->getThread()->addResponse($vars, $errors)))
    return null;
    }


    with this:

    		$mvars = $vars;
    $mvars['response'] = preg_replace(\"/#assign:.([^\s]+)/\", '', $mvars['response']);
    if(($vars['subject'] && preg_match (\"/#internal/\", $vars['subject'], $action)) OR ($vars['response'] && preg_match (\"/#internal/\", $vars['response'], $action))) {
    $mvars['note'] = preg_replace(\"/#internal/\", '', $mvars['response']);
    $mvars['title'] = 'Ticket Updated via email';
    if(!($response=$this->getThread()->addNote($mvars, $errors)))
    return null;

    } else {

    if(!($response = $this->getThread()->addResponse($mvars, $errors)))
    return null;
    }


    I am sure Jemson will come up with an update that strips them all out at the same time - but this works for me in the mean time :)
  • Thanks Jemsen. Do you have an idea on when you will release the update?
  • Awesome!

    Just what I was looking for!

    Thanks!
  • I would like to report that this MOD has worked flawlessly for my organization. It made life so much easier.

    The only addition that would be good is the ability for staff to add #close within the message body to close a ticket.
  • Hi All,

    Just wanted to touch base and let you know I am back from my month long vacation and will be ready to push through the rest of the updates very soon.

    I have pretty much completed the CC mod over the last couple of hours. I just need to complete a few more tests and make sure it is stable, plus make the small modifications to strip the #actions out of the body of email replies to a requester. All in all, should complete testing and push through the next patch version in the next 2-3 days.

    maxus389, I have taken your fantastic suggestion on board and already rolled that into this upcoming version of the mod.

    Alltime, I'm not sure which version of the patch you rolled out, but 4.1 certainly allows for #close in the body of an email to close a ticket. If you are running an older version I recommend waiting a couple of days for the next release.

    Thanks again to all for the support.

    Jemson
  • Hey Jemson,

    One small suggestion - allow more room to play with #assign: (and all the other actions by adding an i after the preg_match)

    Ex. users at my company like to type in all caps for some reason (but usernames in our osticket are all lowercase)

    I personally got around this by doing the following:

    changed the entire
    if($vars['subject'] && preg_match (\"/#assign:/\", $vars['subject'], $action)){
    $match = preg_split(\"/#assign:/\", $vars['subject']);
    }
    to be:

            if($vars['subject'] && preg_match (\"/#assign:/i\", $vars['subject'], $action)){
    $checkSpace = preg_replace(\"/#assign:(\s*)/i\", '#assign: ', $vars['subject']);

    preg_match(\"/(?<=(#assign:\s))(\w+)/\", $checkSpace, $match);

    $match[0] = strtolower($match[0]);
    }


    I also changed the accompanying response - I used preg_match for the assigned name instead of preg_split as well - the gains are minimal though. This does change the $match array to have the user name in index 0 instead of 1 though - so I also adjusted that in the if(isset($match)){ statement...

    Just a suggestion to give complete flexability to #assign which would allow users to type the following and it still work:

    #AsSiGn: hawkhead99
    #ASSIGN:HAWKHEAD99
    #assign: hawkhead99
    (and any other combo you can think of)
  • Mod 5.0 now with CC!

    Hi All,

    As promised please see attached mod 5.0.
    Apologies for the delay, but I found a major bug I had to deal with in my testing.

    There are a LOT of changes in this verison (especially in class.ticket.php) as such the diff on class.ticket.php alone is too big for a single post.
    I would suggest running your own diff against the original code base if you need. If anyone gets stuck let me know and I can probably output to a text file and upload.

    I have tested this mod every way I can think of and hope I have ironed out most/all of the bugs. As usual if you find any please let me know.

    IMPORTANT: Make sure to read the README for usage and requirements.
    There is also a small db change required in this version for the CC ability;
    ALTER TABLE `ost_ticket` ADD COLUMN `cc` VARCHAR(255) default null AFTER `email`;


    Hawkhead99, I incorporated your case insensitive idea and space ability for #claim into this version but modified a bit from your original posted code.
    I also left out the strtolower on the username, but feel free to add it back in if you need it.


    Changelog:
    4.1 to 5.0
    - Added CC functionality
    - Added #unsubscribe action
    - Made #actions case insensitive
    - Added function to strip #actions from being posted in message body
    - Configured system emails regarding tickets to be sent from the department address rather than alert address
    - Added missing reply separators
    - Minor bug fixes and code clean up

    Todo in later versions:
    - Allow staff attachments to be forwarded to requestor with ticket update.
    - Allow staff to create and use actions on tickets in one initial email
    - Add additional actions as necessary/requested.
    mod5.zip
    46K
  • I updated all of the files, and getting this error:

    Excessive errors processing emails for /helpdesk@mydomain.com. Please manually check the inbox.

    http://::\Websites\myserver\api\cron.php
  • After doing a little testing on it

    An end-user can send a ticket in with CC user
    End user can reply to ticket
    CC user can reply to ticket

    Problem is when staff responds to ticket is when It gets the error.
  • Hmmm. Are you passing any actions in the staff reply, or just a straight reply?
  • ive tried both with or without
  • Sorry. I found the issue.

    I was experimenting with another function and got the two class.mailfetch.php files mixed up. I have modified the above v5.0 post and reuploaded the zip.
    Please redownload and this should fix the issue.
  • Testing now...will post results shortly.
Sign In or Register to comment.