Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Adding Work Notes as a Comment to Existing Issues via Incoming Email in Jira Service Management (JSM

Nithin Revanna
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 20, 2024

Context: I’m setting up an automation rule in Jira Service Management (JSM) to handle incoming emails. The objective is to check if the email body contains a specific issue key (formatted as JSM Number: VPLSRV-xxxxx). If the issue key is found, I want to add the work notes from the email as a comment on the existing issue. If no issue key is found, a new issue should be created.

 

 

Specific Requirements:

Email Format Example:

Number: ABC123

JSM Number: ABCD-149

Work_notes: More info added
Screenshot 2024-09-20 183701.png

 

Objective:

  1. If the email contains an issue key:
    • I want to check if an issue with that key already exists in JSM.
    • If the issue exists, I want to add the content under Work_notes: as a comment on the issue.
    • If the issue doesn’t exist, I want to create a new issue.
  2. If no issue key is found in the email:
    • I need to create a new issue in JSM using the email details.

Steps I’ve Taken So Far:

  1. Triggered the Rule when an incoming email is received.
  2. I use a custom automation rule to extract the issue key (formatted as ABCD-xxxxx) from the email body.
  3. I use this issue key to search for an existing issue in JSM.
  4. If an issue is found, I add the content of Work_notes from the email as a comment on the existing issue.
  5. If no issue is found, I create a new issue with the details from the email.

Challenges:

  1. Issue with Searching for Existing Issue by Key: When I try to use the extracted issue key to search for the issue in JSM, I’m getting errors related to the search query being incomplete or invalid.
  2. Handling of Empty Issue Key: I want to make sure that if no issue key is found in the email, the rule falls back to creating a new issue rather than failing.

Questions for the Community:

  1. What is the best way to extract the issue key from the email body and use it in automation to check for an existing issue?
  2. How can I ensure that the search for an issue by the extracted issue key works reliably?
  3. Are there any best practices for handling cases where the issue key is missing from the email body?
  4. What would be the best approach to add the work notes as a comment on the existing issue, once it is found?

1 answer

1 vote
Walter Buggenhout
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2024

Hi @Nithin Revanna and welcome to the Community!

Could you take a step back for a second and explain how you got to the idea of trying to write an automation rule for this?

You seem to be trying to replicate the behaviour Jira's email handler is doing by default. If an email arrives in a connected mailbox, Jira will check if it references an existing issue and - if so - attach the email body as a comment to that existing issue. If no reference to an issue is found in the email, a new issue will be created.

As far as I know, there is no such thing in Jira automation as a trigger on email received. In your screenshot, you reference the Issue created event. If this was indeed an issue raised from an email channel, that means that there was no reference to an existing issue found in the first place and everything else you are trying to do after that has no point anymore, since you will never find a related issue in there. Unless of course people add random references to issue keys in emails about other issues. And that would be the part I am interested to understand 😛

Hope this helps!

Walter Buggenhout
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2024

Adding to the above; when you want to add a comment to a related issue, you need to use a branch on related issues, not to the current issue. The following frame setup might work (though it would probably require some tweaking for checking the condition):

Screenshot 2024-09-23 at 08.42.38.png

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events