Slack Block Kit and Power Automate

Unless you're looking to display limited formatted messages in Slack, you're going to have to use Block Kit. There are a variety of templates available, but let's go directly to the Block Kit Builder.

The builder is divided up into three sections - a list of block types, the Message Preview and the JSON payload. The preview allows for drag-and-drop arranging, with a handy delete button when you hover over a block on the right:

brave_JJwMgi33Ir.png

As I detailed earlier in this post, blocks are a fantastic way to organize message details, headers, and images.

brave_qx1t3ZrPVJ.png

The payload for the message block is:

  "blocks": [
    {
      "type": "header",
      "text": {
        "type": "plain_text",
        "text": "@{concat('Congratulation to <@', outputs('Team_Member_Info')?['body']?['user']?['name'], '> for receiving a ', variables('varResponse')?['Badge'], '!')}",
        "emoji": true
      }
    },
    {
      "type": "image",
      "image_url": "@{outputs('Issue_an_Assertion_to_a_single_recipient')?['body']?['result'][0]['image']}",
      "alt_text": "@{variables('varResponse')?['Badge']}"
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "@{concat('<@',outputs('Submitter_Info')?['body']?['user']?['name'], '> gave this badge for:

       _"',variables('varResponse')?['Reason'],'"_')}"
      }
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "View this badge on <@{outputs('Issue_an_Assertion_to_a_single_recipient')?['body']?['result']?[0]?['openBadgeId']}|badgr.com>"
      }
    }
  ]
}

I highly recommend using the concatenate function when you have a text string with many variables and/or special characters. Understand that Slack will give you the Slack user ID as part of the event request (like UJABCK37C), so you will need to get the user name, either by calling the users info API or have a list you can lookup against. Using the custom connector I created, you can now copy the payload and paste it into the body field of the custom connector.