Using Webhooks to Trigger a Slack Message

viraj October 2, 2024

Hi everyone,

 

I’ve set up a Slack Webhook that sends notifications to a designated channel whenever a new issue is created with the highest priority. It’s working well so far, but I’d like to enhance the message by including the following details:

•Issue Key

•Issue Link

•Current Priority

•SLA Remaining

Here's how I assumed I would do this: 

Screenshot 2024-10-02 at 2.26.15 PM.png

Here is the entire automation: 

Screenshot 2024-10-02 at 2.26.19 PM.png

Here is the Slack message: 

Screenshot 2024-10-02 at 2.28.02 PM.png

Additionally, I’d like a second message to be triggered to the same channel when there are 6 hours of SLA remaining. I understand this might require two separate automations, but is there a way to achieve both using Webhooks? If so, what is the smart value I would use for that? 

3 answers

0 votes
Bill Sheboy
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.
October 2, 2024

Hi @viraj 

I believe your second rule to check the SLA could use a Scheduled Trigger with JQL, checking remaining() for the issues: https://support.atlassian.com/jira-software-cloud/docs/jql-functions/#remaining--

Kind regards,
Bill

viraj October 2, 2024

@Bill Sheboy Would this be something that I setup inside the original automation or would this be totally different?

Bill Sheboy
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.
October 2, 2024

It would be a separate rule: one rule with the Issue Created trigger to send the first message, and the second one with the Scheduled Trigger for soon-to-expire SLAs.

viraj October 3, 2024

@Bill Sheboy - I see. Is there any way you have an example of what that looks like? A bit new to this! 

Bill Sheboy
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.
October 3, 2024

Successfully using automation rules requires learning and experimentation.  I encourage you to try to create the rule (as you did for the first one), and if you run into challenges to ask for further help.

 

You already have a rule which uses the Issue Created trigger.  That could be copied and the trigger changed to Scheduled to start the second rule.

The only other thing needed is to create and test the JQL to find the issues.  I provided a link to the documentation on the JQL function, and you may review that to create the JQL.

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 2, 2024

Hello @viraj 

In the second example you provided you have a parentheses where you need a curly brace. That is what caused the error.

Screenshot 2024-10-02 at 2.36.35 PM.png

In the first example, what is the purpose of //returns in the message content? I have not seen that in the examples of Send Slack Message that I have found. If you remove that, what is the result?

viraj October 2, 2024

@Trudy Claspill 

Thank you, just fixed that! However, even with that change, it still does not output those fields in the message: 

 

Screenshot 2024-10-02 at 4.34.48 PM.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 2, 2024

What did you change? From which version of the rule is that last Slack message being produced?

Please provide new images of your rule and the details of the Send Slack Message component.

viraj October 3, 2024

@Trudy Claspill I changed the error you pointed out. See below: 

 

Screenshot 2024-10-03 at 11.30.06 AM.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 3, 2024

I don't have a Slack environment where I can test this, so these suggestions are just guesses.

1. Try removing all the new-lines in the message so that it is one long string of text. Maybe the new lines are causing a problem.

2. Try adding a Re-fetch Data action before the Send Slack Message action.

You may be encountering a condition where the rule is triggered so fast and the Send Slack Message action is happening before all data has been committed to the database.

viraj October 7, 2024

@Trudy Claspill I tried both of these but it didn't work :( 

 

Screenshot 2024-10-07 at 2.38.25 PM.pngScreenshot 2024-10-07 at 2.38.23 PM.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 7, 2024

I see that you are using this syntax in the smart values section:

<{{issue.toUrl}}|{{issue.key}}|{{issue.summary}}>

The help text below the Message input field says:

Use this format for links: <the link|your text>. For example, <https://slack.com> or <https://slack.com|Slack>. Learn more about Slack's formatting guide.

I am guessing that you are trying to provide a link in your message because you are using <> and included {{issue.toURL}}|

However your syntax includes two of the pipe characters (the vertical bar | ), where the example shows only one. I wonder if that could be causing a transformation problem. If you want the message to show the issue key and summary which the entire text of both associated to a link to the issue, try removing the second pipe character in your syntax.

Again, I note that I don't have an environment in which to test messages sent to Slack. I am basing my suggestions on documentation that is available on the internet and my own deductive reasoning.

0 votes
viraj October 2, 2024

I tried this as well, but it failed: 

Screenshot 2024-10-02 at 2.34.27 PM.png

Suggest an answer

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

Atlassian Community Events