Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including hubot-slack-reaction-example with all npm packages installed. Try it out:

hubot-slack-reaction-example lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("hubot-slack-reaction-example/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hubot-slack-reaction-example v1.2.2

Demonstrates how to use the hubot-slack v4.2.0 Robot.react method

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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free