Custom Scrip

Hello,
I’m looking for either a scrip to notify a particular email address
when a new ticket his the queue or a good place with documentation on
how to write custom scrips.

Basically I want an email to go to our department email list when a new
ticket is generated. I’m assuming to write this myself I will need to
whip up some perl but I’m not sure how involved it will be. Are there
any resources out there for beginning scrip writers?

TIA
Gary

-----Original Message-----
From: Gary Rule [mailto:grule@bbn.com]
Sent: Monday, September 08, 2003 2:03 PM
To: rt-users@lists.fsck.com
Subject: [rt-users] Custom Scrip

Hello,
I’m looking for either a scrip to notify a particular
email address when a new ticket his the queue or a good place
with documentation on how to write custom scrips.

Basically I want an email to go to our department email list
when a new ticket is generated. I’m assuming to write this
myself I will need to whip up some perl but I’m not sure how
involved it will be. Are there any resources out there for
beginning scrip writers?
[…]

I recently asked a similar question (except I want to send a stipped
down template to a pager’s email address) and it was suggested that I
use AdminCC. For me, that won’t work, as I’m using both CC’s and
AdminCC’s for other purposes.

Hopefully someone can answer this question…I’m sure more than just
the two of us could use this information.

Daryl

-----Original Message-----
From: Gary Rule [mailto:grule@bbn.com]
Sent: Monday, September 08, 2003 2:03 PM
To: rt-users@lists.fsck.com
Subject: [rt-users] Custom Scrip

Hello,
I’m looking for either a scrip to notify a particular
email address when a new ticket his the queue or a good place
with documentation on how to write custom scrips.

Basically I want an email to go to our department email list
when a new ticket is generated. I’m assuming to write this
myself I will need to whip up some perl but I’m not sure how
involved it will be. Are there any resources out there for
beginning scrip writers?
[…]

I recently asked a similar question (except I want to send a stipped
down template to a pager’s email address) and it was suggested that I
use AdminCC. For me, that won’t work, as I’m using both CC’s and
AdminCC’s for other purposes.

Hopefully someone can answer this question…I’m sure more than just
the two of us could use this information.

Daryl

I won’t directly answer it, but I’ll post some code that should do the
trick with some modifications.

Problem: I needed to autoassign tickets to individuals based on a
CustomField (eg: Server, Desktop, VPN, Phone System, etc…). So I wrote
this… it seems to work okay for us on 3 queues. RT 3.0.3

Description: AutoAssign
Condition: On Create
Custom Condition:
Action: User Defined

Custom action preparation code:
my $retval = undef;
if ( defined( $self->TicketObj->OwnerObj->id ) ){
# Only change tickets where ID is not already set - eg: New Tickets
if( $self->TicketObj->OwnerObj->Id == $RT::Nobody->Id ){
$RT::Logger->info(“AutoAssign: New Ticket with no owner - Autoassigning”);
$retval = 1;
}
}
return ($retval);

Custom action cleanup code:

use RT::Ticket;
use RT::User;
use RT::CustomField;
use RT::AutoAssign;

my $retval = undef;

my $handle = DBIx::SearchBuilder::Handle->new();

Change to your DB info. Should probably rewrite to pull from

RT_SiteConfig.pm - patches welcome.

$handle->Connect( ‘Driver’ => ‘mysql’,‘Database’ => ‘rt3’,
‘Host’ => ‘localhost’, ‘User’ => ‘rt_user’,‘Password’ => ‘rt_pass’);

my $s = new AutoAssign($handle);

Get the list of Custom Fields

my $CustomFields = $self->TicketObj->QueueObj->CustomFields();

Use the 1st field for our purposes

my $CustomField = $CustomFields->Next();

List of value of the custom field.

my $Values = $self->TicketObj->CustomFieldValues($CustomField->id);

List of valid values for this custom field

my $CustomFieldValues = $CustomField->Values();

my $assigned = 0;

Cycle through possible values…

