简体   繁体   中英

Hubot Slack: How to send message includes channel link?

I wrote following hubot script to send remind.

OUT_CHANNEL = "remind"

module.exports = (robot) ->
  robot.hear /test/, (res) ->
    res.send "set reminder. I tell you at ##{OUT_CHANNEL} after this."
...

This script sends below messages.

"set reminder. I tell you at #remind after this."  

But This case, the part of #remind is not link.

how to embed channel link in hubot message like human send?

Environment is below:
hubot 2.19.0
hubot-slack 3.4.2
slack-client 1.4.0
Slack.app 2.5.2

If you want Slack to show a link to a channel the correct syntax is:

<#C12345678[|text]>

Where #C12345678 is the ID of the public channel, and text can be any text (and is optional). So <#C12345678> will work too.

I am not familiar with the coffeesecript syntax, so please add any script related character encoded (eg ## for # ) as necessary.

Please note that this will only work for public channel, but not for private Slack channel.

You can read more about how to correctly link items in Slack messages in the excellent Slack API documentation n.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM