Oleksii Serik
Oleksii Serik

Reputation: 81

URIs in messages sent via Slack Outgoing Webhooks are wrapped with corner brackets

I have an integration between Slack and my custom app via Slack Outgoing Webhook. Recently, I found that if a Slack message contains a URI (and this URI was recognized as URI in Slack) the JSON sent to my webhook has this link surrounded by corner brackets ('<' and '>').

So, for now, I've got two questions:

  1. Is this intended behavior or a bug?
  2. Is there any way to disable it?

Unfortunately, official Slack documentation is not very helpful.

Upvotes: 0

Views: 200

Answers (1)

Jai Pandya
Jai Pandya

Reputation: 2329

This is the intended behavior. I don't think there is a way to disable it.

The behavior you noted above, happens when a Slack message has some formatted text in it. Not only for URIs but for other strings like channels, usernames, groups as well you will encounter these brackets. You'll need to write your code in order to parse these strings.

The good news is that these are well-defined strings, and they always follow a special structure. You can consult Slack documentation here, to know more about it.

  1. Detect all sub-strings matching <(.*?)>
  2. Within those sub-strings, format content starting with #C as a channel link
  3. Format content starting with @U or @W as a user mention
  4. Format content starting with !subteam as a user group mention
  5. Format content starting with ! according to the rules for special mentions
  6. For any other content within those sub-strings, format as a URL link
  7. Once the format has been determined, check for a pipe (|) - if present, use the text following the pipe as the label for the link or mention.

Upvotes: 1

Related Questions