OTRS auto filter ticket

Moderator: crythias

Locked
oscar
Znuny newbie
Posts: 68
Joined: 04 Mar 2011, 11:02
Znuny Version: 3.0.6

OTRS auto filter ticket

Post by oscar »

hi all,


I got problem with my customer, they keep sending same content and message but with different of customer so that it will auto generate a lot of different tickets number.

example: 5 customers different time send same content and message to me , so I need to manually merge it and reply them


so isn't got anyway for OTRS to auto filter the same ticket number to stack together with one ticket number, so that I no need to manually one by one to merge it.

I know PostMaster Filter Management is the way to filter the ticket queue, but how to solve my problem ? which I need to select ?


thank you and wish you guy reply me soon :D
fedora 5.0, OTRS 3.0.6

Professional software engineer
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: OTRS auto filter ticket

Post by renee »

You could write your own PostMaster filter module that checks the database if a ticket with the same subject and message already exists. If a ticket exists, use the mail as a followup.

If it's not exactly the same subject and message, you have to think about when you want it to be a followup and when it should be a new ticket.
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
oscar
Znuny newbie
Posts: 68
Joined: 04 Mar 2011, 11:02
Znuny Version: 3.0.6

Re: OTRS auto filter ticket

Post by oscar »

dear renee


which followup i need to select ? because it a lot type of followup.such as followup-articlekey, followup-articlevalue, followup-tickettime1,2,3... , followup-ticketvalue1,2,3... and etc...


I no really understand of what is the different between of the type also


thank for your reply
fedora 5.0, OTRS 3.0.6

Professional software engineer
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: OTRS auto filter ticket

Post by renee »

I would change the subject so that OTRS recognises the ticketnumber of the "original" ticket...
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
oscar
Znuny newbie
Posts: 68
Joined: 04 Mar 2011, 11:02
Znuny Version: 3.0.6

Re: OTRS auto filter ticket

Post by oscar »

hi renee,


what you mean is you will change the filter condition become-subject ? then what about the set email header? what you will set on this ???


so what should I need to select and put in

filter condition header1:subject - ? value1: ?

set email header1: ? value1: ?



example: my customer is using their own gmail to send one email to otrs, after few second, they use their gmail to reply back their sent email, so OTRS will become 2 tickets , but the subject is same such as

> [Ticket#1052405]
>
> Then customer replies it with the subject
>
> Re: [Ticket#1052405]


so how to I filter it by these two same tickets subject and how to I auto stick and filter this 2 tickets number become one ticket number??
fedora 5.0, OTRS 3.0.6

Professional software engineer
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: OTRS auto filter ticket

Post by renee »

You can't do this with the PostMast filter editor in the Admin area. You have to create a Perl module that acts as a PostMaster filter:

Code: Select all

   # --
    # Kernel/System/PostMaster/Filter/FindDuplicates.pm - the global PostMaster module for OTRS
    # Copyright (C) 2011 perl-services.de, http://perl-services.de/
    # --
    # $Id: FindDuplicates.pm,v 1.4 2011/05/31 07:56:35 rb Exp $
    # --
    # This software comes with ABSOLUTELY NO WARRANTY. For details, see
    # the enclosed file COPYING for license information (AGPL). If you
    # did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
    # --

    package Kernel::System::PostMaster::Filter::FindDuplicates;

    use strict;
    use Kernel::System::Ticket;

    use vars qw($VERSION);
    $VERSION = '$Revision: 1.4 $';
    $VERSION =~ s/^.*:\s(\d+\.\d+)\s.*$/$1/;

    sub new {
        my $Type  = shift;
        my %Param = @_;

        # allocate new hash for object
        my $Self = {};
        bless( $Self, $Type );

        $Self->{Debug} = $Param{Debug} || 0;

        # get needed objects
        for my $Object (
            qw(ConfigObject LogObject DBObject TimeObject MainObject EncodeObject)
            )
        {
            $Self->{$Object} = $Param{$Object} || die "Got no $Object!";
        }

        $Self->{TicketObject} = Kernel::System::Ticket->new( %{$Self} );

        return $Self;
    }

    sub Run {
        my ( $Self, %Param ) = @_;

        for my $Needed (qw(JobConfig GetParam)) {
            if ( !$Param{$Needed} ) {
                $Self->{LogObject}->Log(
                    Priority => 'error',
                    Message  => "Need $Needed!",
                );
                return;
            }
        }

        # ------ 8< this should go into a Kernel::System::* module 8< ------
        my $SQL = 'SELECT tn FROM ticket JOIN article ON ticket.id = ticket_id WHERE a_subject = ? AND a_body = ?';
        return if !$Self->{DBObject}->Prepare(
            SQL => $SQL,
            Bind => [ \$Param{GetParam}->{Subject}, \$Param{GetParam}->{Body} ],
            Limit => 1,
        );

        my $TicketNr;
        while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
            $TicketNr = $Row[0];
        );

        return 1 if !$TicketNr;

        $Param{GetParam}->{Subject} = sprintf "[Ticket#%s] %s", $TicketNr, $Param{GetParam}->{Subject};
        # ------ 8< this should go into a Kernel::System::* module 8< ------

        return 1;
    }

    1;
And you have to enable the filter in your Kernel/Config.pm:

Code: Select all

$Self->{'PostMaster::PreFilterModule'}->{'010-Duplicates'} =  {
  'Module' => 'Kernel::System::PostMaster::Filter::FindDuplicates'
};
This code is untested!
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
oscar
Znuny newbie
Posts: 68
Joined: 04 Mar 2011, 11:02
Znuny Version: 3.0.6

Re: OTRS auto filter ticket

Post by oscar »

hi renee,


thank for reply, Isn't the coding is safety ? because I afraid if I change the code, in the future might got some error, but able to try :D


once again, thank you :D
fedora 5.0, OTRS 3.0.6

Professional software engineer
ipguy
Znuny newbie
Posts: 40
Joined: 19 May 2010, 08:29
Znuny Version: 2.3.4

Re: OTRS auto filter ticket

Post by ipguy »

renee wrote:You can't do this with the PostMast filter editor in the Admin area. You have to create a Perl module that acts as a PostMaster filter:

Code: Select all

   # --
    # Kernel/System/PostMaster/Filter/FindDuplicates.pm - the global PostMaster module for OTRS
    # Copyright (C) 2011 perl-services.de, http://perl-services.de/
    # --
    # $Id: FindDuplicates.pm,v 1.4 2011/05/31 07:56:35 rb Exp $
    # --
    # This software comes with ABSOLUTELY NO WARRANTY. For details, see
    # the enclosed file COPYING for license information (AGPL). If you
    # did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
    # --

    package Kernel::System::PostMaster::Filter::FindDuplicates;

    use strict;
    use Kernel::System::Ticket;

    use vars qw($VERSION);
    $VERSION = '$Revision: 1.4 $';
    $VERSION =~ s/^.*:\s(\d+\.\d+)\s.*$/$1/;

    sub new {
        my $Type  = shift;
        my %Param = @_;

        # allocate new hash for object
        my $Self = {};
        bless( $Self, $Type );

        $Self->{Debug} = $Param{Debug} || 0;

        # get needed objects
        for my $Object (
            qw(ConfigObject LogObject DBObject TimeObject MainObject EncodeObject)
            )
        {
            $Self->{$Object} = $Param{$Object} || die "Got no $Object!";
        }

        $Self->{TicketObject} = Kernel::System::Ticket->new( %{$Self} );

        return $Self;
    }

    sub Run {
        my ( $Self, %Param ) = @_;

        for my $Needed (qw(JobConfig GetParam)) {
            if ( !$Param{$Needed} ) {
                $Self->{LogObject}->Log(
                    Priority => 'error',
                    Message  => "Need $Needed!",
                );
                return;
            }
        }

        # ------ 8< this should go into a Kernel::System::* module 8< ------
        my $SQL = 'SELECT tn FROM ticket JOIN article ON ticket.id = ticket_id WHERE a_subject = ? AND a_body = ?';
        return if !$Self->{DBObject}->Prepare(
            SQL => $SQL,
            Bind => [ \$Param{GetParam}->{Subject}, \$Param{GetParam}->{Body} ],
            Limit => 1,
        );

        my $TicketNr;
        while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
            $TicketNr = $Row[0];
        );

        return 1 if !$TicketNr;

        $Param{GetParam}->{Subject} = sprintf "[Ticket#%s] %s", $TicketNr, $Param{GetParam}->{Subject};
        # ------ 8< this should go into a Kernel::System::* module 8< ------

        return 1;
    }

    1;
And you have to enable the filter in your Kernel/Config.pm:

Code: Select all

$Self->{'PostMaster::PreFilterModule'}->{'010-Duplicates'} =  {
  'Module' => 'Kernel::System::PostMaster::Filter::FindDuplicates'
};
This code is untested!


Hi Renee

Where exactly does one place the code marked as:

# ------ 8< this should go into a Kernel::System::* module 8< ------

?
Locked