Socket
Socket
Sign inDemoInstall

hubot-slack

Package Overview
Dependencies
159
Maintainers
6
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.4.0 to 4.5.0

.github/contributing.md

8

docs/_pages/about.md

@@ -13,5 +13,5 @@ ---

* [License](<a href="https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/LICENSE">)
* [Code of Conduct](<a href="https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/CODE_OF_CONDUCT.md">)
* [Contributing](<a href="https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/CONTRIBUTING.md">)
* [Contributor License Agreement](<a href="https://docs.google.com/a/slack-corp.com/forms/d/e/1FAIpQLSfzjVoCM7ohBnjWf7eDYQxzti1EPpinsIJQA5RAUBwJKRUQHg/viewform">)
* [License](https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/LICENSE)
* [Code of Conduct](https://slackhq.github.io/code-of-conduct)
* [Contributing](https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/.github/contributing.md)
* [Contributor License Agreement](https://cla-assistant.io/slackapi/hubot-slack)

@@ -9,2 +9,4 @@ ---

- title: Customizing the RTM Client
- title: Activate logging for debugging
- title: Accessing more API methods and distribution
---

@@ -15,3 +17,3 @@

Under the hood, each Hubot using this adapter is connected to Slack using the [RTM API](https://api.slack.com/rtm). A
connection to the RTM API is initiated using the Web API method [`rtm.start`](https://api.slack.com/methods/rtm.start).
connection to the RTM API is initiated using [`rtm.start`](https://api.slack.com/methods/rtm.start).
By default, the adapter calls this method with only the required `token` parameter. If you have more specialized needs,

@@ -23,3 +25,3 @@ such as opting into MPIM data, you can add additional parameters to that Web API call by setting an environment

```
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_SLACK_RTM_OPTIONS='{ "mpim_aware": true }' bin/hubot --adapter slack
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_SLACK_RTM_START_OPTS='{ "mpim_aware": true }' ./bin/hubot --adapter slack
```

@@ -29,14 +31,53 @@

The RTM connection is handled by the `RtmClient` implementation from our handy
[Slack SDK for Node](https://github.com/slackapi/node-slack-sdk). By default, the adapter instantiates the client with
only the required `token` parameter, but many more are
[available in the documentation](https://slackapi.github.io/node-slack-sdk/reference/RTMClient#new_RTMClient_new). You
can customize the options for the `RtmClient` instance by setting an environment variable. The variable is called
`HUBOT_SLACK_RTM_CLIENT_OPTS` and its value should be a JSON-encoded string with the additional parameters as key-value
pairs. Note that not every option can only be set to JSON-encodable values; you won't be able to create an instance of
`SlackDataStore` and pass it in via a JSON string but you can set the option to `false` to opt out of using a Data Store
(not recommended). Here is an example of running hubot with a custom retry configuration:
The RTM connection is handled by the `RtmClient` class from our handy
**Slack Developer Kit for Node.js version 3**. By default, the adapter instantiates the client with the required
`token` parameter, but more options are available. You can customize the options for the `RtmClient` instance by setting
an environment variable. The variable is called `HUBOT_SLACK_RTM_CLIENT_OPTS`, and its value should be a JSON-encoded
string with the additional parameters as key-value pairs. Note that not every option can only be set to JSON-encodable
values; you won't be able to create an instance of `SlackDataStore` and pass it in via a JSON string but you can set the
option to `false` to opt out of using a Data Store (not recommended). Here is an example of running hubot with a custom
retry configuration:
```
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_SLACK_RTM_CLIENT_OPTS='{ "retryConfig": { "retries": 20 } }' bin/hubot --adapter slack
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_SLACK_RTM_CLIENT_OPTS='{ "retryConfig": { "retries": 20 } }' ./bin/hubot --adapter slack
```
## Activate logging for debugging
Hubot has a flag for setting a log level, called `HUBOT_LOG_LEVEL`. This adapter peforms all of its logging through
Hubot, so setting it to its most detailed level, `debug`, can give you much more detailed information about activity
at runtime. Here is an example of running hubot with its log level set to `debug`:
```
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_LOG_LEVEL=debug ./bin/hubot --adapter slack
```
The underlying **Slack Developer Kit for Node.js** can also be supplied with a log level to get _even more_ information
at runtime. Here is an example of combining both of these options:
```
$ HUBOT_SLACK_TOKEN=xoxb-xxxxx HUBOT_LOG_LEVEL=debug HUBOT_SLACK_RTM_CLIENT_OPTS='{ "logLevel": "debug" }' ./bin/hubot --adapter slack
```
## Accessing more API methods and distribution
You might find your Hubot unable to access a Web API method. For some methods, you can resolve this by transitioning
from an App Bot to a Custom Bot (these methods are [listed here](https://api.slack.com/bot-users#bot_methods)). If the
method isn't available to a Custom Bot, you'll have to use an App Bot and also manage a new token.
You will also need to manage a new token if you're considering distributing your Hubot powered app in the App Directory.
Start by finding the new scope that your app will require. Required scopes are specified on the documentation for each
[Web API method](https://api.slack.com/methods). Add this scope to your app on the "OAuth and Permissions" page of your
app configuration. Once you save the changes, you need to install the app on your development workspace once again.
After installing the app and authorizing the new scope, you'll notice a new **OAuth Access Token** (begins with `xoxp`).
This is the new token that you'll need to manage. We recommend putting the new token in another environment variable,
and using it to initialize a new `WebClient` object, as described in
[Using the Slack Web API]({{ site.baseurl }}{% link _pages/basic_usage.md %}#{{ "Using the Slack Web API" | slugify }}). For
example, if you put the new token in an environment variable called `SLACK_OAUTH_TOKEN`, you'd simply change the
initialization of the `WebClient` object to the following:
```coffeescript
web = new WebClient process.env.SLACK_OAUTH_TOKEN
```

@@ -6,2 +6,3 @@ ---

order: 2
hidden: true
headings:

@@ -15,3 +16,3 @@ - title: Handling tokens and other sensitive data

to never explicitly hardcode them.
Try to avoid this when possible:

@@ -23,3 +24,3 @@

If you commit this code to GitHub, the world gains access to this token's team. Rather, we recommend you pass tokens as
If you commit this code to GitHub, the world gains access to this token's team. Rather, we recommend you pass tokens as
environment variables, or persist them in a database that is accessed at runtime. You can add a token to the

@@ -26,0 +27,0 @@ environment by starting your app as:

@@ -8,9 +8,14 @@ ---

- title: Listening for a message
- title: Messages directed to your bot
- title: Posting a response
- title: Messages directed to your Hubot
- title: Sending a response
- title: User and conversation mentions
- title: Using the Slack Web API
- title: Working with threads
- title: Message reactions
- title: General Web API patterns
- title: Presence changes
- title: Send a message to a different channel
- title: Text formatting and raw messages
---
Most Hubots are designed to react to user input&mdash;a user makes a request, and Hubot responds, often after going out
Most Hubots are designed to react to user input – a user makes a request, and Hubot responds, often after going out
into the world to trigger some action (building your code, deploying to production, and so on). Many of the tasks

@@ -20,7 +25,2 @@ you'd like to accomplish are already well documented in the [official Hubot documentation](https://hubot.github.com/docs/).

Each of the examples below are ready to be included as a [Hubot script](https://hubot.github.com/docs/scripting/)
&mdash;just drop them into the `scripts` folder.
See [Tokens & Authentication]({{ site.baseurl | prepend: site.url }}/auth) for API token best practices.
--------

@@ -30,30 +30,30 @@

Most tasks with Hubot are no different with the Slack adapter than they are for other adapters.
You can listen for messages in any channel that your Hubot has been invited into very simply, by using `robot.hear` with
a RegExp to match against. Any message that matches the RegExp will trigger the function.
You can listen for messages in any channel that your Hubot has been invited into very simply, by defining a regex
to match against. Any message that matches your regex will trigger the callback you assign to that regex.
```coffeescript
module.exports = (robot) ->
# Any message that contains "badger" will trigger the following function
robot.hear /badger/i, (res) ->
# res.message is a SlackTextMessage instance that represents the incoming message Hubot just heard
robot.logger.debug "Received message #{res.message.text}"
```
Hubot will only hear messages in converastions where it is a member. A human must invite Hubot into conversations
(shortcut: `/invite @username`).
--------
## Messages directed to your bot
## Messages directed to your Hubot
If you want to specifically listen for messages that mention your bot, again the pattern here is no different than
for any other Hubot. You define a regex to match against. Any message that matches your regex _and_ either includes
an @-mention of your bot, or occurs within a DM with your bot will trigger the callback you assign to that regex.
If you want to specifically listen for messages that mention your Hubot, use the `robot.respond` method. You can also
be more specific using a RegExp (or don't be more specific, `/.*/` will match all messages).
Note that Slack has the concept of [Threaded messages](https://api.slack.com/docs/message-threading) and in order
to allow for your bot to respond in the context of those threaded messages the `thread_ts` field is available on
the `res.message` object provided. This field will automatically be passed along for you, as a result your bot
will automatically reply in the context of the thread, if the message to your bot originated from one.
```coffeescript
module.exports = (robot) ->
# Any message that contains "badger" and is directed at Hubot (in a DM or starting with its name)
# will trigger the following function
robot.respond /badger/i, (res) ->

@@ -65,6 +65,6 @@ robot.logger.debug "Received message #{res.message.text}"

## Posting a response
## Sending a response
Responding to a message is straightforward, regardless of whether the message was sent to your bot specifically or
to anyone in general.
Responding to a message is straightforward, regardless of whether the message was sent to your Hubot specifically or to
anyone in general.

@@ -75,2 +75,3 @@ ```coffeescript

robot.hear /badger/i, (res) ->
# Hubot sends a response to the same channel it heard the incoming message
res.send "Yes, more badgers please!"

@@ -81,16 +82,133 @@ ```

## User and conversation mentions
When your Hubot hears a message, it might contain mentions of other users, channels, or groups. The `text` property is
pretty and human-readable. But this isn't great for scripting because
[usernames are deprecated](https://api.slack.com/changelog/2017-09-the-one-about-usernames), and display names and
conversation names can change. What you really want is an ID; it's stable to store and gives your Hubot an easy way to
write mentions that have the user's preferred display name.
Each incoming message has a `mentions` array that contains the ID and any other information known about the user or
conversation that was mentioned.
```coffeescript
module.exports = (robot) ->
# A map of user IDs to scores
thank_scores = {}
robot.hear /thanks/i, (res) ->
# filter mentions to just user mentions
user_mentions = (mention for mention in res.message.mentions when mention.type is "user")
# when there are user mentions...
if user_mentions.length > 0
response_text = ""
# process each mention
for { id } in user_mentions
# increment the thank score
thank_scores[id] = if thank_scores[id]? then (thank_scores[id] + 1) else 1
# show the total score in the message with a properly formatted mention (uses display name)
response_text += "<@#{id}> has been thanked #{thank_scores[id]} times!\n"
# send the response
res.send response_text
```
--------
## Using the Slack Web API
You can access the [Slack Web API](https://api.slack.com/web_api) from your Hubot. Start by installing the
[Slack Developer Kit for Node.js](https://slackapi.github.io/node-slack-sdk/) package into your Hubot project:
```
npm install --save @slack/client
```
Next, modify your script to instatiate a `WebClient` object using the same token your Hubot used to connect.
```coffeescript
# Import the Slack Developer Kit
{WebClient} = require "@slack/client"
module.exports = (robot) ->
web = new WebClient robot.adapter.options.token
# remainder of your script...
```
Finally, anytime you'd like to call a Web API method, call it like a method on `web`.
```coffeescript
# Import the Slack Developer Kit
{WebClient} = require "@slack/client"
module.exports = (robot) ->
web = new WebClient robot.adapter.options.token
robot.hear /test/i, (res) ->
web.api.test()
.then () -> res.send "Your connection to the Slack API is working!"
.catch (error) -> res.send "Your connection to the Slack API failed :("
```
You only have access to the Web API methods that your bot token is authorized to use. Depending on
[how you installed Hubot]({{ site.baseurl }}{% link index.md %}#{{ "Getting a Slack token" | slugify }}), the
exact list of methods is either those checked for Custom Bots or App Bots in the
[bot methods table](https://api.slack.com/bot-users#bot_methods). If you have an App Bot and need to access a method
only available to a Custom Bot, now might be the right time to switch. If you need access to a method that isn't listed
in the table at all, see
[Accessing more API methods and distribution]({{ site.baseurl }}{% link _pages/advanced_usage.md %}#{{ "Accessing more API methods and distribution" | slugify }}).
--------
## Working with threads
Slack has the concept of [threaded messages](https://api.slack.com/docs/message-threading), which Hubot wasn't
directly designed to support. However, with a little bit of knowledge about the underlying messages, you can create
new threads and send messages into a thread using Hubot.
```coffeescript
module.exports = (robot) ->
robot.hear /badger/i, (res) ->
if res.message.thread_ts?
# The incoming message was inside a thread, responding normally will continue the thread
res.send "Did someone say BADGER?"
else
# The incoming message was not inside a thread, so lets respond by creating a new thread
res.message.thread_ts = res.message.rawMessage.ts
res.send "Slight digression, we need to talk about these BADGERS"
```
If you want to use the `reply_broadcast` feature of threads, you'll have to
[use the Web API directly](#{{"Using the Slack Web API" | slugify}}) for the `chat.postMessage` method.
--------
## Message reactions
Of course, Slack is more than just text message. Users can post emoji responses to messages as well—and your bot can both
listen for these, and post reactions of its own. Here is a simple recipe to listen for message reactions, and to add
the same reaction back to the same message
Of course, Slack is more than just text messages. Users can send
[emoji reactions](https://get.slack.help/hc/en-us/articles/206870317-Emoji-reactions) to messages as well. Your Hubot
can both listen for these from other users, and send reactions of its own. Here is a recipe to listen for
emoji reactions and add the same reaction back to the same message.
```coffeescript
{WebClient} = require "@slack/client"
module.exports = (robot) ->
web = new WebClient robot.adapter.options.token
robot.react (res) ->
robot.logger.debug res.message.type, res.message.reaction
if res.message.type == "added"
robot.adapter.client.web.reactions.add(res.message.reaction, {channel: res.message.item.channel, timestamp: res.message.item.ts})
# res.message is a ReactionMessage instance that represents the reaction Hubot just heard
if res.message.type == "added" and res.message.item.type == "message"
# res.messsage.reaction is the emoji alias for the reaction Hubot just heard
web.reactions.add
name: res.message.reaction,
channel: res.message.item.channel,
timestamp: res.message.item.ts
```

@@ -100,7 +218,5 @@

## General Web API patterns
## Presence changes
You can access much of the [Slack Web API](https://api.slack.com/bot-users#api_usage) with your bot. The `robot`
object uses [Slack Developer Kit for Node.js](slackapi.github.io/node-slack-sdk/) to access the Slack API, and an instance of the
Web API wrapper is available in `robot.client.web`. So, you can call API endpoints in the following way:
Each time a user changes from away to active, or vice-versa, Hubot can listen that event.

@@ -110,9 +226,72 @@ ```coffeescript

robot.hear /test/i, (res) ->
robot.adapter.client.web.api.test() # call `api.test` endpoint
# There are better ways to post messages of course
# Notice the _required_ arguments `channel` and `text`, and the _optional_ arguments `as_user`, and `unfurl_links`
robot.adapter.client.web.chat.postMessage(res.message.room, "This is a message!", {as_user: true, unfurl_links: false})
robot.presenceChange (res) ->
# res.message is a PresenceMessage instance that represents the presence change Hubot just heard
names = (user.name for user in res.message.users).join ", "
message = if res.message.presence is "away" then "Bye bye #{names}" else "Glad you are back #{names}"
robot.logger.debug message
```
--------
## Send a message to a different channel
Responding right back to an incoming message is great, but sometimes you want send a message to a different channel.
Hubot calls channels "rooms" and this adapter identifies rooms by channel ID, **not by channel name**. If your Hubot
wants to send a message into another channel, it first needs to find that channel ID. You might get a channel ID from
a previous message or you might use the Web API to translate a channel name to a channel ID. In the following example,
we use the Web API to translate to default named channel to an ID and then store it in a variable. There's a listener
set up that can update that variable based on an incoming message. Then a new listener is used to send data into
the current channel in the variable, no matter where the incoming message is received.
```coffeescript
{WebClient} = require "@slack/client"
module.exports = (robot) ->
web = new WebClient robot.adapter.options.token
# When the script starts up, there is no notification room
notification_room = undefined
# Immediately, a request is made to the Slack Web API to translate a default channel name into an ID
default_channel_name = "general"
web.channels.list()
.then (api_response) ->
# List is searched for the channel with the right name, and the notification_room is updated
room = api_response.channels.find (channel) -> channel.name is default_channel_name
notification_room = room.id if room?
# NOTE: for workspaces with a large number of channels, this result in a timeout error. Use pagination.
.catch (error) -> robot.logger.error error.message
# Any message that says "send updates here" will change the notification room
robot.hear /send updates here/i, (res) ->
notification_room = res.message.rawMessage.channel.id
# Any message that says "my update" will cause Hubot to echo that message to the notification room
robot.hear /my update/i, (res) ->
if notification_room?
robot.messageRoom(notification_room, "An update from: <@#{res.message.user.id}>: '#{res.message.text}'")
```
--------
## Text formatting and raw messages
When your Hubot receives a message, the adapter does its best to make the `text` easy to work with by formatting links
and mentions. This formatting sometimes removes meaningful information from the text. If you want to access the
unaltered text in the incoming message, you can use the `rawText` property. Similarly, if you need to access any other
property of the incoming Slack message, use the `rawMessage` property.
```coffeescript
module.exports = (robot) ->
# listen to all incoming messages
robot.hear /.*/, (res) ->
# find URLs in the rawText
urls = res.message.rawText.match /https?:\/\/[^\|>\s]+/gi
# log each link found
robot.logger.debug ("link shared: #{url}" for url in urls).join("\n") if urls
```

@@ -5,2 +5,3 @@ ---

permalink: /faq
hidden: true
order: 6

@@ -42,3 +43,3 @@ headings:

What an excellent question. First of all, please have a look at our general
[contributing guidelines](https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/CONTRIBUTING.md).
[contributing guidelines](https://github.com/{{ site.github_username }}/{{ site.repo_name }}/blob/master/.github/contributing.md).
We'll wait for you here.

@@ -64,2 +65,2 @@

If you are editing one of the many markdown files in the `docs` folder, there is nothing you need to do: GitHub will
do the right thing automatically. Hooray!
do the right thing automatically. Hooray!

@@ -13,21 +13,13 @@ ---

Version 4 of the {{ site.product_name }} adapter uses a more recent version of the
Slack Developer Kit for Node.js. As a result, there are some syntax changes within Hubot:
Version 4 of the {{ site.product_name }} adapter uses a more recent version of the Slack Developer Kit for Node.js. As a
result, there are some syntax changes within Hubot:
1. 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 with the client:
1. 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]({{ site.baseurl }}{% link _pages/basic_usage.md %}#{{ "Send a message to a different channel" | slugify }}).
```coffeescript
robot.respond /what room am i in\?/i, (msg) ->
room = msg.message.room
roomName = robot.adapter.client.rtm.dataStore.getChannelById(room).name
msg.send roomName
```
2. Version 3 of {{ site.product_name }} supported attachments by emitting a `slack.attachment` event. In version 4, you
use `msg.send`, passing an object with an `attachments` array:
2. Version 3 of {{ site.product_name }} supported attachments by emitting a
`slack.attachment` event. In version 4, you use `msg.send`, passing an object
with an `attachments` array:
```coffeescript

@@ -49,17 +41,12 @@ robot.respond /send attachments/i, (msg) ->

Version 3 of the {{ site.product_name }} requires different server support from
previous versions. If you have an existing "hubot" integration set up you'll
need to upgrade it:
Version 3 of the {{ site.product_name }} requires different server support from previous versions. If you have an
existing "hubot" integration set up you'll need to upgrade it:
- Go to https://my.slack.com/services/new/hubot and create a new hubot
integration
- Run `npm install hubot-slack --save`
to update your code.
- Test your bot locally using:
`HUBOT_SLACK_TOKEN=xoxb-1234-5678-91011-00e4dd ./bin/hubot --adapter slack`
- Update your production startup scripts to pass the new `HUBOT_SLACK_TOKEN`.
You can remove the other `HUBOT_SLACK_*` environment variables if you want.
- Go to https://my.slack.com/services/new/hubot and create a new hubot integration
- Run `npm install hubot-slack --save` to update your code.
- Test your bot locally using: `HUBOT_SLACK_TOKEN=xoxb-1234-5678-91011-00e4dd ./bin/hubot --adapter slack`
- Update your production startup scripts to pass the new `HUBOT_SLACK_TOKEN`. You can remove the other `HUBOT_SLACK_*`
environment variables if you want.
- Deploy your new hubot to production.
- Once you're happy it works, disable the old hubot integration from
https://my.slack.com/services
- Once you're happy it works, disable the old hubot integration from https://my.slack.com/services

@@ -6,27 +6,32 @@ ---

headings:
- title: Motivation
- title: Requirements
- title: Installation
- title: Basic Setup
- title: Getting a Slack Token
- title: Running Hubot
- title: Trick it out
- title: Getting Help
---
So you want to get started with ChatOps using Hubot and Slack? We've got you covered. {{ site.product_name }} is an
adapter that connects your Hubot scripts to your Slack team, giving you and your fellow DevOps engineers a new best friend: your very own ChatOps bot.
So you want to get started using Hubot and Slack? We've got you covered. {{ site.product_name }} is an
adapter that connects your Hubot scripts to your Slack team, giving you and your fellow teammates a new best friend:
your very own scriptable, pluggable bot.
## Requirements and Installation
[What is Hubot and when should I use it?](https://hubot.github.com/) In short, it makes developing ChatOps-style bots
quicker and easier. It's an application you host on a server that uses the Slack platform and behaves however you
script it to.
Of course, you'll need Node.js, as well as NPM. NPM has
[a great tutorial](https://docs.npmjs.com/getting-started/installing-node) to help you get started if you don't have
these tools installed. [Yeoman](http://yeoman.io) is also a great tool for getting started on your first Hubot.
## Basic Setup
To install, you will first want to create a new Hubot project. The simplest way is to use your computer's terminal app
to invoke Yeoman.
To get started, you'll need [Node.js](https://nodejs.org/en/) installed.
```bash
You will first want to create a new Hubot project. The simplest way is to use your computer's terminal app to install
[Yeoman](http://yeoman.io), a handy tool that builds projects from a template. We'll also install the the template for
Hubot projects, `generator-hubot`.
```
npm install -g yo generator-hubot
```
This will install the Yeoman Hubot generator. Now we can create that Hubot project:
Now we can create that Hubot project:
```bash
```
mkdir my-awesome-hubot && cd my-awesome-hubot

@@ -36,18 +41,53 @@ yo hubot --adapter=slack

This script will prompt you to describe the app you are going to build, and create a file that NPM can use to help
manage your project.
Yeoman will ask you a few easy questions about your project and fill your directory with a Hubot app, ready to run.
You will also need to set up a Custom Bot on your Slack team. This will create a token that your hubot can use to
log into your team as a bot. Visit the [Custom Bot creation page](https://my.slack.com/apps/A0F7YS25R-bots) to register
your bot with your Slack team, and to retrieve a new bot token
## Getting a Slack Token
Next, you'll need a token from Slack to authenticate your Hubot. Use one of the following choices:
- **Create a Slack App with a Bot User (recommended)**: Slack apps are a container for many capabilities in the Slack
platform, and let you access those capabilities in a single place. This is the recommended choice because it allows
room for your Hubot to grow. To begin, you just need a Bot User.
1. Create a new app at the [app management page](https://api.slack.com/apps). Pick a clever name and choose the
a the workspace you want Hubot installed in.
2. Navigate to the Bot User page and add a bot user. The display name is the name your team will use to mention
your Hubot in Slack.
3. Navigate to the Install App page and install the app into the workspace. Once you've authorized the installation,
you'll be taken back to the Install App page, but this time you'll have a **Bot OAuth Access Token**. Copy that
value, it will be your Slack token.
Don't use this choice if your Hubot needs access to any of the permissions that are only available to Custom Bots in
the [Bot methods documentation](https://api.slack.com/bot-users#bot_methods). If you don't know whether you'll need
those, its easy to start with a Slack app and move to a Custom Bot when you need to by simply swapping a token, no
sweat 😅.
- **Create a configuration of the Hubot Integration**: The
[Hubot Integration](https://my.slack.com/apps/A0F7XDU93-hubot) is an older way to use the Slack platform. It's main
advantage is you get more permissions out of the box. For some more-security-sensitive people, this might be a
disadvantage. From the above link click Install, choose a username, and finish by clicking Add Hubot Integration. On
the next page, you'll see an **API Token**. Copy that value, it will be your Slack token.
## Running Hubot
Once you've got your bot set up as you like, you can run your hubot with the run script included (being sure to
copy-and-paste your token in!):
Run the command below, pasting your own Slack token after the `=`.
```bash
```
HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE ./bin/hubot --adapter slack
```
Before you can interact with your Hubot, you invite it into a channel (shortcut: `/invite @username`).
_Windows users_: The above command sets an environment variable correctly for Linux and macOS, but
[Windows is a little different](https://hubot.github.com/docs/deploying/windows/).
## Trick it out
Hubot has many pre-written scripts that you can easy add by naming them in `external-scripts.json`. Take a look at all
the possibilites with the [hubot-scripts keyword in npm](https://www.npmjs.com/search?q=keywords:hubot-scripts).
Feeling inspired? You can jump into writing your own scripts by modifying `scripts/example.coffee`. It had tons of
helpful comments to guide you. You might also find the [Hubot scripting docs](https://hubot.github.com/docs/scripting/)
useful.
## Getting Help

@@ -58,3 +98,6 @@

* [Issue Tracker](http://github.com/slackapi/{{ site.repo_name }}/issues) for reporting bugs or requesting features.
* [dev4slack channel](https://dev4slack.slack.com/archives/{{ site.dev4slack_channel }}) for getting help using
{{ site.product_name }} or just generally commiserating with your fellow developers.
* [Bot Developer Hangout](https://community.botkit.ai) is a Slack community for developers building all types of bots.
You can find the maintainers and users of this package in **#slack-api.**
* Email us in Slack developer support: [developers@slack.com](mailto://developers@slack.com)
{
"name": "hubot-slack",
"version": "4.4.0",
"version": "4.5.0",
"description": "A Slack adapter for hubot",

@@ -9,3 +9,3 @@ "main": "./slack",

"codecov": "codecov",
"mocha": "mocha --compilers coffee:coffee-script/register --require coffee-coverage/register-istanbul --reporter spec test"
"mocha": "mocha --compilers coffee:coffeescript/register --require coffee-coverage/register-istanbul --reporter spec test"
},

@@ -29,21 +29,21 @@ "keywords": [

"@slack/client": "^3.4.0",
"bluebird": "^3.5.1",
"lodash": "^3.10.1"
},
"peerDependencies": {
"hubot": "^2.0.0"
},
"devDependencies": {
"coffee-coverage": "~1.0.1",
"coffee-script": "~1.7.1",
"codecov": "~1.0.1",
"grunt": "~0.4.1",
"grunt-cli": "^0.1.13",
"grunt-contrib-watch": "~0.5.3",
"grunt-release": "~0.6.0",
"grunt-shell": "~0.5.0",
"hubot": "~2.19",
"chai": "^3.5.0",
"coffee-coverage": "^2.0.0",
"coffeescript": "^1.12.7",
"codecov": "^2.3.1",
"hubot": "^2.19.0",
"istanbul": "^0.4.3",
"mocha": "~1.13.0",
"should": "~2.0.2"
"mocha": "^3.5.3",
"should": "^8.0.0"
},
"engines": {
"node": ">= 0.10.x",
"npm": ">= 1.1.x"
"node": ">= 0.12",
"npm": ">= 2.0.0"
},

@@ -79,4 +79,15 @@ "contributors": [

"name": "John Agan"
},
{
"email": "aoberoi@gmail.com",
"name": "Ankur Oberoi"
},
{
"email": "sdewael@slack-corp.com",
"name": "Shane DeWael"
},
{
"name": "Siôn le Roux"
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc