Table of Contents

Introduction to email templates (creation, modification) and fields

Author: Sophie Renshaw

Emails in Tickets

Alongside forms, emails are a key part to tickets. They can be configured to send automatically when a ticket moves into a specific state to a set of defined contacts or they can be manually sent from the ticket.


Sending from a Ticket

Clicking the Send Email button in the Ticket Info panel of the ticket will allow the user to select the email template(s) that they would like to send. Clicking the Show All button on the Email Preview Selection screen will preview all of the email templates that were selected. This allows the user to make any changes necessary to the To, CC and Subject fields, before the email is sent.

Selecting this button will send the email

Selecting this button or clicking the X in the top right corner will discard the email template


Sending Automatically from a Workflow

Emails can be automatically sent when a ticket moves into a certain state. This is configured in the workflow. To add an email to a workflow state open the workflow and identify the relevant Node. Double click on the node and in the Node Properties window that appears select either the On State Enter or On State Exit tab, depending on what functionality you require. Select an email from the Send an Email dropdown and click Save. Don't forget to publish to workflow to save the changes!

If you require more than one email to be sent or if the required functionality is a bit more complex in which it depends on certain forms, states, previous states etc. then groovlets can also be used to send emails automatically. These groovlets can be selected in the Run a Rule dropdown.


Creating and Editing Email Templates

The Email Templates manager allows us to create and edit email templates. To open it, select the Admin Options dropdown from the Ticketer menu bar, from there select Email and finally Email Templates. This will open the Email Template wizard.


Creating a new Email Template

To create a new email template click the New Button. Select OK in the dialog box to continue or Cancel to return to what you were doing. The necessary fields that need to be filled in to save the template are the To, Subject, and Email Body. It will also be necessary to specify the Email Account, which can be done through the Advanced settings button. You will get a popup box in which you can select an email address from a dropdown. There is also an option to specify a form that will be attached to the email.

You can also specify a CC and Fallback address (where a failure email will be sent.) There are 3 checkboxes on the email template; Ticket Email means that it will require a ticket number to be used, Query IDMS KnowledgeBase will require a query to the Database and HTML Email will depict wether the email is sent in HTML or plain text.

The Customer Title field allows you to select a Customer Icon to be shown on the email template. Similarly Customer Subtitle will allow you to define a subtitle to be shown. The Email Style dropdown will allow you to select an email style. Typically this will be either Basic or Default but there are also used for the other options.

To save you new email template click the save button. You will be prompted for an Email name and description.


Editing an Email Template

Opening an email template will allow you to edit all aspects of it. Clicking save will allow you to save your changes. If you want to save it with a new name and description, clicking Save As will allow this.


Testing Email Template Changes

An important part of testing your changes to an email template or the creation of a new one is testing it to ensure that both the data is correctly represented and that it is aesthetically pleasing. If the email requires a ticket then you will need to use the ticket search functionality to find one that will suit the template.

To test the email template click the Preview button. You will be prompted for the ticket number. If there are no issues with the template the preview will load with the ticket information populated (if applicable). If no email preview loads then this usually indicates an issue with the template.

Tailing the logs while previewing the email will be beneficial here for troubleshooting any issues that may occur. Once you are happy with your changes and you have saved them if is also worth previewing the email through the ticket (mentioned above). Send this email to yourself to confirm that your email client is rendering the template correctly.


Populating To & CC Fields from the KB

Static email addresses can be set in the To and CC fields but more commonly the data is pulled dynamically from the database depending on the related ticket.

Pulling in the address based on the ticket's contact responsibility. In this case the email address of the contact with the Network Operations Manager responsibility will be returned. Variations of this can be used to return Field Tech Primary, Carrier Primary, Manager, etc.

${(new com.errigal.ticketer.datasource.ExternalDBConnection("IDMS Monitor")).getExternalData("select distinct email_address from contact as ct left join contact_responsibility as cr on (ct.id = cr.contact_id) join network_element as ne on (cr.element_id = ne.id) where ne.name = '${ticket.changes.find{it.form.name == 'DAS NOC'}.data.get('hub_name')}' and ne.show_in_monitor = true and (cr.responsibility_type ='Network Operations Manager (NOM)')").join(',')}

The address fields can also populate information based on ticket states:

${if(ticket.currentStatus.status == 'ASSIGNED - Escalated to SCN Tech Support') {return 'SCNTechSupport' + '@customer.com'}else{ 	(new com.errigal.ticketer.datasource.ExternalDBConnection("IDMS Monitor")).getExternalData ("select distinct email_address from contact as ct left join contact_responsibility as cr on (ct.id = cr.contact_id)  join network_element as ne on (cr.element_id = ne.id) where ne.name = '${ticket.changes.find{it.form.name == 'DAS NOC'}  .data.get('hub_name')}' and ne.show_in_monitor = true and (cr.responsibility_type='Tech Supervisor' or cr.responsibility_type   ='Field Tech Primary' or cr.responsibility_type ='Field Tech Secondary' or cr.responsibility_type ='DAS Vendor Primary')").toString()}}

