1. Introduction
This is a brief doc on how to create templates for use in RT.
2. Types of Templates
Templates are located in rt/etc/templates/queues/<queue_name> The templates available for customization are:
- autoreply
-
Used to build auto reply email message.
- comment
-
Used to build comments entered through any of the UIs.
- correspondence
-
Template for all mail sent by requestor / owner / queue members.
- error
-
General errors template.
- give
-
Used to build email notification which is sent to person assigned ownersip of a ticket.
- respond
-
?
- steal
-
Used to build email notifications for ex-owners of requests when they are stolen.
- transaction
-
Used to build emails if an email is sent for each transaction. (priority change, etc)
- web_create
-
Used to build a skeleton ticket in the web UI.
3. Embedable Tokens
Templates support the embedding of "tokens" for dynamically inserting information such as the ticket owners contact info.
The available tokens are
- %rtname%
-
?
- %rtversion%
-
RT Software version
- %actor%
-
RT username and real name. i.e. "'login' (Full Name)"
- %owner%
-
Ticket owner
- %subject%
-
Ticket subject
- %serial_num%
-
Ticket number
- %mailalias%
-
Queue email alias
- %content%
-
Content of the ticket / transaction
- %req:<word>%
Where <word> can be:- serial_num
- effective_sn
- queue_id
- area
- alias
- keywords
- requestors
- owner
- subject
- initial_priority
- final_priority
- priority
- status
- time_worked
- date_created
- date_told
- date_acted
- date_due
- %trans:<word>%
Where <word> can be:- id
- effective_sn
- serial_num
- actor
- type
- trans_data
- trans_date
- %queue:<word>%
Where <word> can be:- queue_id
- mail_alias
- comment_alias
- m_owner_trans
notify owner on transaction - m_members_trans
notify list members on transaction - m_user_trans
notify requestor on transaction - m_user_create
notify user on creation - m_members_corresp
notify members on creation - m_members_comment
notify members on comment - m_user_resolve
mail user on resolution. NOT YET IMPLEMENTED - allow_user_create
let nonmembers create - default_prio
- default_final_prio
- default_due_in
3.1. Token Interpolation
The code for interpolating these tokens can be easily hacked and is found in rt/lib/rt/mail.pm. It looks something like this:
$template =~ s/%rtname%/$rtname/g; $template =~ s/%rtversion%/$rtversion/g; $template =~ s/%actor%/\'$in_current_user\' ($rt::$users{$in_current_user}{real_name})/g; $template =~ s/%owner%/$rt::$users{$rt::req[$in_serial_num]{owner}}{real_name} ($rt::$users{$rt::req[$in_serial_num]{owner}}{email})/g; $template =~ s/%subject%/$in_subject/g; $template =~ s/%serial_num%/$in_serial_num/g; $template =~ s/%mailalias%/$mail_alias/g; $template =~ s/%content%/$in_custom_content\n/g; $template =~ s/%req:(\w+)%/$rt::req[$in_serial_num]{$1}/g; $template =~ s/%trans:(\w+)%/$rt::req[$in_serial_num]{'trans'}[$in_id]{$1}/g; $template =~ s/%queue:(\w+)%/$rt::queues{$rt::req[$in_serial_num]{'queue_id'}}{$1}/g;
4. Sample Templates
The default templates are found in rt/lib/generic_templates/ while normal queue templates are stored in rt/etc/templates/queues/<queue_name>/. I find it useful to put the full path name into the templates while you are tweaking them so it is easier for yourself and others to track down. You probably want to remove that from your templates that will go to requestors once you have your templates solidified.
4.1. Sample give Template
Example of template used to notify a user when a request has been given to them. You'll notice that I have included a link of http://rt.domain.com/ to remind the new owner of where to go to work on the ticket. I suppose it would be pretty crafty to include a direct link to the ticket.
Ticket %serial_num% has been given to you by %actor%. Now it is YOUR job to get this issue resolved! Do it!! -- %actor% %mailalias% http://rt.domain.com/ /usr/local/rt/etc/templates/queues/noc/give
4.2. Sample web_create Template
This template automatically populates the textarea field when you create a web based request. In my installation we pretty much exclusively use the web interface and our tickets are only used inside the company.
-=-=-=- For Internal use only - Do not send outside company -=-=-=- ********************************************************** -- DESCRIPTION ------------------------------------------- ********************************************************** -- APPLICATIONS AFFECTED --------------------------------- -- CUSTOMER IMPACT --------------------------------------- -- CONTACT INFORMATION ----------------------------------- %actor% Network Operations - 317-555-5555 - noc@domain.com -- UPDATE SECTION ----------------------------------- -=-=-=- For Internal use only - Do not send outside company -=-=-=-
4.3. Sample transaction Template
This template will only be used if you choose to notify queue members of transactions.
%trans:text_time%: Ticket %serial_num% was acted upon. Ticket Num: %serial_num% Transaction: %trans:text% Queue: %req:queue_id% Area: %req:area% Subject: %req:subject% Owner: %req:owner% Requestors: %req:requestors% Status: %req:status% ------------------------------------------------------------------------- %trans:content% ------------------------------------------------------------------------- /usr/local/rt/etc/templates/queues/noc/transaction