Hubot-slack: About support for unfurling all links posted by bot

Created on 23 Sep 2018  路  2Comments  路  Source: slackapi/hubot-slack

Description

From the official Slack API documentation on classic unfurling:

By default we unfurl all links in any messages posted by users. For messages posted via incoming webhooks, the chat.postMessage API method or chat.postEphemeral, we will unfurl links to media, but not other links.

If you'd like to override these defaults on a per-message basis you can pass unfurl_links or unfurl_media while posting that message. unfurl_links applies to text-based content, unfurl_media applies to media based content. These flags are mutually exclusive, the unfurl_links flag has no effect on media content.

I want my hubot to post links to tweets in a Slack channel. Problem is these links won't unfurl because tweets are not considered media. Solving this issue is easy: just send the unfurl_links flag in the request to the chat.postMessage endpoint, but looks like currently there's no way to do that in the adapter.

Is there any known workaround for this or do we need to have this included as a feature in a PR? If I add this feature myself, would you guys be willing to review it? You have some olds PRs related to this, that's why I'm asking.

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [x] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.
question needs info

Most helpful comment

hi @kevinnio, i think the following code should work:


module.exports = (robot) ->
  robot.hear /thanks/i, (res) ->
    res.send { text: "Here's a fun tweet: https://twitter.com/photographerjon/status/1046174097762332672", unfurl_links: true }

All 2 comments

hi @kevinnio, i think the following code should work:


module.exports = (robot) ->
  robot.hear /thanks/i, (res) ->
    res.send { text: "Here's a fun tweet: https://twitter.com/photographerjon/status/1046174097762332672", unfurl_links: true }

To anyone that might be wondering, that indeed worked.

Was this page helpful?
0 / 5 - 0 ratings