13

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?

Arnab Datta
  • 5,356
  • 10
  • 41
  • 67

2 Answers2

19

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

Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22
1

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 \(.)"'

jonseymour
  • 1,006
  • 1
  • 12
  • 22