Skip to content

mbland/hubot-slack-reaction-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hubot-slack-reaction-example

Source: https://github.com/mbland/hubot-slack-reaction-example

npm

This is a chat bot built on the Hubot framework that demonstrates how to use the Robot.react method introduced in hubot-slack v4.2.0 and the ReactionMessage type introduced in hubot-slack v4.1.0.

All of the example code is in scripts/handle-reaction.coffee.

Running the bot

  1. Clone this repo:

    $ git clone https://github.com/mbland/hubot-slack-reaction-example
    $ cd hubot-slack-reaction-example
    $ npm install
  2. You must have administrator access for your Slack domain. Alternatively, you can create your own personal slack domain for testing.

  3. Create a new Slack bot user for your team. Name it anything you like, such as reaction-example-bot. Take note of the API token, which should start with xoxb-.

  4. Invite the bot to a channel by @-mentioning it in the channel, e.g. @reaction-example-bot.

  5. Run the bot:

    $ HUBOT_SLACK_TOKEN=<bot-test-token> ./bin/hubot --adapter slack

    you should see output like:

    [Sun Oct 09 2016 12:22:12 GMT-0400 (EDT)] INFO Logged in as reaction-example-bot of mbland
    [Sun Oct 09 2016 12:22:12 GMT-0400 (EDT)] INFO Slack client now connected
    [Sun Oct 09 2016 12:22:12 GMT-0400 (EDT)] INFO Listening for reaction_added, reaction_removed events
    
  6. Post a message in your Slack domain and add an emoji reaction to it.

Now you should see something like:

Usage example


After the message received the +1 emoji reaction, the example bot posted a response to the channel reporting the details of the event.

Copyright

This software is made available as Open Source software under the ISC License. For the text of the license, see the LICENSE file.

That said, this is example code. Feel free to do with it what you like even without retaining the copyright. However, since publishing code as public domain still seems more complicated than it needs to be, the license is there if you need legal coverage.