[rt-users] Change queue and owner based on requestor's email address

john habermann john.habermann at wilderness.org.au
Sat Sep 9 22:58:05 EDT 2006


Hi Neil

On 9/8/06, Neil Hymans - Technically Speaking <info at techspeak.com.au> wrote:
> Hi all
>
> I'm an absolute RT neophyte, so my apologies in advance.  I've trawled
> through previous listings for solutions to similar requirements, but because
> I don't speak its programming dialect, I've not been able to successfully
> adapt things that I've found in the archives.
>
> So here's there the requirement:
>
> We want to maintain just one customer service email address which goes
> straight to RT, but would like each ticket to:
>
> 1) be assigned to the relevant major customer queue, based on the domain of
> the requestor's email address. For example, any email originating from
> "[anyone]@example.com" would go to the queue named "Example".
>
> There will also be situations in which we will need to match to an entire
> email address rather than a domain, so an illustration of this variation
> would also be helpful.
>
> 2) be assigned to the customer's account manager as owner.
>
> But remembering my newbie status, I'd be grateful for any suggestions
> regarding the most efficient way to implement this for maybe 25 cases.
> Should I create a scrip for each different case, or build all of them into
> one scrip?

I am guessing that it would be more efficient to have the check for
all the cases in the one scrip but I am a bit of a newbie myself so I
might be wrong. It looks like

http://wiki.bestpractical.com/index.cgi?SetOwnerAndQueueBySubject

matches pretty closely to want you want to do except that the match is
based on the subject rather than the requestor address. You would
match against the requestor address with something like this:

my $T_Obj = $self->TicketObj;
my $email = ($self->TicketObj->RequestorAddresses)[0];

if ($email =~ /^[\w\.]+\@(\w+)[\w\.]+/) {
        my $newqueue = $1;
        $RT::Logger->debug("newqueue will be $newqueue");
        my ($status, $msg) = $T_Obj->SetQueue($newqueue1);
        unless ($status) {
                $RT::Logger->warning("unable to set new queue: $msg");
                return undef;
        }
}

I guess you might want to check in your custom condition code whether
the email address of the requestor actually matches a queue that you
have set up for a customer and if it hasn't just let it pass through
to the main queue. Alternatively you could add a check in the code
above to see if the $newqueue already exists in RT and if it doesn't
exit and let the request go through to the default queue.

By playing around with the regular expression match you would be able
to match to a specific email address so you might have to add some
additional elsif checks for those cases.

Hope this is useful.

cheers
John
>
> I hope all this makes sense and will be very grateful for any assistance you
> good folk can offer.
>
> Thanks & regards
>
> Neil (Perth, Western Australia)
>
>
>
>
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>


-- 
John Habermann
Internet Programmer, System Administrator
The Wilderness Society Inc
http://www.wilderness.org.au



More information about the rt-users mailing list