How send email to user mentioned in comment
Asked by ????? ???????:

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/


Answers:
author: Bill Sheboy
body: Hi [@????? ???????](/t5/user/viewprofilepage/user-id/4839392) -- 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

comments: author: ????? ???????
body: It's awesome. Thanks a lot.

It works!!!


author: ????? ???????
body: 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?


author: Bill Sheboy
body: 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.


author: Szymon Cichocki
body: [@????? ???????](/t5/user/viewprofilepage/user-id/4839392) 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.


author: ????? ???????
body: [@Szymon Cichocki](/t5/user/viewprofilepage/user-id/4966606)

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


author: ????? ???????
body: ![??????1.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/201831i1E871A9536BB8DC1/image-size/large?v=v2&px=999 "??????1.JPG")![??????2.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/201828iE73B9043F21B8A66/image-size/large?v=v2&px=999 "??????2.JPG")![??????3.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/201830i1E6905C3A83E19C1/image-size/large?v=v2&px=999 "??????3.JPG")![??????4.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/201829i8E853F611CCF20A1/image-size/large?v=v2&px=999 "??????4.JPG")


author: Szymon Cichocki
body: Thank you very much for help!


author: Yaseer Jawhar
body: [@????? ???????](/t5/user/viewprofilepage/user-id/4839392) 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](/t5/user/viewprofilepage/user-id/4966606) [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)


author: Bill Sheboy
body: Hi [@Yaseer Jawhar](/t5/user/viewprofilepage/user-id/5042589)

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


author: Yaseer Jawhar
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)  
Thank you for the details.   
I will try that solution as well.  
The solution proposed by [@????? ???????](/t5/user/viewprofilepage/user-id/4839392) and [@Szymon Cichocki](/t5/user/viewprofilepage/user-id/4966606) worked for me at the moment.


author: ABDESSAMAD JARIR
body: Hello [@Yaseer Jawhar](/t5/user/viewprofilepage/user-id/5042589) ,

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

Thank you very much


author: Yaseer Jawhar
body: Yes [@ABDESSAMAD JARIR](/t5/user/viewprofilepage/user-id/5141753) I got it sorted.  
The solution adds a label to the existing

![atlassian.png](https://community.atlassian.com/t5/image/serverpage/image-id/238970i152A240DF23C780C/image-size/large?v=v2&px=999 "atlassian.png")


author: ABDESSAMAD JARIR
body: Thnaks [@Yaseer Jawhar](/t5/user/viewprofilepage/user-id/5042589) ,

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


author: Yaseer Jawhar
body: [@ABDESSAMAD JARIR](/t5/user/viewprofilepage/user-id/5141753) Great!.  
If you can post your solution here, it might help the others who come.. Cheers!


author: ABDESSAMAD JARIR
body: [@Yaseer Jawhar](/t5/user/viewprofilepage/user-id/5042589) of course, i have just change type of my costum field to user picker (in costums fields configurations)

![Capture.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/238973i47449B786FEE2AC6/image-size/large?v=v2&px=999 "Capture.JPG")


author: Szymon Cichocki
body: 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/>

comments: author: Yaseer Jawhar
body: [@Szymon Cichocki](/t5/user/viewprofilepage/user-id/4966606) Thank you. Much appreciated..


author: Szymon Cichocki
body: 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.

comments: author: Yaseer Jawhar
body: Hi [@Eszy](/t5/user/viewprofilepage/user-id/3702857)

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.


author: Yaseer Jawhar
body: [@Szymon Cichocki](/t5/user/viewprofilepage/user-id/4966606) I configured this. Thanks for your help..