Match Mail to Tickets by Reference


#1

Good Nighttime,
just a short question about matching Mails to existing tickets.
In the default setup request tracker matches answers to existing tickets that are ingoing via mail by the subject itself. Is it possible to look after other headers, such as References?

  1. User sends mail, ticket got created
  2. Agent changes subject, answers to user, keeping tracker in CC
  3. Instead of creating a new ticket, request tracker should look at the References in the header to find the original ticket and place it there as mail.

Thank you in advance


#2

You get a problem when the user takes an old email and tries to use it as the basis for a new problem. The subject changed, but the reference didn’t. How do you determine if the email should be a new ticket or a reply to an old one?

Teaching users not to use an old email this way is hard.
Teaching users to keep the ticket number is much easier.

/jeff


#3

Thanks for your remark. Since this is only a subset of all mails it should be limited towards one queue.

The reason here is quite simple and can be explained by an external monitoring system:
At a given point, the system creates a mail and sends it towards the tracker.
Now the tracker sends it to both, the internal and the external crew. At the external crew, the mail is converted into another ticket with their number and a generalized subject.


#4

Now that you have explained the environment that needs this, I see the following:
The email subject will have a standard form, albeit not RT’s.
The email from will likely have a fixed value.

Given this, you can modify the detect routine to check the from, and if found, use the other header instead.

Sorry, but I don’t know which file that code is in, but I know it has been mentioned on the forum.

/jeff


#5

Take a look in lib/RT/Interface/Email.pm, specifically the ExtractTicketId() method. You could tweak a local copy of that to see if there is a References header. RT message IDs should appear as references that look like RT-Ticket-653@your.domain.com. A simple bit regexp should then do the trick. I’ve not tried this (don’t want to screw up our RT dev box at the moment!) but something like this might work:

sub ExtractTicketId {
    my $entity = shift;

    # Look for RT-Ticket-<number> reference headers in the Email
    my $references = Encode::decode( "UTF-8", $entity->head->get('References") || '');
    if($references) {
       if($references =~ /RT\-Ticket\-(\d+)/) {
         return $1;
       }
    }

    # No matching RT-Ticket-<number> references so look in the subject line.
    my $subject = Encode::decode( "UTF-8", $entity->head->get('Subject') || '' );
    chomp $subject;
    return ParseTicketId( $subject );
}