Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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"'

 

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

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

209 views 2 5
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