Combinations of groovy and SQL can be used to manipulate Knowledgebase data to return the desired email addresses.

Example Email Body

newSection(table(tbody(
         tr(td1(b("Resolution:")) + td2(b(ticket.changes.find{it.form.name == 'DAS NOC'}.data.get('carrier_update') ?: "None"))) +
            tr(td(p(b("Details"), ["class": "errigal_gray_text"]), ["width": "140px"]) + td("", ["width": "360px"])) +
                    tr(dividerTd()) +
                    trDark(td1("Customer TT No:") + td2(ticket.changes.find{it.form.name == 'DAS NOC'}.data.get('carrier_ticket') ?: "None")) +
                    tr(td1("Ticket No:") + td2("$ticket.workflow.ticketPrefix-$ticket.id")) +
                    trDark(td1("Market:") + td2(ticket.visibility ?: "")) +
                    tr(td1("DAS Network Name:") + td2(ticket.changes.find{it.form.name == 'DAS NOC'}.data.get('hub_name') ?: "")) +
                    trDark(td1("Node(s) Affected:") + td2(ticket.changes.find{it.form.name == 'DAS NOC'}.data.get('node_name') ?: "")) +
                    trDark(td1("Event Type:") + td2(ticket.summary)) 
    ), width530 + border0 + spacing0 + padding0)) +

newSection(table(tbody(
            tr(spacerTd + td(p(b("Contact Network Operations Center"), ["class": "errigal_gray_text"]), width530) + spacerTd) +
                    tr(spacerTd + dividerTd() + spacerTd) +
                    tr(spacerTd + td(p("888-632-0931", ["class": "errigal_gray_text", "bgcolor": "#F2F1E8"])) + spacerTd) +
                    tr(spacerTd + td(p(a("mailto:$ticket.emailAccount.replyTo", ticket.emailAccount.replyTo), ["class": "errigal_gray_text"])))),
            width600 + border0 + spacing0 + padding0 + ["style": "padding:10px 0px 0px 0px;"]))

Tips

- Be careful to remove all the space in the code

- Using IF…ELSE for TO, CC fileds on Customer ENV

${String emails = "test@errigal.com"; if(ticket.priority==2){emails+=", test1@errigal.com"}; if(ticket.priority==1){emails+=", test2@errigal.com"}; return emails}

- Using IF…ELSE for TO, CC fileds on Watchdog(Atlas) Ticketer - https://errigalnoc.com:8083/Ticketer/ - Preview of email template works differently from when sending the real email. When send the real email, the CC field just grep all the String has `@something.com` to return. So the workaround will be define the email account before @ first, and then add `@something.com` to the end, like below

${String email = ""; if(ticket.summary.startsWith("qaext")||ticket.summary.startsWith("qaatc")||ticket.summary.startsWith("americantower.idm")){email="u7z5s9r7a4a9j9i4"}; if(ticket.summary.startsWith("sfqa")||ticket.summary.startsWith("qa")||ticket.summary.startsWith("nvqa")||ticket.summary.startsWith("qasco")||ticket.summary.startsWith("towerqa")||ticket.summary.startsWith("demo")){email="a8p2i3w5v9h1m1q4"}; if((ticket.summary.startsWith("ext")&&!ticket.summary.startsWith("qaext"))||(ticket.summary.startsWith("atc")&&!ticket.summary.startsWith("qaatc"))||(ticket.summary.startsWith("sco")&&!ticket.summary.startsWith("qasco"))||ticket.summary.startsWith("scottypro")){email="u9y7h8j3n4p8t2b8"}; println email; return email+"@errigaloperations.slack.com"}

Onboarding Self Assessment

  1. Open the Email Template Wizard and create a simple email template.
  2. Save it with a relevant name and description.
  3. Edit the email template the use a ticket (if it isn't doing so already) and update the To and CC fields to pull email addresses from the Database
  4. Preview your changes and make sure there are no issues.
  5. Edit the email body to pull in information from the ticket and forms on the ticket.
  6. Preview your changes again and make sure that there are no issues.
  7. Save your email template with a new name and description.
  8. Open a ticket and click the Send Email button to view your new email.
  9. Send this email to yourself, confirm that you received it and that it renders correctly in your mail client.

Please ask yoiur mentor to look through the relevant email template names and tickets with you.