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

Mention someone directly in Slack via Jira Automation

80 comments

ann.flynn May 18, 2022

Hi, I've run the script, however I'm getting a ratelimited error.  I've tried to adjust the API_DELAY_MS variable but it doesn't help.  Does anybody have a workaround for this?

Like # people like this
Haddon Fisher June 14, 2022

It's cool that there's a mechanism for this at all...has anyone turned this into an add-on yet? It would be infinitely cooler if we didn't need to execute some python ;)

Like Becky likes this
Tony Sammak June 16, 2022

@Daniel Eads Thank you for sharing this workaround, i am trying to apply it on my side and i think i am missing something that would be great if i can get your help with if possible.

when running the below command, i am getting this error...any idea what went wrong here or probably what have i missed?

  File "sync.py", line 12, in <module>

    import requests

ModuleNotFoundError: No module named 'requests'

python3 sync.py --slack_token $SLACK_TOKEN --jira_url $JIRA_URL --username $USERNAME --apikey $APIKEY

 Thank you!

Tony Sammak June 17, 2022

issue sorted, missing config.

Caleb Eno July 25, 2022

@armcaelria Just for future reference for you or anyone else, you can iterate through a list of users and print them all using the join smart value function.  For instance, making a list of all of the approvers for a card: 

<@{{issue.Approvers.properties.metadata.slack_id.join(">, <@")}}>


Everything inside of the quotes of join("") will be used between each entry.  Since each mention must be formatted as @<userid> you have to end each with > and <@.  Between those you can add any delimiter you want, in this case I used a comma.  See here for more list manipulations available in smart values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

Clarissa Rodrigues August 5, 2022

Hi @Daniel Eads

I'm getting the following error running the script. Can someone help?


ERROR:slack.web.base_client:Failed to send a request to Slack API server: IncompleteRead(42224 bytes read)

Traceback (most recent call last):

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 552, in _get_chunk_left

    chunk_left = self._read_next_chunk_size()

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 519, in _read_next_chunk_size

    return int(line, 16)

ValueError: invalid literal for int() with base 16: b''

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 569, in _readall_chunked

    chunk_left = self._get_chunk_left()

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 554, in _get_chunk_left

    raise IncompleteRead(b'')

http.client.IncompleteRead: IncompleteRead(0 bytes read)

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "sync.py", line 209, in <module>

    slack_users = gather_slack_details(slack_client)

  File "sync.py", line 78, in gather_slack_details

    next_active_users, next_cursor = _get_active_users(client, next_cursor)

  File "sync.py", line 44, in wrapper

    return func(*args, **kwargs)

  File "sync.py", line 66, in _get_active_users

    response = client.users_list(limit=SLACK_PAGINATION_LIMIT, cursor=next_cursor)

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/client.py", line 2210, in users_list

    return self.api_call("users.list", http_verb="GET", params=kwargs)

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/base_client.py", line 150, in api_call

    return self._sync_send(api_url=api_url, req_args=req_args)

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/base_client.py", line 241, in _sync_send

    return self._urllib_api_call(

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/base_client.py", line 352, in _urllib_api_call

    response = self._perform_urllib_http_request(url=url, args=request_args)

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/base_client.py", line 495, in _perform_urllib_http_request

    raise err

  File "/Users/clariar/Library/Python/3.8/lib/python/site-packages/slack/web/base_client.py", line 479, in _perform_urllib_http_request

    body: str = resp.read().decode(charset)  # read the response body here

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 462, in read

    return self._readall_chunked()

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/client.py", line 576, in _readall_chunked

    raise IncompleteRead(b''.join(value))

http.client.IncompleteRead: IncompleteRead(42224 bytes re 

 

Demi August 12, 2022

@Daniel Eads Thank you for the script, but when I try to run the script, I got 

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

 

How can I resolve this?

Marisa Chan September 14, 2022

Hi @Daniel Eads really appreciate you creating this tool! I would love to give credit where it's due when using it, and I noticed that the license number in the .py file isn't really a license number. Where can I find the real one? 

Like Becky likes this
Randy O_Neal
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

Hey, @Daniel Eads ... I have an odd scenario.  I have followed the above instructions and everything seems to be working for nearly everyone... but not everyone.  I have 1-2 people who apparently do not have Slack IDs; when automation attempts to send them messages, I get a 404 channel not found error.  When I attempt to display their IDs, it's blank.  This is what I have in the channel or user field:

@{{issue.assignee.properties.metadata.slack_id}}

Is there some way to inspect the Slack IDs via JQL or some other method?  Alternatively, is there some way to inspect and update the Slack IDs?

Please advise... and thanks in advance!

Like Anthony likes this
Richard Hausen November 15, 2022

Hello, @Daniel Eads I ran this using our Jira Sandbox as the Jira URL. The automation located all 589 Slack Members but returned the "No User Found for Email" error for every one of our users. I can visually verify that the emails addresses being located in Slack are identical to the email addresses in JIRA. 

Would the fact that I ran this to the Sandbox cause any issue? 

Thank you, 

Richard Hausen

shimizu_jun November 28, 2022

Hi  @Daniel Eads   , thank you for developing a great tool.
I have a very sad report to make. This tool has stopped working in my environment since November. This tool worked great for a little over a year.

error message -------
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'ratelimited'}
------------------------

I am happy, if this tool support Slack's rate limit.

Like # people like this
Mario Coluzzi December 12, 2022

NOPE! A way to complex to implement. Something simple i.e. only use @{{reporter.displayName}} without installing any code and tinkering with the settings????

Ashish Agrawal December 27, 2022

@Daniel Eads Tony Sammak 

I am getting the following error on running this script "sync.py" with Python 3.8.2



Traceback (most recent call last):

  File "sync.py", line 12, in <module>

    import sync

  File "/Users/ashish/Downloads/atlassian_slack/sync.py", line 13, in <module>

    import requests

ModuleNotFoundError: No module named 'requests'



Please help me!

armcaelria December 28, 2022
Like # people like this
Ashish Agrawal December 28, 2022

@armcaelria Thanks for the help!

clarissa_ar December 28, 2022

@Daniel Eads is it a feature that we will have soon? Seems a lot of people are expecting for that. :)