while (my $value = $CustomFieldValues->Next) {
# If we match up…
if ($Values->HasEntry($value->Name)) {
# Do stuff
my $name = $value->Name;
my $id = $value->id;
$s->LoadByCol(‘SubQueueid’, $id);
$retval = $self->TicketObj->SetOwner($s->Userid());
$RT::Logger->info(“AutoAssign: Result code is $retval”);
$assigned = 1;
}
}
if ($assigned != 1) {
# AutoAssign to dlaskey (67) for no match
$retval = $self->TicketObj->SetOwner(67);
$RT::Logger->info(“AutoAssign: Result code is $retval”);
}

return ($retval);

Template: Global Template: Blank

I’ve got a module (AutoAssign.pm) defined to describe the table I used,
which is basically just Users.id → CustomFieldValues.id mapping. Email
me if you want/need a copy - it’s a bit uglier that I’d like to admit :slight_smile:

For your needs, just change the CleanUp Code to like:

$retval = $self->TicketObj->AddWatcher(Type => ‘Cc’, Email => ‘user@host.com’)

Or if, as you indicated you can’t use the AdminCCm and just want a one-off
email, then:

use RT::Action::SendEmail;

and then run perldoc /opt/rt3/lib/RT/Actions/SendEmail.pm to see the
functions to set the To/CC/Subject/Content etc…

Ken

You could add that e-mail address as a user, then add it as a cc watcher
on that queue. Then setup a script on that queue to notifycc only when a
ticket is created

Michael-----Original Message-----
From: Gary Rule [mailto:grule@bbn.com]
Posted At: Monday, September 08, 2003 2:03 PM
Posted To: RT
Conversation: [rt-users] Custom Scrip
Subject: [rt-users] Custom Scrip

Hello,
I’m looking for either a scrip to notify a particular email address
when a new ticket his the queue or a good place with documentation on
how to write custom scrips.

Basically I want an email to go to our department email list when a new
ticket is generated. I’m assuming to write this myself I will need to
whip up some perl but I’m not sure how involved it will be. Are there
any resources out there for beginning scrip writers?

TIA
Gary

rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

It wouldn’t be that tough with a simple (quite simple)
perl script. I did something similar as a spam
filter. My configuration goes something like this:

  1. in /etc/aliases, I do not have the normal entry:

general: “|/opt/rt2/bin/rt-mailgate --queue general
–action correspond”

Instead, I have:

general: “|/home/gman/scripts/filter.pl”

The ‘filter.pl’ reads the body of the email into an
array. If the body contains certain spam text, the
script exits (therefore, nothing goes into RT); if the
body contains no spam keywords, I do this:

open (PIPE, “|/opt/rt2/bin/rt-mailgate --queue general
–action correspond”
);
print PIPE @message;
close PIPE;

So, for your case, you could do something similar.
But instead of dropping the message if there is spam,
you check the body for:
[your.domain.here # (something that shows up in the
title after RT already saw it, since you only are
interested in new tickets).
If the body contains the above, you simply pass it
along to RT with the PIPE; if the body doesn’t contain
the above, you generate an email to the address
interested in new messages, as well as pass it to RT
via the PIPE.

If you want examples of my perl code, I can provide.— “Daryl G. Jurbala” daryl@introspect.net wrote:

-----Original Message-----
From: Gary Rule [mailto:grule@bbn.com]
Sent: Monday, September 08, 2003 2:03 PM
To: rt-users@lists.fsck.com
Subject: [rt-users] Custom Scrip

Hello,
I’m looking for either a scrip to notify a
particular
email address when a new ticket his the queue or a
good place
with documentation on how to write custom scrips.

Basically I want an email to go to our department
email list
when a new ticket is generated. I’m assuming to
write this
myself I will need to whip up some perl but I’m
not sure how
involved it will be. Are there any resources out
there for
beginning scrip writers?
[…]

I recently asked a similar question (except I want
to send a stipped
down template to a pager’s email address) and it was
suggested that I
use AdminCC. For me, that won’t work, as I’m using
both CC’s and
AdminCC’s for other purposes.

Hopefully someone can answer this question…I’m
sure more than just
the two of us could use this information.

Daryl


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at
http://fsck.com/rtfm

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com