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

Link Slack Threads on JSM Chat Created Tickets

Summary

You may be using Slack with Jira to create tickets from Slack messages, such as with Atlassian Assist. However, there natively is no way to have a link to the Slack message that created the Jira ticket within the Jira ticket thread itself. How can we achieve this?

This can be achieved using a Slack Triage Channel with an Automation Rule using a couple of Slack API requests to then link the Slack Thread URL as a comment on that newly created Jira Issue.

Setup the Slack App

We will need to setup a new Slack App to obtain our API token and grant the appropriate access to the Slack App, for us to use the API and integration with Automation https://api.slack.com/apps

When setting up the app (which is built from the 'scratch' option) please ensure that the required scopes are filled out for the Bot API tokens and the User Tokens, those are listed and included in the screenshot below. This is very important to ensure your App works with the API calls used in the Automation Rule:

  • Bot and User Tokens
    • channels:history
    • groups:history
    • im:history
    • mpim:history

Screenshot 2023-08-13 at 4.39.17 PM.png

Please also be sure to use Bots and Permissions as the two features and functionality for the Slack App:

Screenshot 2023-08-13 at 4.46.38 PM.png

After that you will have a Bot User OAuth Token under that specific app within: Features -> OAuth and Permissions. This is the Authorization token you want to use for your API calls:

Screenshot 2023-08-13 at 4.33.39 PM.png

Setup the Automation Rule

Now that the Slack App is setup to interact with the Slack API we will configure the Automation Rule. This will utilize the Issue Created Trigger, when the initiator is Atlassian Assist (using a User Condition), then get the latest conversation in the history of conversations of the Slack Workspace, then get the hyperlink to that conversation, which will be posted as a comment on the Jira Issue. Please note that these API requests only require the Content-Type as application/x-www-form-urlencoded and the Authorization will always be Bearer.

 

Step 1. The first Send Web Request URL

The Web Request URL for getting the conversation history of a Slack Channel would be: https://slack.com/api/conversations.history?channel=channelID (here's a link on how to get the Channel ID: https://medium.com/@life-is-short-so-enjoy-it/slack-where-how-to-get-slack-channel-id-f6765ff37dcc)

Screenshot 2023-08-13 at 4.50.16 PM.png

Step 2. Create a Variable

The variable name can be anything. In this case I used {{lastofmessage}} as the name and the Smart Value we need to use is: {{webResponse.body.messages.ts.first}} to pull in the web responses timestamp for the last created message from that Slack Channel

Screenshot 2023-08-13 at 4.50.44 PM.png

Step 3. Second Send Web Request URL

The Web Request URL for getting the hyperlink to the message sent to the Triage Channel for your Assist created tickets: https://slack.com/api/chat.getPermalink?channel=XXXXXXXXXXXX&message_ts={{lastofmessage}}

Screenshot 2023-08-13 at 4.50.53 PM.png

Step 4. Add Slack URL as comment on Jira Issue, using the following as the comment, which can be shared with the customer or an internal only link, depending on your use case.

  • Slack Thread: {{webResponse.body.permalink}}

Screenshot 2023-08-13 at 4.54.27 PM.png

Automation in practice!

Screenshot 2023-08-13 at 5.05.22 PM.pngScreenshot 2023-08-13 at 5.07.05 PM.png

Relevant Documentation

11 comments

Sydney Hollingsworth August 24, 2023

Thanks for this article. To confirm, we would have to set this up per channel in slack? Aka if we have multiple channels in Slack connected to JSM, we would have to set this automation up per channel? 

Like Christian Beaulieu likes this
Christian Beaulieu
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2023

Hey @Sydney Hollingsworth ! Yes that is correct :) 

Pete @ Threaded Comments for Jira
Contributor
October 10, 2023

👀

Great job, mate! Love how you bridged Slack and Jira.

Like Christian Beaulieu likes this
Austin Alejandro
Contributor
December 11, 2023

When I copy this automation exactly, the automation completes successfully. However the final webresponse returns empty.

 

I also don't have any "Logging" action show up in my automation audit log. I'm wondering if that may be why? Any info helps. Thanks!Screen Shot 2023-12-11 at 10.08.10 PM.png

Christian Beaulieu
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2023

@Austin Alejandro hope you are well :) 

Could you please submit a support request mentioning this article and the issue? One of the Support Engineers on my team (or myself) would be happy to assist you!

Camilo_Santana
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!
December 18, 2023

for authorization bearer, which tokens are we using at which steps?

we create two tokens in slack, scope them but i don't know which i should be using where.

 

UPDATE: I missed a step. It looks like we use the BOT token for all calls.

Like Christian Beaulieu likes this
Austin Alejandro
Contributor
December 18, 2023

@Christian Beaulieu Thank you!

Like Christian Beaulieu likes this
Camilo_Santana
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!
January 12, 2024

hey, in the following step...

Step 2. Create a Variable

The variable name can be anything. In this case I used {{lastofmessage}} as the name and the Smart Value we need to use is: {{webResponse.body.messages.ts.first}}

You reference `webResponse.body.messages.ts.first` in the text but have `webResponse.body.messages.ts.last` in the screenshot.

 

Which is it?

 

P.S. this didn't work for me because I confused JSM chat and regular slack integration (where you can create ticket with `/jira create` in slack). D'oh!

If you know of any article that'll give us the same feature (link back to the thread that created the ticket), that would be great.

Mohammed Monir
Contributor
March 18, 2024

@Christian BeaulieuI have used the bot token but not seeing the log and the slack thread is blank.

Which token we should use? Bot or user? I have used Bot token since I don't have access for user token

Slack_.png

Mohammed Monir March 28, 2024

Got it working.. had to use user token instead of bot token to make it work. 

 

Thanks

 

Oliver Smith
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!
April 12, 2024

Are there any plans to make this a default integration? 

Assist keeps a track of the slack thread, it should be relatively simple to make it also post a link as the Comment or to a field.

I think HALP had this setup somewhere previously.

 

This is very painful to setup across a dozen + channels and growing for different customers, but feels like an almost necessary feature.

 


Edit: The original functionality 

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events