So I'm making request to Slack api to get messsage history of a particular channel. Everything works fine except the messages that are returned are still in slack format. Is there any way to convert it to HTML format?
Thanks.
So I'm making request to Slack api to get messsage history of a particular channel. Everything works fine except the messages that are returned are still in slack format. Is there any way to convert it to HTML format?
Thanks.
No. The Slack api will give you the messages in Slack markup only. If you want them in html you need to convert them yourself or find a library.
Here is how to parse the Slack markup in order to convert it into another format like HTML:
If you're retrieving messages, we've included some extra details in the sections above to help you parse the formatting syntax. This will let you properly format it for display on a different service, or to help your app fully understand the intent of a message. Here are the general steps involved for detecting advanced formatting syntax:
Detect all sub-strings matching <(.*?)>
Within those sub-strings, format content starting with #C as a channel link
Format content starting with @U or @W as a user mention
Format content starting with !subteam as a user group mention
Format content starting with ! according to the rules for special mentions
For any other content within those sub-strings, format as a URL link
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.
From official Slack documentation on Formatting.