Elevate Your Slack Messages: Advanced Message Formatting with Jira Cloud Automation

Are you looking to make your Slack notifications from Jira Cloud more visually appealing and informative? If so, you're in the right place! By combining Jira Cloud Automation with Slack's Block Kit, you can craft rich, detailed messages that keep your team engaged and informed. This guide walks you through the process of setting up advanced message formatting for Slack notifications using Jira Cloud.

slack-channel-1__Channel__-_Gerson_Testing_-_4_new_items_-_Slack.png

Why Use Advanced Formatting?

While Jira Cloud Automation provides a straightforward "Send Slack message" action, its formatting capabilities are somewhat limited. By switching to the "Send web request" action, you unlock the ability to fully customize your message using Slack's robust Block Kit framework. This allows you to send dynamic, richly formatted messages that can include everything from text and images to interactive elements.

Getting Started

Step 1: Create an Incoming Webhook in Slack

First, you'll need to create an Incoming Webhook in Slack. This will serve as the endpoint for your messages. You can set this up quickly here. Once created, make sure to copy the Webhook URL provided—this is crucial for the next steps.

Step 2: Design Your Message with Block Kit

Next, head over to Slack's Block Kit Builder, a user-friendly tool that allows you to design your message layout visually. You can experiment with various elements like sections, dividers, images, and more to create the perfect message format. Once satisfied, copy the JSON payload generated by the Block Kit Builder. This article will be based on this layout here

Step 3: Configure the "Send Web Request" Action in Jira Cloud Automation

In your Jira Cloud Automation rule, add the "Send web request" action. This is where you'll connect Jira to Slack using the Webhook URL:

  • Web request URL: Paste the Webhook URL from Step 1.

  • HTTP method: Select POST.

  • Web request body: Choose Custom data.

  • Custom data: Insert your JSON payload within a payload={} structure. You'll include additional key-value pairs as detailed in the next step and an example will be share at the Step 5.

  • Headers:

    • Key: Content-Type

    • Value: application/x-www-form-urlencoded

Step 4: Craft the Perfect Payload

Inside your custom data payload, you'll define the following key-value pairs:

  • channel: Specify the Slack channel or user, make sure you use the MemberID instead of the username.

  • username: Choose a name that will appear as the sender.

  • icon_emoji: Select an emoji to represent the sender. This can be a standard Slack emoji or a custom one you’ve uploaded.

  • blocks: Insert the JSON payload you obtained from the Block Kit Builder.

Step 5: Enhance with Smart Values

To make your Slack messages more dynamic and informative, incorporate Jira's smart values. These allow you to automatically insert relevant data such as issue details, assignee names, or project information directly into your message. Replace placeholders within your JSON payload with these smart values to ensure the notifications are both timely and contextually rich. For example:

 

Custom data Result

 

payload={
"channel": "slack-channel-1", 
"username": "Jira Bot",
"icon_emoji": ":jira:",
"blocks": [
        {
            "type": "header",
            "text": {
                "type": "plain_text",
                "text": "New Jira Issue: {{issue.summary.jsonEncode}}",
                "emoji": true
            }
        },
        {
            "type": "section",
            "fields": [
                {
                    "type": "mrkdwn",
                    "text": "*Type:*\n{{issue.issueType.name}}"
                },
                {
                    "type": "mrkdwn",
                    "text": "*Reporter:*\n{{reporter.displayName}}"
                }
            ]
        },
        {
            "type": "section",
            "fields": [
                {
                    "type": "mrkdwn",
                    "text": "*Created On:*\n{{issue.created.jiradate}}"
                },
                {
                    "type": "mrkdwn",
                    "text": "*Assignee:*\n{{assignee.displayName}}"
                }
            ]
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "<{{url}}|View issue in Jira>"
            }
        }
    ]
}

 

slack-channel-1__Channel__-_Gerson_Testing_-_4_new_items_-_Slack.png

 

Smart value reference(green numbers):

1- {{issue.summary.jsonEncode}}

2- {{issue.issueType.name}}

3- {{reporter.displayName}}

4- {{issue.created.jiradate}}

5- {{assignee.displayName}}

6-{{url}}

 

 

Conclusion

By following these steps, you can transform routine Slack notifications into engaging, data-rich messages that provide your team with valuable insights at a glance. This approach not only enhances the visual appeal of your notifications but also leverages real-time data to keep everyone informed and aligned.

Embrace the power of Jira Cloud and Slack integration to streamline communication and boost productivity within your team. Happy automating!

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events