Retrieving {{webResponse.body.ts}} from a Slack link using Jira Automation

Bryan Kim February 23, 2024

Hi everyone,

 

We managed to implement an automated system of a Slack bot creating a Slack thread and adding comments to the thread based on updates, using API REST: https://community.atlassian.com/t5/Jira-Software-questions/Connecting-Jira-and-Slack-in-a-way-that-Jira-ticket-updates-can/qaq-p/2572883?utm_source=atlcomm&utm_medium=email&utm_campaign=kudos_comment&utm_content=topic&emcs_t=S2h8ZW1haWx8a3Vkb3N8TFI5WFJCNjg5QkhJR0d8MjU3NzE2OHxLVURPU3xoSw

 

While the solution above works fantastic, our internal requirement has slightly changed in a way that we want to implement the following workflow:

  1. a team member reports a bug by creating a Slack thread in a specific Slack channel
  2. a QA engineer validates the reported bug
  3. if the reported bug is validated, the QA engineer copies a Slack thread link of step 1, and pastes it in a ticket field of a Jira ticket
  4. using API REST or other methods, Slack somehow locates the exact thread in step 1, and posts automated messages about ticket creation & status updates

I am currently stuck at implementing step 3; I would be grateful if someone could shine some light on how to make a Jira automation which takes a Slack thread link as an input, then returns {{webResponse.body.ts}} as an output. :)

 

Thanks in advance,

Bryan

 

2 answers

1 accepted

1 vote
Answer accepted
Fernando Eugênio da Silva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2024

@Bryan Kim , @Kalyan Sattaluri 

Glad to see you guys :D

Let me see if I understand what you need:

Instead of collecting the thread that is created when Jira adds a message to your channel, do you want this message to be sent in an already created thread?

What you want to do is the following:

- First of all, you will need another automation rule and for this new rule you need to ensure that you field slack thread record is filled before you're creating the issue. It means that the user who is creating the issue before click create he needs to fill the jira field with the thread :)

 

You'll be able to get your slack thread ID just access your thread and copy the link of any message inside the thread. You will see this value (image below)

Screenshot_169.png

Only these numbers inside thread_ts (including dot .) and before &cid are your thread number and you'll need to fill this value in your field before you create your Jira issue. You can use the same field earlier.

Assuming you're using the same field, you can just copy the automation who send the updates for the thread and then change your trigger in this copy to Issue created instead issue commented.

If the field to record your thread is already filled, then your message for the new issue will be published automatically in your created thread.

I'm not sure if the idea is to maintain the first automation of creating a thread when the issue is created, but if that's the case, I would say to put a condition on it of 'Slack App thread record' field IS EMPTY. This is because for issues that it identifies that the Slack Thread field is filled in, it will not create a new thread. If the field is not filled in, then it will create a new thread for the issue automatically.

Hope this helps. Let me know if you have questions.

Bryan Kim February 26, 2024

Hi @Fernando Eugênio da Silva , great to see you again! 

Instead of collecting the thread that is created when Jira adds a message to your channel, do you want this message to be sent in an already created thread?

-> Yes, that is exactly what I am looking for. :) 

 

That is amazing - I never thought of actually looking at the Slack thread link on its own. The idea is that the automation should never create a new/separate thread, instead, it should continue to write out progress update as thread comments in a given thread based on an input thread_ts. The purpose is to reduce the number of created Slack threads in a given channel, by making the automation continuously write comments in existing threads without creating new threads.

 

I will give this a try and let you know. Thank you so much for sharing your insights!

Bryan Kim February 26, 2024

@Fernando Eugênio da Silva I immediately have some questions:

A link for a Slack thread looks like this on our end, for example: https://___.slack.com/archives/___________/p1708992713265039. I noticed that the numbers after '/p' correspond to thread_ts, however, is missing a period somewhere in between.

It seems like I can only get the accurate thread_ts when I copy a link of a comment in the thread (and it looks exactly like the link in your screenshot). 

For now I have created a Jira ticket field that contains the thread link shared above, and made an automation block to create a variable: Screenshot 2024-02-27 011844.png

By doing the split operation, I am able to get the entire thread_ts digits without the period somewhere between the digits. Using smart value operations here, would it be possible to insert a period in the obtained smart value above to turn it into a proper thread_ts value? I noticed that thread_ts seems to contain a single period in front of the 6th digit from the last; in this case, the correct thread_ts would be 1708992713.265039. Do you know if this is a consistent behavior?

 

Thank you in advance!

Fernando Eugênio da Silva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2024

Hey @Bryan Kim 

This happens because https://___.slack.com/archives/___________/p1708992713265039

It's not exactly the thread ID, it's the ID of the published message. It's as if it were p for "Post" and the message ID. I also noticed that there is a dot . just before the final sixth digit, but I can't confirm if this is a pattern. In Slack's API documentation it appears to be a standard, but there is nothing explicit.

Therefore, I suggest that the link be copied from a message within the thread and not from the first message in the thread itself.

So you would have something like this: https://-_______.slack.com/archives/________/p1708992713265039?thread_ts=1708992713.265039&cid=_________

The value of 'p1708992713265039' will change the ID according to the published message, but if it is within the thread, the value of thread_ts= will always have the thread number with the dot

And finally, you can copy all the content to fill in your field: https://_________.slack.com/archives/________/p1708992713265039?thread_ts=1708992713.265039&cid=_________

In your automation use the following smartvalue to access only the thread_ts: {{issue.customfield_XXXX.substringBetween("=","&")}}

It works well and you will only have the value: 1708992713.265039

Hope this helps you :)

Bryan Kim March 12, 2024

Forgot to accept your comment as an answer, my apology for that.

 

It all worked out nicely, and our team members have been giving us positive feedback on the newly implemented automation. Once again, thank you so much.

0 votes
Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2024

@Bryan Kim  Never used slack and am using google to propose you below, so take everything I am saying with lump of salt.

But,

I think you need to set up an incoming webhook in your slack app which will post to your channel.

And then, after step 3, your Jira trigger is your new comment with "slack thread" and you call the webhook you set up earlier.

Please investigate this workflow.

Bryan Kim February 25, 2024

Hi Kalyan,

Basically I need to retrieve the message ts value, based on a Slack thread link (https://____.slack.com/....), in order to use creation of a Jira ticket as a trigger to satisfy the workflow I mentioned. I will investigate the documentation for incoming webhooks regardless, but I am still all ears if anyone knows how to exactly achieve the workflow I mentioned.

Thanks!

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2024

Hello @Bryan Kim 

I am still missing how is step 1 being done. Is it being manually or is it automated?

Also, lets page @Fernando Eugênio da Silva to see if he can check this thread when he is online. Seems like its something he can shed some light on.

Bryan Kim February 26, 2024

Hi @Kalyan Sattaluri

The conversation with Fernando gave me a good idea about how to implement what I was looking for. Thank you for bringing his attention to this post. :) 

Like Kalyan Sattaluri likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events