From Request Tracker Wiki
Revision as of 15:39, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sending notification emails with rt-crontool

It is now possible to add an email comment or correspondence to a ticket (or selection of tickets) using an external command-line tool. Together with rt-crontool, the administrator now has the ability to schedule timed notifications for tickets that meet certain criteria.

The key modules for this are RT::Search::FromSQL and RT::Action::RecordComment (or RT::Action::RecordCorrespondence, although you may not want to send "unowned after 2 days" escalation alerts to the customer who opened the ticket.) The steps are thus:

  • Create a template. It is probably easiest to create a global template; this can be done by clicking on Configuration -> Global -> Templates -> New Template. If you wish to have different messages for your different ticket queues, you may also create queue-specific templates. Name the template something memorable, such as 'Unowned tickets'.

The template content might look like this:

 Subject: {$Ticket->id} unowned after 48 hours!
 RT-Send-Cc: management@company.com, projectlead@company.com

The ticket {$Ticket->id} has been unowned for 2 days now.  Get busy.

Key to this template is the RT-Send-Cc: (or RT-Send-Bcc:) field, in which you should put the email addresses of those who should get this escalation email. Any internal watchers of the ticket would also get this email.

  • Create a TicketSQL query. The easiest way to do this is to build the query in the web Query Builder, and then click on "Advanced" to see the TicketSQL. Make a note of this query string; you will need it for running rt-crontool. (Do NOT copy the query strings directly in the examples below; any system-specific user IDs could well be different, so be sure to use the one that the Query Builder generates for you.)
  • Set up a cron job using rt-crontool. In the above example we might have the following in crontab:
0 3 * * * /opt/rt3/bin/rt-crontool --search RT::Search::FromSQL \
 --search-arg "Owner = '10'  AND Created < '2 days ago' AND Created > '3 days ago'"  \
 --action RT::Action::RecordComment --template 'Unowned tickets'
  • Another example, for an unresolved ticket that has not been updated in 7 days, might look like this:
0 3 * * * /opt/rt3/bin/rt-crontool --search RT::Search::FromSQL \
--search-arg "LastUpdated < '7 days ago'  AND Status != 'resolved' AND Status != 'rejected'" \
--action RT::Action::RecordComment --template 'Ignored tickets'

If you wish the generated email to also go to the customer, simply use RT::Action::RecordCorrespondence instead of RT::Action::RecordComment.