Hubot-slack: Sending formatted links doesn't work

Created on 12 Dec 2014  ยท  130Comments  ยท  Source: slackapi/hubot-slack

We switched to using hubot-slack 3.0 and am seeing weird formatting with messages that include URLs.

For example, I have a script with msg.send "[#{url}|details]". The output is as follows (if url ==https://google.com):

v2: [details] << where details is a hyperlink in the channel
v3: [https://google.com%7Cdetails]

I've tried <https://google.com|details> too, but that input is printed literally in the channel.

bug

Most helpful comment

Howdy y'all, new project maintainer here. I am looking into this this week! Hold tight, we'll get this sorted.

All 130 comments

Thanks for opening the bug here - sorry we couldn't resolve the issue on twitter.

I've reproduced this. You're right that this worked in v2, but it was one of those things where it worked by accident, which makes a fix harder.

To understand what's going on here, it helps to know how Slack formats links internally. The summary is that a link in slack is represented by <url|label>, for example: <http://www.example.com|example.com>.

Hubot v2 converted URLS into links inside the adapter, and did so naively. It converted [http://www.example.com|details] into [<http://www.example.com|details]>. Note: the brackets are unbalanced, so the closing bracket shows up as part of the link.

With Hubot v3 our servers convert URLs into links, it converts [http://www.example.com|details] into [<http://www.example.com>|details]. Which is technically correct, but not what you want.

I think the answer here is for us to work out a way for hubot to send formatted text to slack (so you can send [<http://www.example.com|details>] which is what you really want. I am working on a plan to make this possible...

Thanks for responding here @paulhammond !

I wrote up a quick script to test this and the URLs are still not parsing as documented:

Hubot Script:

module.exports = (robot) ->
  robot.hear /^test msg$/i, (msg) ->
    msg.send "You can go to <https://www.google.com|google> and search."

Slack Output:

[8:55 AM] Justin: test msg
[8:55 AM] Hubot: You can go to <https://www.google.com|google> and search.

Any ideas?

FYI, I updated hubot-slack and am still experiencing this issue:

$ npm list | grep slack
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”ฌ [email protected]

+1
I also found that user email (e.g. [email protected]) would parse become [email protected] mailto:[email protected]. Why not just keep the old format?

@Ferrari that's a slightly different issue, which is fixed by #125. The old version of hubot worked with different APIs on the Slack side. The new APIs work differently, but add a lot of new functionality. Unfortunately we're still shaking out some edge cases, sorry about the problems this is causing you.

@justindowning: Unfortunately the fix for this needs some more work on our servers, so didn't make the cut for 3.2. We're still working on it...

Thanks!
We did some modify on regex match to get correct format for now,
hope can see new version come out soon.

@Ferrari We just merged the pull request, but it's not yet made it into a release. Until then you could put something like this in your package.json and I think it'll pull in the new code:

"hubot-slack": "slackhq/hubot-slack#64d7c572",

Don't forget to change it back after the next release!

I just submitted a pull request (#129) that (among other things) tweaks the formatting so it stops using both the label and the link together. It's just weird to get results like "apple.com http://apple.com".

@kballard that's a different issue. This is about sending formatted links to Slack, not receiving formatted links from Slack.

If I understand this correctly, the issue is currently server-side? Or to say it another way, there is currently nothing I can do in this or the node-slack-client repository to make links work?

Any progress or updates on this issue? We rely on a lot of formatted links in our messages, and I can't find any ways to get the 3.0 adapter to send links in a format that gets formatted correctly

Seconded.

Unfortunately the fix for this needs some more work on our servers

@paulhammond How are things looking server-side?

It would be nice if the link text allowed whitespace as well, e.g.:

msg.send "<http://www.slack.com|Check it out!>"

Is there a workaround to achieve this type of formatting?

Is this getting fixed sometimes soon peeps?

+1

+1

+1

+1

+1

+1

+1 Any closer to this?

+1 This also inhibits Slack's own custom slackbot responses from serving html.

I wonder if there are security issues. Skype started analyzing all IM for evil links because of bots using Skype APIs to send phishing and malware links. Their tradeoff was "go back on our promise of end-to-end privacy" or "save our network".

But how would evil bots get access to slack? Isn't it all private?

On 1. mai 2015, at 23.08, Phil Wolff [email protected] wrote:

+1 This also inhibits Slack's own custom slackbot responses from serving html.

I wonder if there are security issues. Skype started analyzing all IM for evil links because of bots using Skype APIs to send phishing and malware links. Their tradeoff was "go back on our promise of end-to-end privacy" or "save our network".

โ€”
Reply to this email directly or view it on GitHub.

+1

+1

+1

+1

+1

+1

+1

+1

:+1: wow took me forever to find out this was an actual issue.

+1

justindowning opened this issue on 12 Dec 2014 :( Discovered hubot recently, I've been trying to make niceurls from hubot for 3 hours now telling myself that's how it's described on their api, what's wrong with my code! I was about to open a stackoverflow question then found this issue.

174 days old, sounds like I'll edit my code to give bare links instead.

Unfortunately the fix for this needs some more work on our servers, so didn't make the cut for 3.2. We're still working on it...

Any news/plan/milestone on this?

I'm not privy to any milestone updates, but I would suggest trying Slack Attachments before sending in bare links. It can take up more space in the chat than what's usually necessary, but it looks better.

thanks @justmiles, I'll give this a try. I was sending multiple links in a single message with sha in it (not very nice to the eye), but I think I can split them in multiple attachments. :)

Fwiw incoming webhooks don't have the same problem at all, so I guess that's more of an API weirdness than something else. An ETA on this would be cool :-)

Does anyone know if this is a priority? Can the public find things out like that?

@j-walker23 you must be new around here, lol :smiley:

@omega definitely. first time i have needed to look at git issues for slack. Someone asked me how to format links in slack and i assumed it would be dead simple. I was kind of shocked when i finally landed here to see its been open for so long.

I know some companies don't publish their roadmap so they don't have to deal with the "fallout". Besides making fun of me, which i am guessing due to the first question. i laughed when i just re-read that. Being a web dev i would laugh if formatting links were a priority, but you didn't answer the question. Is there any kind of public roadmap?

Sorry, didn't intend to make fun of you, but of slack. In the beginning they were very responsive to issues, discussing details etc, but as far as I know they have been silent the past 6 (?) months or so.

We chose slack over competitors partly because they seemed to care about the community, but sadly I've been let down lately on that aspect of things.

Sorry again for my inappropriate response, and to my knowledge there is no public roadmap.

On 16. jul. 2015, at 06.06, John Walker [email protected] wrote:

@omega definitely. first time i have needed to look at git issues for slack. Someone asked me how to format links in slack and i assumed it would be dead simple. I was kind of shocked when i finally landed here to see its been open for so long.

I know some companies don't publish their roadmap so they don't have to deal with the "fallout". Besides making fun of me, which i am guessing due to the first question. i laughed when i just re-read that. Being a web dev i would laugh if formatting links were a priority, but you didn't answer the question. Is there any kind of public roadmap?

โ€”
Reply to this email directly or view it on GitHub.

ahhhh, i assumed you were calling me a noob, not them. Its sad that the internet has made me assume someone is being a dick by default. Sorry man, thanks for the reply.

That is sad, any ideas why their attitude has seemed to change?

+1

+1

+1

+1

+1
any workaround?

+1 Incredibly disappointing that this has continued to remain unfixed, and that there's not even an available workaround.

+1

I am not using hubot, but is anybody facing this issue when sending messages to default slackbot?

The workaround we're currently using is to also use the webhook library, and respond with that instead for certain types of messages that require rich formatting. It seems to work fine, but it's a little ghetto.

See this gist: https://gist.github.com/trevoro/3a9dec9b001dab2ee3a0

Suddenly, without changing my code, the channel names I publish to slack from hubot are properly linked.

Good grief, I literally just re-wrote a bunch of code to use attachments as a workaround.

I can confirm that <http://www.foo.com|www.foo.com> once again works (fixed server side by Slack). That's a relief ... after 8 months of waiting. Hopefully it'll stick around.

Good to know! I'll be updating mine tomorrow.

Nice, thanks for posting here, I'll update my fork of hubot-bitbucket :)
Edit, Just tested and

response = "[<#{url}|#{name}>]\n"
robot.messageRoom 'general', response

Prints [<https://google.com/|sample>] instead of a nice link. Am-I missing something?

Blarf! Right after I rewrote a bunch of things to use attachments.

This isn't working for me. The following prints the full unformatted string.

msg.send '<http://www.foo.com|www.foo.com>'

Just to be clear, I had formatted channel names that started working. Not external links.

You had my hopes up :(

+1

+1

+1

This is a duplicate of https://github.com/slackhq/hubot-slack/issues/43 . I just posted a work around there (basically, you can do it with attachments).

yeah, thanks.formatted link in text as attachments does work.

+1

+1

+1

+1

+1

+1

  • 1

+1

+1

+1 โ€ฆย wow, almost a year!

+1

+1

+1

+1
How crazy is this, soon comes one year when this were opened and still no fix for this quite a basic functionality.

+1

But isn't this a problem on Slack side? I tried sending the following directly on the chat box and it display the exact text I sent without formatting.

This is a link <http://google.com|google>

Btw, I'm using the web UI

Yes, there seems to be no way to format links in Slack besides notifications, so we should probably be +1 bumping this on Slack's side somehow

But isn't this a problem on Slack side? I tried sending the following directly on the chat box and it display the exact text I sent without formatting.

Over on https://github.com/slackhq/hubot-slack/issues/43 I got confirmation from Slack that using RTP doesn't allow formatted links. That includes the client and the hubot adapter as it's implemented.

I also posted a workaround, which is to use attachments:

robot.emit 'slack.attachment', {text: "<https://github.com/link/to/a/PR|myrepo #42> fix some broken">}

I also have posted a PR at https://github.com/slackhq/hubot-slack/pull/236 to use chat.postMessage which fixes this.

I'm using robot.send instead of robot.emit and I guess I'm not configuring the arguments properly. My origin is this, where text contains some links this way < url | label >, and it's showing the text as it is, with no links:

robot.send {room: userName}, text

How could I set the slack.attachment type here according to your workaround @technicalpickles ? I have tried this way but no success:

robot.send {room: userName, type: 'slack.attachment'}, text

With {text: text} as you mention in the second argument, the message is not sent at all with robot.send. The same for {attachments: [text]}.

Thanks in advance for your help!

@josal you'd still use slack attachments with that branch:

robot.emit 'slack.attachment', {room: userName, text: "<https://github.com/link/to/a/PR|myrepo #42> fix some broken">}

+1 (original report in April 2015, here : https://github.com/slackhq/hubot-slack/issues/179)

+1, guess we'll use attachments

According to https://api.slack.com/docs/formatting#linking_to_urls
"<http://www.foo.com|foo>" should work, but after more than a year, still not working!

+1

we can report this directly to them using this twitter account https://twitter.com/slackapi

+1

+1

+1

+1

+1

+ 1

+1

Hey guys, I am working in a feature that requires formatted links. Initially, I tried to use the message formatting described in the Slack API <https://www.google.com|google>, but every time I was been redirected to my Slack page. However, I tried to formatting the link in this way <https://google.com|google> and it worked (in my case I will receive the link without the www).

+1

+1

+1

+1 Still doesn't work. It's not even a complicated thing once the < | > pattern and the URL is recognized, what's going on guys?

+1

+1

+1 Link formatting works with slash commands, but not bots.

Just spoke to someone at Slack that works in the Slack API group. She asked if anyone has opened a support issue with Slack on this. Looks like that would be the next step to get some visibility on this..

+1

Went ahead and sent an email to [email protected] a few days ago. I believe someone is going to look into the issue really soon. Here is the email I got 2 days ago:

So, thanks again for bringing this up with us. We discussed this a lot here, and one of our engineers will be taking a look at the issues on that repository next week. There are a couple of pull requests out that make use of another API method which allows for more advanced formatting, so we'll be reviewing those to see if they should be merged. Again, apologies for the silence from us on this โ€” it's understandable that people are frustrated about it and we definitely should be more responsive.

โ€” Jake

+1 I'm trying to rickroll a teammate and cannot :(

+1

+1 to +100 has no effect. You'll have to open a support ticket with Slack
API and post results here.

On Wed, May 25, 2016 at 4:08 AM, Henrik Lau Eriksson <
[email protected]> wrote:

+1

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/slackhq/hubot-slack/issues/114#issuecomment-221541930

I ran into the same issue today, and landed here from a search. After a bit of tinkering, I got it to work on my end.

For what it's worth, this works for me on the Web API when I'm sending a message with parse="none".

(I also send unfurl_links=False, since we're linking to our task tracker, and there's no point in constantly showing a "sign in" attachment.)

I know nothing about coffeescript, or the implementation for hubot. (My bot relies on a python client.) But for the folks who are so inclined, maybe this is a breadcrumb to get it working on your end? Good luck!

Howdy y'all, new project maintainer here. I am looking into this this week! Hold tight, we'll get this sorted.

I ran into this issue trying to shorten our squad's channel topic into descriptive links. I want: "Appear.in | JIRA Board | Confluence Page" or similar links all visible without hovering over the topic. Thanks!

Any progress @DEGoodmanWilson? ๐Ÿ˜Ÿ

Yes, we will have something for you soon!

Setting parse='none' (as @mrcarriere mentioned above) worked for me.

+1

Will hyperlinking words and terms in a Slack message be supported when this ticket is closed? Because now it's not supported. This would be very useful for formatting Hubot messages.

Sorry, a bit behind on closing tickets. This should be fixed in v4. To use the feature, just follow the guide here: https://api.slack.com/docs/message-formatting

Omg. Thank you!

image

@rucsi is the mrkdwn_in param being passed to specify which fields to parse as markdown?

https://api.slack.com/docs/message-formatting#message_formatting

@Roach
This is not working for me, when the URL is sent in text outside the attachments for chat.update command. FYI, it works for chat.postMessage command and mrkdwn is set to true for both commands. I guess I'm missing something here.

FWIW, this remains broken, as of 2018-02-08.

+1 @kynnjo

For me, it is working now.

+1

Hello everyone.
I have an issue for slack notification on Win 10.
I used slack bot and sending formatted message, https://app.shipez.us|link
it looks like link on the bot channel but display like &lt;link&gt; on notification.
Also it works on Mac and Ubuntu, Win 8 properly but not working on only Win 10.
11

12

If anyone has a solution, please let me know.
thanks.

Why is this ticket being closed? The issue is still there - I cannot write manually nor via API a link with a label, to sow only the label.

This is not working for me as well in slack client on macos x

Can confirm this is still broken. @DEGoodmanWilson, please reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tigris picture tigris  ยท  4Comments

DonEmil picture DonEmil  ยท  9Comments

ojacques picture ojacques  ยท  9Comments

Plork picture Plork  ยท  4Comments

tlytg456 picture tlytg456  ยท  4Comments