187

What am I doing wrong? None of the example Markdown links work so far in my Slack app.

I pasted in the example below in a chat in my Slack app. I got this example from slack markdown syntax and it still treats it as literal text in the Slack App:

[like this](http://someurl)

so I end up seeing that instead of just "like this" as a link in Slack chat.

Or maybe the above is wrong, in which case my question would then be how do you do explicitly create links in Slack? I want some text that I specify to be clickable to a specific URL (hyperlink).

pillravi
  • 3,549
  • 4
  • 14
  • 31
PositiveGuy
  • 11,583
  • 13
  • 50
  • 102
  • 1
    Seems to be unresolved bug (doesn't work for me either) https://github.com/slackhq/hubot-slack/issues/114 – Petr Gazarov Mar 30 '16 at 03:54
  • not only the are not implementing this functionality, they also do not include a dark theme! this is outrageous for such a popular tool..on the other hand this is how popular tools become unpopular all of the sudden ... – pkaramol Jan 17 '18 at 10:33
  • Slack markdown link syntax is `````` not the same as github. I think you are right that some of the Slack examples used to have that mistake in them, but github syntax does not work. – eemz Jan 31 '21 at 20:12

10 Answers10

195

Slack currently does not support hyperlinks; see this link which says:

Note: It’s not possible to hyperlink words in a Slack message.


UPDATE:

Slack has finally added this functionality to their chat interface (source):

  • Select text, then click the link icon in the formatting toolbar
  • Select text, then press Cmd+Shift+U on Mac or Ctrl+Shift+U on Windows/Linux.

Copy the link you'd like to share and paste it in the empty field under Link, then click Save.

pillravi
  • 3,549
  • 4
  • 14
  • 31
  • 19
    The question is specifically about the `slack-api` which **does** support hyperlinked text. – spencer.sm May 22 '17 at 16:38
  • 7
    This is unfortunate. Hyperlink has been around for more than 20 years, it's hard to assume this is a security issue. Pasting super long links is really annoying, at least slack should add an automatic URL shortening service (which would be optional of course). – superarts.org Apr 24 '19 at 13:25
  • 1
    It seems this is now possible. But I'm unable to get it to work. No matter what I do Slack just receives `Array` as the message in the channel. See the examples here: https://api.slack.com/messaging/composing/formatting#linking-urls – TJ Zimmerman Jul 03 '19 at 02:02
  • 2
    The original question asks about achieving this using markdown. This answer seems unrelated. – Mike T Sep 09 '20 at 19:46
  • 4
    Worth mentioned that none of these work if you select `Format messages with markup` in the settings, to get rid of the text formatting toolbar. – Roberto Jan 26 '21 at 22:44
175

Slack uses their own flavor of markdown:
Slack Markdown Links work in the following way: <http://someurl|like this>

Note: You can only do this via the Slack API and NOT just as a simple message you send via the Slack client.

Message Builder Example
enter image description here More Info in the Docs

Wilhelm Klopp
  • 4,157
  • 2
  • 25
  • 32
  • 73
    is there a way to do this via the Slack client? – Chris Miller Jul 11 '16 at 13:07
  • 5
    I don't think so. Slack explicitly does not want to overcomplicate input. More at the bottom of this help article: https://get.slack.help/hc/en-us/articles/202288908-Formatting-your-messages – Wilhelm Klopp Jul 12 '16 at 21:38
  • 312
    One way they could have avoided overcomplication would have been to stick with a popular and well-established format ... like Markdown. ;-) – joeytwiddle Nov 15 '16 at 08:44
  • 88
    +joeytwiddle That would mean Slack intentionally doing something that is user friendly and intuitive, which I'm pretty sure is against their company policy. – Peter R Feb 10 '17 at 10:51
  • @PeterR It's pretty disappointing that slack doesn't **FULLY** support markdown in messages like [gitter.im](https://gitter.im/). – Bruce Sun Aug 23 '17 at 06:36
  • 7
    Please upvote this feature request here : https://slack.canny.io/feature-requests/p/as-a-user-i-can-use-markdown-hyperlink-formatting-in-messages – Jules Sam. Randolph Nov 10 '17 at 16:36
  • 5
    Calling this a flavor of markdown is misleading. It's really more "their own formatting that sometimes looks a bit like markdown". – Jasper Mar 13 '18 at 10:52
  • you could also use this for email like – Shreyan Mehta Oct 23 '19 at 11:01
  • 1
    @JulesRandolph link is broken – Pedro77 Nov 07 '19 at 12:33
  • 2
    Today was the nth (where n>10) time that I wrote a `[title](url)` link in the Slack client, spent a minute trying to figure out if I had a typo somewhere, reversed the order of () and [], and then googled the syntax just to find this answer. How is this *less* complicated? – André Laszlo Nov 18 '19 at 11:48
34

This is not yet supported by Slack for direct messages, you can only do this using Slack API. But you can upvote the feature request I have submitted here.

lezhumain
  • 17
  • 5
Jules Sam. Randolph
  • 1,828
  • 17
  • 31
26

As of today, 2020.02.14, in one of the Slack instances I'm a member in, I can create/paste hyperlinks!

hyperlink screenshot

Example pasting hyperlink from copy Teams meeting info into Slack:

paste hyperlink example


Slack has updated their documentation. Still no markdown way of doing it though , i.e. [blah](https://stackoverflow.com) doesn't work.


Neat feature, select some text and CTRL + V when a URL is on the clipboard and it creates a hyperlink

select text & ctrl + v video]


Through some reverse engineering I was able to put text on the Windows Clipboard via C# and get it to paste into Slack:

var textToDisplay = "Test";
var url = "https://stackoverflow.com";
var arbitraryText = "Mike D.";
var dataObject = new DataObject();
//to my surprise, the Fragment comments ARE required
dataObject.SetData(DataFormats.Html, @$"<html><body>
    <!--StartFragment-->
    <a href=""{url}"">{textToDisplay}</a>
    <!--EndFragment-->
    </body></html>");
//have to set the Text format too otherwise it won't work
dataObject.SetData(DataFormats.Text, arbitraryText);
Clipboard.SetDataObject(dataObject);
spottedmahn
  • 11,379
  • 7
  • 75
  • 144
  • 22
    Upvoted because this is essentially the answer. Love the paste-to-linkify, love the hotkey... unfortunately I have disabled their WYSIWYG so that it stops messing with other things I'm trying to write, and there doesn't seem to be any alternative for those of us happy using markdown(-ish) formatting in plain text. – Tyler James Young Apr 06 '20 at 18:30
  • [@Tyler](https://stackoverflow.com/users/2506703/tyler-james-young). I'm glad I'm not the only one that does this too! – frakman1 May 01 '20 at 13:53
  • 1
    I managed to make it work without the fragment comments – tennabey Jul 08 '20 at 21:18
9

If you are using slack-bot or something that uses Slack API, you'll be able to use mrkdwn syntax for your messages.

<http://www.example.com|This message is a link>

Reference: https://api.slack.com/reference/surfaces/formatting

Prakhil TP
  • 344
  • 3
  • 7
6

Reuben's answer will work, but it will look like an untitled file upload, as seen here: untitled file posted to Slack. With a slight modification, however, you can easily post a natural looking message featuring a working hyperlink such as you see here: natural looking Slack post with hyperlink by using the chat.postMessage Slack api method instead of "files.upload" and adopting Slack's own message formatting instead of Markdown. That would be done like this:

curl -F text="*<https://someurl|like this>*" -F as_user=true -F link_names=true -F channel=C1.....7L -F token=xoxp-... https://slack.com/api/chat.postMessage

The link_names=true argument isn't used in this example, but is useful to be able to @mention users and #refer to channels.

4

As an alternative to Slack Messages (covered in Wilhem's answer), you can create Slack Posts via the API and use at least some Markdown. These both create <h2><a href="https://someurl">like this</a></h2>:

curl -F filetype=post -F content="# [like this](https://someurl)" -F channels=C1.....7L -F token=xoxp-... https://slack.com/api/files.upload

or swap content="..." for file=@post.md

curl -F filetype=post -F file=@post.md -F channels=C1.....7L -F token=xoxp-... https://slack.com/api/files.upload

This is using files.upload. I think the easiest way to try posting as yourself is with a legacy token. Get the channel ID from the URI of the channel.

Reuben
  • 121
  • 1
  • 4
2

I wrote this code to convert markdown links within a body of text into the link format slack expects:

      // Pretty hacky, convert [sup](http://foo.com) to <http://foo.com|sup>
      const reformatLinks = /\[(.*?)\]\((.*?)\)/g
      const slackBody = body.replace(reformatLinks, (_m, text, url) => `<${url}|${text}>`)

From what I can tell slack does not support image links inside text.

ratbeard
  • 107
  • 1
  • 5
-1

Had a problem with this form of markdown when the url is involving a vertical bar | solved this with urltext.replace("|", "%7C")

lukasell
  • 361
  • 1
  • 2
  • 10
-5

Super late to the party but I recently discovered that you can use a URL shortener to create a https link which you can then reference using markdown links.