Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed html in slack posts

I have a html message like this:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript">
        (function(){
            document.writeln("<iframe src=\"http://www.example.com" width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>");
        })();
    </script>
</head>
<body>
<h1>hello world!</h1>
</body>
</html>

How can i post this as a message in slack ? Does slack accept HTML ?

var message = {
        mrkdwn: true,
        text: "",      //This does not accept my above HTML code
        attachments : []
    };

    slacker.notify(message, function(err, result) {
        callback(err, result);
    });
like image 722
user1452936 Avatar asked Mar 28 '16 09:03

user1452936


People also ask

Can I use HTML in Slack?

Slack allows no HTML element at all. Links, bold, italic, code formatting is only possible by using a Markdown-like syntax. markup is possible without url redirection: slack.com/intl/en-in/help/articles/…

Can you embed code in Slack?

Who can use this feature? Snippets are a quick and easy way to share bits of code, configuration files, or log files in your workspace. Note: You can't currently create or share snippets from the Slack mobile apps.


1 Answers

Slack doesn´t allow HTML elements. But you can format your text with its Markdown flavor, which allows (links, bold, italic etc)

It won't allow javascripts or iframes because of security.

Details : https://api.slack.com/docs/formatting

like image 193
Eray Avatar answered Oct 06 '22 00:10

Eray