How send email to user mentioned in comment

Семён Жарычев
Contributor
April 22, 2022

There is a problem.

 

I want to make rule, thet if somebody mention user in comment, this user get email with custom message.

I can take accountid from comment. But I cant take email from that accountid. It looks like a plain text.

 

Is there any abilities to get user email from accountid in rule?

Thanks/

3 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2022

Hi @Семён Жарычев -- Welcome to the Atlassian Community!

You could call the REST API with a web request using the accountId, get the email address, and then send your custom message.  Please note doing this means the user would get 2 emails per mention: one from the mention and one from the rule.

If you want to try this approach, here are some references to help you get started:

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/user-getUser

 

Kind regards,
Bill

Семён Жарычев
Contributor
April 27, 2022

It's awesome. Thanks a lot.

It works!!!

Like # people like this
Семён Жарычев
Contributor
April 28, 2022

I try this/ And for me it works well. But for other users (if in cimment mentioned not me) webhook is succesful, it can take user name, but cant take user email adress.

What could be the problem?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2022

Please check the response from the web request to determine if it was successful.  If so, try writing the response to the audit log to learn if the email address was successfully found for the user's account ID.

Szymon Cichocki June 14, 2022

@Семён Жарычев Could you show me how your's automation working? I have the same problem about mentios in automations and i can't resolve this properly.

Семён Жарычев
Contributor
June 14, 2022

@Szymon Cichocki 

LastUserCommented is a custom field with userpicker, that hidden in issue screen (both create and edit/view)

Like Szymon Cichocki likes this
Семён Жарычев
Contributor
June 14, 2022

Снимок1.JPGСнимок2.JPGСнимок3.JPGСнимок4.JPG

Like Szymon Cichocki likes this
Szymon Cichocki June 14, 2022

Thank you very much for help!

Yaseer Jawhar September 29, 2022

@Семён Жарычев I am following your steps, however I am not sure about the variable creation.

How did you create the "LastUserCommented" field to show in the dropdown?

My variable does not appear in the "choose fields to set" dropdown.

I am new to Automation so if you can attach a picture of how you created the variable and what you did to show in the dropdown.

All the other fields are working fine but I am not able to extract the mentioned user's email address. 

{{issue.comments.last.body.substringBetween("accountid:","]")}} this returns the account id but I am not aware how to get the email from this.

Thanks in advance.

cc: @Szymon Cichocki @Bill Sheboy 

Like ABDESSAMAD JARIR likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2022

Hi @Yaseer Jawhar 

If you only have the accountId value, you would need to call a REST API function from the rule (with a web request) to get the email address, or other user information.  That is described at the beginning of this thread.

Kind regards,
Bill

Yaseer Jawhar September 30, 2022

Hi @Bill Sheboy
Thank you for the details. 
I will try that solution as well.
The solution proposed by @Семён Жарычев and @Szymon Cichocki worked for me at the moment.

Like Bill Sheboy likes this
ABDESSAMAD JARIR February 8, 2023

Hello @Yaseer Jawhar ,

Did you find a solution to extract email address from mentioned user, i am blocked in this point?.

Thank you very much

Yaseer Jawhar February 8, 2023

Yes @ABDESSAMAD JARIR I got it sorted.
The solution adds a label to the existing 

atlassian.png

ABDESSAMAD JARIR February 8, 2023

Thnaks @Yaseer Jawhar ,

I already fixed it in otherway, for me, i just change a type of created costum field .

Yaseer Jawhar February 8, 2023

@ABDESSAMAD JARIR  Great!.
If you can post your solution here, it might help the others who come.. Cheers!

ABDESSAMAD JARIR February 8, 2023

@Yaseer Jawhar  of course, i have just change type of my costum field to user picker (in costums fields configurations)

Capture.JPG

0 votes
Szymon Cichocki September 29, 2022

I have only Polish version of system so i dont think my screenshots can help you.

But here you got video : https://www.youtube.com/watch?v=L1Kv3xA0TM0

And here tutorial : https://support.atlassian.com/jira-cloud-administration/docs/create-a-custom-field/

Yaseer Jawhar September 29, 2022

@Szymon Cichocki Thank you. Much appreciated..

0 votes
Szymon Cichocki September 29, 2022

Hi,

 

you have to create new custom field with a name "LastUserCommented" an type "user pick".

Remember to add this field to your issue screens.

Yaseer Jawhar September 29, 2022

Hi @Eszy 

Thank you for your response, is it possible for you to post some screenshots on how to add it, it will be very helpful.

I appreciate your time.

Yaseer Jawhar September 29, 2022

@Szymon Cichocki I configured this. Thanks for your help.. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events