Like # people like this
clarissa_ar February 3, 2023

@Daniel Eads I'm not able to run it in my company, is there an ETA to have this functionality in prod?

Chris Melville February 10, 2023

I'm looking for a Data Center or Server version of the python script.  Anyone that has already done this work please post.

Darla Sheehan April 26, 2023

Hi. I have this working for the most part, but 2 questions.

1. This is working for mentioning the Assignee on the ticket in the Slack channel "issue.assignee.properties.metadata.slack_id", but what is the format of mentioning the person or people in the "Requested Participants" field on the ticket? "issue.requested.participants.properties.metadata.slack_id"??

2. All my users from slack have sync'd with Jira users from the script. How do I mention a specific user in an automation? Not a user pulled from a certain field. For example @JaneDoe for every new ticket created.

Thanks!

Taeshin Yun May 11, 2023

New API keys from JIRA not compatible 

 

Hi, since 2023 January, Jira has updated its API key length which I believe is causing an issue to run the script. 

Can it be modified to resolve the new changes to the API token length? 

 

Thanks!

 

 Screenshot 2023-05-10 at 9.12.57 PM.png

Like Luanna Gobbato likes this
Becky May 11, 2023

Hey @Darla Sheehan , How's going? 

  1. As the field 'Requested Participants' is a list, you need to specify which member of this list you want to mention. If you intend to mention everyone who is listed in this field, you can iterate through the list using the code below, it will print out one mention per line.
    {{#issue.Request participants.properties.metadata.slack_id}} <@{{.}}>{{^last}},{{/}} {{/}}


    Or use the same code provided by @Caleb Eno in the previous comments, but changing Approvers to 'Request participants' like this
    <@{{issue.Request participants.properties.metadata.slack_id.join(">, <@")}}>

    image.png
  2. You can't modify a user's properties unless you have the user as the assignee or in any field of the issue. However, if you want to go the extra mile and retrieve data from the user, you can overengineer it by making an HTTP request to pull the required information, but it is dull. Its easier the user configs his slack account to notify him everytime some keyword appears, like project key or something. 

    image.png
Jeremy Jones July 12, 2023

Hi @Daniel Eads 

Appreciate you putting this together. I have completed all the steps and run the python script which seemed run without issue (~1590 users were updated)

Unfortunately I am still having issues with the ability to mention specific users.

Here is my automation:

Auto.jpg

And this the the output

Any chance you could have a look?

Result.jpg

Becky July 13, 2023

@Jeremy Jones Have you tried to check if the propertie is really in this user? It seems like it's empty.

You can try send a Get request using this code bellow, 

curl --request GET \ 
--url 'https://your-domain.atlassian.net/rest/api/3/user/properties/metadata?accountId=5b10ac8d82e05b22cc7d4ef5' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json'

You need to have access to Eric Yang's account ID in order to substitute it in the code

Darla Sheehan July 14, 2023

Hi @Jeremy Jones ,

I actually had this exact same issue for just a few users. Atlassian support was very helpful and was able to see that the user(s) in question all had something in common.

In my case, it was because the user(s) (with the issue) had duplicated accounts, both portal-only and atlassian accounts, and since there are 2 accounts with the same email it can confuse Jira and get the information from one of the accounts.
The fix for that would be migrating the portal-only account and merging it to the user Atlassian account, you can do that by going to the https://admin.atlassian.com/, Jira Service Management - Portal Only Custimers - and searching for that user. Click on the three-dot icon had then on migrate it to Atlassian account.

After that, I believe that you will have to run the script again to resync the slack users with the Jira users.

Worth a shot...portal customers.png

Like Becky likes this
Jeremy Jones July 16, 2023

Thanks for the responses @Darla Sheehan @Becky 

It seems that this is happening for every user - is there a simple way to migrate ~1600 user profiles?

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events