Open JoseFMP opened 3 years ago
Seems is related to the mrkdwn
type. If I set it to plain_text
it works just fine. What is wrong? I can see in the Slack message builder, plenty of blocks text objects have the type mrkdn
.
Any ideas?
I got to work around this issue by using mark down formatting and the option false
to disable emojis. So this is really counter-intuitive and the error message from Slack API could be improved. Not even that, but the client itself could check this before sending the HTTP request.
So using emojis + mrkdown gives an error from backend.
Thanks for reporting.
It seems that Slack does not allow emoji
property in section block now.
In this example Slack does appear to support the use of emoji
with mrkdown
in section
type blocks. However I still encounter errors when attempting to use mrkdown
.
Using mrkdown
returns this error while replacing it with plain_text
successfully uses the formatted string and uses emoji.
Indicates whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.
https://api.slack.com/reference/block-kit/composition-objects#text
FYI:
Please use (TextBlockObject).Validate()
for avoiding this error before sending a request.
See also: #895
If you are using mrkdown
then I believe emoji
has to be set to false. Emoji still get resolved though
I can confirm that the mrkdwn
type does not support the emoji
property. Attempting to set emoji
to either false or true will result in this response from the API. This is not an issue with the go client, but the block schema.
Response: {
"ok": false,
"error": "invalid_blocks",
"errors": [
"failed to match all allowed schemas [json-pointer:/blocks/2/text]",
"invalid additional property: emoji [json-pointer:/blocks/2/text]
]
}
You can verify this with the slack block kit builder app, too.
This may not be what you want to achieve with this issue, but I am sending emoji in markdown type with this.
text := ":bell: *Notification*"
block := slack.MsgOptionBlocks(
&slack.SectionBlock{
Type: slack.MBTSection,
Text: &slack.TextBlockObject{Type: "mrkdwn", Text: text},
},
)
return &block
Not sure if there have been changes to supported emojis, or just the names, but as of 2024:
But thanks to the comment from @shzxcv, I discovered that ":bell:" did work with type set as mrkdown, so I assumed I must just have wrong or outdated colon strings.
In any event, I'm sure I'm just missing a link to the current set of colon emoticon strings, but in case it helps someone out, here's a happiness spectrum of supported colon strings:
I try to send a hello world message using Slack go API.
And in Slack response, (HTTP 200) there is an upper layer error message there is just this:
invalid_blocks
and obviously the message is not posted.Since the message I am sending is so extremely simple, what could be wrong!?
Versions