Automation Help: Add watcher when user mentioned in comments

Mateus Almeida August 30, 2022

Hi Jira Community,

 

Looking for some help using the native automation tools in Jira Cloud to create automation where if a user is mentioned/tagged in the comments section, they'll be added as a watcher for future issue updates. My thought process here is that if a user is tagged, it's likely they are then impacted or associated with the issue and may want updates on that particular issue. Do I need to add a specific JQL condition after "Comment is the main action" rule trigger? Any help would be greatly appreciated! 

2 answers

2 accepted

3 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.
August 30, 2022

Hi @Mateus Almeida -- Welcome to the Atlassian Community!

Until such a feature is built into Jira Cloud, what you can try is creating an automation rule, triggered on Issue Commented, extract the mentioned users' accountId values, and then add them as watchers.  To do this, you will need...

  • to use a regular expression to get the accountId values, for example...
{{issue.comments.last.body.split(" ").match("(accountId:.*)]").remove("accountId:")}}
  • a condition test to check for empty values
  • an advanced branch to iterate over the values, and
  • an action to add the watchers.

Kind regards,
Bill

 

UPDATED: Another community member noted my rule did not handle multiple mentions on the same text line, and so I revised this one to first split on spaces before searching for the mention-markup information.

Mateus Almeida April 11, 2023

Reply Removed

Test work August 25, 2023

I have tried the above which hasn't worked, note that the project is using issue security 

Trying to add @mention and then  add this to the watcher as to selecting a user.

 

The SL has a watcher 

Here's the rule

When: Issue commented           Comment Type: Comment on the main action
Then: Create variable             Variable name: varAddWatcher  Smart Value: {{issue.comments.last.body.split(" ").match("(accountid:.*)]").remove("accountid:")}}

Advanced compare condition:   First value: varAddWatcher  Condition: does not equal Second Value: empty
Then: add Watcher   {{varAddWatcher}}
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.
August 25, 2023

Hi @Test work 

Please review the suggested solution as you appear to be missing the part to use an advanced branch to iterate over the values.

As an alternative, I believe you may also try adding them in one step using advanced edit with JSON.

Kind regards,
Bill

Test work August 29, 2023

 

See the screen shot enclosed which i have used condition and Advanced Branching.

The other issue is the watcher- If I mention a person , that person should be added into the watcher field, the option of action doesn't work.

Test work August 29, 2023

1st Rule Watcher.PNG

Test work August 29, 2023

2nd Rule Watcher.PNG

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.
August 29, 2023

Do you see the red exclamation mark in your action to Add Watchers?  There is something wrong with that action.  Please review that to find the problem, and if you are unable to find it, post an image of your Add Watcher action so the community can try to help.

Based upon your rule, you should be using the Variable Name defined in the advanced branch: {{WhatSmartvaluesshouldbeused}}

And remember that smart values are name, spacing, and case-sensitive.  So it must exactly match your defined variable name.

Test work August 29, 2023

I get the red exclamation mark  as I left that blank - however I don't want to insert a name.

If I @ mention in the comment, then that name should be added to the watcher 
See the additional screen

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.
August 29, 2023

To use that action, you must enter something.

The original question for this thread was to add watchers based on mentions in the comments.  And all of the rule logic suggested up to this point was so the smart value can be entered in the Add Watcher action.

If you now want something else, I suggest creating a new question, with a new post, and clearly describe what you are trying to accomplish.  Thanks!

Test work August 29, 2023

Sure, Thank you for your support Bill

0 votes
Answer accepted
Summer.Hogan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2022

@Mateus Almeida - are you using server or cloud? If you are using server, this feature has been enabled where @mentions on comments make the mentioned user a watcher. In cloud, there is a suggestion open in the Jira Cloud project that is in the "Reviewing" status. See here: https://jira.atlassian.com/browse/JRACLOUD-31869. I voted for this feature for you.

At this point in cloud, @mentions are used to just reach out to someone once. Here is some more information: https://www.atlassian.com/blog/jira-software/using-watchers-and-mentions-effectively 

Mateus Almeida April 11, 2023

Reply Removed

Pooja Singh
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 28, 2023

Dear @Summer_Hogan

We are using server data center version of Jira, but we are unable to add @mentioned user to watchers list automatically.

Is there anything that we need to enable in order for this feature to work?

Or the script id the only option for server too?

Any help would be highly appreciated.

Kind Regards,

Pooja

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events