How do I post a bulleted list using the slack api

Viewed 5517

Background

I am trying to use the slack bolt jdk along with the following dependencies:

  // Slack bolt SDK
  implementation("com.slack.api:bolt:1.8.1")
  implementation("com.slack.api:bolt-servlet:1.8.1")
  implementation("com.slack.api:bolt-jetty:1.8.1")
  implementation("com.slack.api:slack-api-model-kotlin-extension:1.8.1")
  implementation("com.slack.api:slack-api-client-kotlin-extension:1.8.1")

What I want to achieve (in slack)

enter image description here

What I currently am getting (in slack)

enter image description here

What I've tried so far

fun SlashCommandContext.sendSectionAndAck(
  message: String,
): Response {
  slack.methods(botToken).chatPostMessage { req ->
    req
      .channel(channelId)
      .blocks {
        section {
          markdownText(message)
        }
      }
  }
  return ack()
}

It seems like the markdown is being formatted almost properly. The header and footer are both bold as intended, but for some reason, the bulleted list is not being formatted correctly. I have also tried replacing the * with - without any luck.

In my case, I can call the function with the following input:

val input = """
*Some header text in bold*
- item
- another item
*Some footer text also in bold*
"""
sendSectionAndAck(input)

What am I doing wrong?

2 Answers

The easiest workaround for this would be using '•' character itself in the text.

Slack also uses following as part of the block kit message to reflect bullet points:

"text": "• test",

"blocks": [
    {
      "type": "rich_text",
      "block_id": "erY",
      "elements": [
        {
          "type": "rich_text_list",
          "elements": [
            {
              "type": "rich_text_section",
              "elements": [
                {
                  "type": "text",
                  "text": "test"
                }
              ]
            }
          ],
          "style": "bullet",
          "indent": 0
        }
      ]
    }

Another reference:
https://superuser.com/questions/1282510/how-do-i-make-a-bullet-point-in-a-slack-message

A simple jq script to prefix a stream of lines read from stdin with bullets for the purposes of pasting into a slack message:

jq -rR '"\u2022 \(.)"'

Related