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.
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:
Please also be sure to use Bots and Permissions as the two features and functionality for the Slack App:
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:
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)
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
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}}
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.
Christian Beaulieu
JSM Support Engineer 3
Atlassian
Phoenix, Arizona
2 accepted answers
11 comments