Version 4 of the Slack Developer Kit for Hubot adapter uses a more recent version of the Slack Developer Kit for Node.js. As a result, there are some syntax changes within Hubot:
Before version 4, msg.message.room
would return the name of the room(e.g. general
). msg.message.room
now
returns a room identifier (e.g. C03NM270D
). If you need to translate the room id to a room name, you can look it up as
shown in
Send a message to a different channel.
Version 3 of Slack Developer Kit for Hubot supported attachments by emitting a slack.attachment
event. In version 4, you
use msg.send
, passing an object with an attachments
array:
robot.respond /send attachments/i, (msg) ->
msg.send(
attachments: [
{
text: '*error*: something bad happened'
fallback: 'error: something bad happened'
color: 'danger'
mrkdwn_in: ['text']
}
]
)
Version 3 of the Slack Developer Kit for Hubot requires different server support from previous versions. If you have an existing “hubot” integration set up you’ll need to upgrade it:
npm install hubot-slack --save
to update your code.HUBOT_SLACK_TOKEN=xoxb-1234-5678-91011-00e4dd ./bin/hubot --adapter slack
HUBOT_SLACK_TOKEN
. You can remove the other HUBOT_SLACK_*
environment variables if you want.