Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I map Jira users to my Slack users when sending notifications with Automation for Jira?

andreas Community Leader Mar 05, 2019

In the past it was possible to @mention users in Slack simply by adding this type of smart-value to your Automatin for Jira rules (see https://docs.automationforjira.com/getting-started/actions.html#send-slack-message):

Hi @{{assignee.name}}

This would at runtime be replaced with the Assignee's Jira username, and Slack would mention this user.  

Now that Jira Cloud will remove usernames & user keys due to GDPR, how can we still mention Slack users directly with Automation for Jira?

 

3 answers

1 accepted

0 votes
Answer accepted
andreas Community Leader Mar 05, 2019

I'm glad you asked ;).  So this has become a little more complicated.  

First of all: The above was never 100%  correct, and would have only worked, if your Jira usernames, mentioned your Slack usernames exactly.  If they didn't always match, then this wouldn't have worked at all.

Going forward we do want to add a better Slack integration in future that will allow mapping Slack users to their corresponding Jira users, however in lie of that, there's another solution using user properties.

 

For each user you'll have to set their slack handle as a user property in Jira.  This is now necessary, since usernames will no longer be available in Jira cloud.

To set the slack handles as properties you'll have to make some REST calls to your Jira instance:

  1. First you need to get an API token for this: https://confluence.atlassian.com/cloud/api-tokens-938839638.html
  2. Next for all of your users, you'll have to set their slack handle using this CURL command:
    curl --request PUT \
    --url 'https://YOUR_CLOUD_URL/rest/api/2/user/properties/slack?username=USERNAME' \
    -u YOUR_USERNAME:API_TOKEN \
    --header 'Content-Type: application/json' \
    --data '"SLACK_HANDLE"'

For example here's a request to set my Slack handle against our instance:

curl --request PUT \
--url 'https://codebarrel.atlassian.net/rest/api/2/user/properties/slack?username=admin' \
-u andreas@codebarrel.io:abc123def456 \
--header 'Content-Type: application/json' \
--data '"andreas"'

So this will set the 'slack' user property for the 'admin' user to 'andreas' on our 'codebarrel.atlassian.net' instance

 

Next in your Automation rules, you can use this smart-value to now mention users:

Hi @{{assignee.properties.slack|assignee.displayName}}

This will try to lookup the slack mention from user properties, and fall back to the full name, if no slack property can be found.

slack-mentions.png

This workaround still works but the query is a bit different and accountId needs to be used now as it looks like username is deprecated:

 

curl --request PUT \
--url 'https://YOUR_CLOUD_URL/rest/api/2/user/properties/slack?accountId=USERNAME' \
-u YOUR_USERNAME:API_TOKEN \
--header 'Content-Type: application/json' \
--data '"SLACK_HANDLE"'

 

Daniel Eads Atlassian Team Nov 09, 2020

In a recent ShipIt, we wrote a python script that handles (no pun intended) the Jira user properties for you when you feed it your Jira API and Slack API tokens. Check it out in this article or view the script directly here.

Oh boy, this is rough workaround with large sets of users. How much of a priority is it for you guys to improve the integration to support mentions better? Do you happen to have a timeline? I'd imagine this is quite a popular use case for JIRA automation.

Hey Haris,

Sorry about the slow response on this one. We can't give an exact timeline on it unfortunately as we have a lot of high priorities in our backlog right now. 

Once we do ship the improvement though, we will leave a note here so you know. 

Cheers,

John 

Hi @andreas ,

Which Slack property is the correct one to use for the mention to work?

Is it the "real_name" or display_name" one?

Thanks!

I had to use the slack Username for the mention to work

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

320 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you