Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This how-to will help you out solving the following use case:

A customer (john@customer.com) sends an email to an employee (joe@mycompany.com) instead of the JEMHC's JIRA Jira mail box (support@mycompany.com). The employee would like to tackle the use case via JIRA Jira rather than a standard email conversation with the customer. So the employee could reply/forward the email to both the customer (john@customer.com) with copy to JEMHC mail box (support@mycompany.com). There are a few problems with this approach.

  1. The employee will be the reporter/sender of the email instead of the customer

  2. The employee may not want to be involved, he wants the ticket in the JIRA Jira queue so the ticket is handled by the team

  3. The employee needs to send the forwarded email back to the customer so customer address doesn't get lost. If this email is replied, the conversation will be out of JIRAJira.

  4. The user may also receive a JEMHC email from the created ticket but not as the reporter/sender of the email

  5. The original reply could be stripped out so forward should be used

A forwarded email from Google Mail looks similar to the following:

Example forwarded email

Code Block
languagetext
MIME-Version: 1.0
Received: by 10.157.39.45 with HTTP; Mon, 2 Jan 2017 18:24:15 -0800 (PST)
In-Reply-To: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com>
References: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com>
Date: Mon, 2 Jan 2017 23:24:15 -0300
Subject: Fwd: I have a problem
From: Joe Company <joe@mycompany.com>
To: Support <support@mycompany.com>
Content-Type: text/plain; charset=UTF-8
Message-ID: <CAJQE=NOijOO4=89Scau3RZZgHWB19q=C+tnBfaLK6F1wp3v0FQ@mail.gmail.com>

---------- Forwarded message ----------
From: John Customer <john@customer.com>
Date: Mon, Jan 2, 2017 at 11:23 PM
Subject: I have a problem
To: Joe Company <joe@mycompany.com>


Hi Joe, my name is John and I have this problem....

...

One solution is to transform the email converting the From: address from joe@mycompany.com to john@customerfrom joe@mycompany.com to john@customer.com with Velocity Pre-Processing Task. The velocity script will take the From: email address in the body and replace the From: header of the forwarded message. After this pre-processing, JEMHC will handle the email as if the customer has sent the email directly to the JEMHC mail box (support@mycompany.com) and not the employee.

With the following pre-processing script, JEMHC will handle the following transformed email (Notice the changed From: header)

Example forwarded email (after task has run)

Code Block
languagetext
MIME-Version: 1.0
Received: by 10.157.39.45 with HTTP; Mon, 2 Jan 2017 18:24:15 -0800 (PST)
In-Reply-To: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com>
References: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com>
Date: Mon, 2 Jan 2017 23:24:15 -0300
Message-ID: <CAJQE=NOijOO4=89Scau3RZZgHWB19q=C+tnBfaLK6F1wp3v0FQ@mail.gmail.com>
Subject: Fwd: I have a problem
From: John Customer <john@customer.com> <---HERE!
To: Support <support@mycompany.com>
Content-Type: text/plain; charset=UTF-8

---------- Forwarded message ----------
From: John Customer <john@customer.com> <---COPIED FROM HERE!
Date: Mon, Jan 2, 2017 at 11:23 PM
Subject: I have a problem
To: Joe Company <joe@mycompany.com>


Hi Joe, my name is John and I have this problem....

Create a Pre-Processing Task

  1. Go to Profiles → Profile → Cog → Edit → Check Use PreProcessed Message and check Scripted Task Enabled

  2. Enter the following Velocity Script. The script replaces the From header with the From found in the body.

    Pre-Processing Task Script

    Code Block
    languagephp
    #if ($taskUtils.isForward($message,"Fwd:","Fw:","WG:","Doorst:","VL:","TR:","I:","FS:","VS:","VB:","RV:","PD"))
        #set ($originalFrom = $taskUtils.getHeaderValue($message, 'From'))
        #if ( $stringUtils.containsIgnoreCase($originalFrom,'@mycompany.com'))
            #set ($from = $taskUtils.getHeaderFromBody($message,"from"))
            #if ($stringUtils.isNotBlank($from))
                $taskUtils.getHeaderOrCreate($message,"from").setValue($from)
                $taskUtils.log("Setting new From: value $from")
            #end
        #end
    #end
    1. Line 1: Check if the email is a forward. This helps preventing false negative (an non forwarding email including a From: line in the body) and it saves JEMHC the complexity of extracting values from the body. If no prefix list is provided (#if ($taskUtils.isForward($message))), the system default is used.

    2. Line 2-3 It validates that the user forwarding the email is an employee so only people in team can execute this feature.

    3. Line 4: Extracts the original sender From: email and personal from the body.

    4. Line 5: Validates that there was a From: in the body.

    5. Line 6: Sets the new From so email looks like it was send by the original sender/customer. From: header should exist as it was validated in Line 3 so getHeader could be used instead of getHeaderOrCreate

    6. Line 7: Adds a line in the report confirming that the from has been changed.

  3. Enter the example email as test case

  4. Add the following assertion to test that the header has been changedTest Script

    Code Block
    languagephpnone
    $assert.assertEquals('John Customer <john@customer.com>', $taskUtils.getHeaderValue($message, 'From'))
  5. Click Validate and check the outcome. 

Test the script with a Test Case

  1. Go to Test Cases → Create → Copy the example email address. Change the To: header with the mail box address (must match the profile's catch email address)

  2. Run the test case, the report shown is the following (Notice the log line confirming that the From: address has been changed)

  3. The created issue has the customer as the reporter. If you have outbound notification mappings, the reporter/customer can receive the created issue as email so when he replies, the issue gets commented

Info

This feature works nicely with the JEMHC's Auto create JIRA Jira user. To enable it go to Profiles → Profile → Project Mapping → User and enable the feature. Revisit the groups new users will join.

Warning

Creating users may cause your license tier to go up increasing the price of the

...

Jira instance, JEMHC and other paid Add-ons.

Info

You can use Directive Set when forwarding the email. For example, write @Assignee=peter in the body so you can assign the issue when it's created.

Filter by label (Content by label)
showLabelsfalse
max5
spacesJEMHC
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel in ( "pre-processing" , "inbound" ) and type = "page" and space = "JEMHC"
labelsinbound pre-processing

...