Auto-Add Watchers When User Is Mentioned

Summary

This article is being used to demonstrate how to automatically add Watchers to Jira Issues when a User is mentioned in a comment, using Automation.

Please note that you can make this Rule either a Single Project, Multiple Project, Project Type, or a Global Automation Rule, depending on your preference. But bear in mind our: Best Practices for Optimizing Automation Rules 

Screenshot 2023-12-11 at 5.01.50 PM.png

Setup

Configure your Automation Rule Trigger to run on the Comment Types that you prefer the @mentioned Users to be added as a Watcher on. I configured my Automation Rule Trigger to Trigger on All comments.

Screenshot 2023-12-11 at 4.49.04 PM.png

Then, Create a Variable Automation Action that will use any variable name, with the Smart Value field as: 

{{issue.comments.last.body.split(" ").match("(accountid:.*)]").remove("accountid:")}}

This will look like the following in the Rule, right after the Rule Trigger:

Screenshot 2023-12-11 at 4.52.28 PM.png

After that, we will want to configure an Advanced Compare Condition. This will look at the First Value of the Variable Name that you created and evaluate if there are no watchers on the comment action. In my case that is {{addwatchers}}. That said, if there are no mentions in the comment, then the Rule does not run the Action. If it does, it will execute the Action in the Rule Next. Here is a screenshot of the Advanced Compare Condition:

Screenshot 2023-12-11 at 4.56.19 PM.png

Lastly, we will configure the Add Watchers Automation Action, using the {{addwatchers}} Smart Value:

Screenshot 2023-12-11 at 4.58.57 PM.png

This will all look like the following in the Automation Rule Flow:

Screenshot 2023-12-11 at 4.59.27 PM.png

I hope this helps!

-Christian B.

Relevant Documentation:

6 comments

Laurie Sciutti
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 21, 2024

Great article, @Christian Beaulieu !

Lexi White
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!
November 21, 2024

This is awesome! Just implemented this automation into our project. 

I also wanted to create an additional automation that applies to Descriptions, but it doesn't seem to work. I'm new to Automation, so maybe there's something simple I'm missing? 

Capture.PNG

Omri Zeman January 6, 2025

Hey its work for me also, but its work only when you tag one user only, if i wanna make it also when you tag in the comment multiply users what I need to change? :)

Susan Hauth _Jira Queen_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2025

Hi @Omri Zeman 

I just tested it and it adds all the mentioned users.  I did drop the comparison step because it doesn't fail or matter if the @mentioned user is already a watcher.  Maybe that makes a difference?

Thank you @Christian Beaulieu - super great little automation

Susan

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.
January 30, 2025

Hi @Omri Zeman 

What you describe may happen when there are newlines in the comment as the automation rule match() function does not consistently handle those well. 

The solution is to replace the newlines with spaces before the split():

{{issue.comments.last.body.replace("\n", " ").split(" ").match("(accountid:.*)]").remove("accountid:")}}

 

Kind regards,
Bill

Like Omri Zeman likes this
Omri Zeman February 3, 2025

Thanks @Bill Sheboy  work now :)

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events