We started using Slack shortly after it was released, and now must say we’re not surprised to find out that so many people use it on daily basis too. (As data says, there are 1.7 million Slack users at this moment.) Namely, it serves us awesomely as centralized hub for discussions, code deployment and tracking our Trello activities, e.g. Notifications are also pretty handy, as well as search functionality, and it works great on mobile. All in all, we have to say we like it equally as online conference room as well as virtual water cooler. Giphy function is especially appreciated in both cases. Still, we missed oldy but goody IRC* times when you could just type in:

  
    /slap Josh
  

…and as a result Josh would get a proper slap!

*link referral meant for millennials ;)

Update: Slapbot now supports user tagging and custom emoji codes and can include random “banter”. For example: /slap @josh :hot_pepper:, will tag @josh and slap him with a hot pepper. Ouch!

So, we weren’t lazy and decided to recreate these joyful moments in Slack:

First Step First: Installation

Start with these:

  • Clone the repo, e.g. git clone https://github.com/spfr/slapbot.git
  • Run npm install
  • Run node server.js

OK, great job! But, this actually is not that useful since you will need to host it somewhere in order to configure Slack to use it. We recommend running the server with PM2 and frontend it with Nginx or similar.

PM2 configuration .json should look like this:

  
{
  "name" : "slapbot",
  "script" : "server.js",
  "cwd" : "[path_to_cloned_repo]",
  "env" :
   {
        "PORT":8090,
   }
}
  

Configuring Your Slack Slapbot

  • Go to Slack services section https://.slack.com/services/new.
  • From there find Slash Command and add a command like /slap [username].
  • In the URL put your service URL or use ours -> http://slapbot.spfr.co/slap.

Now you have a working bot with whom you can interact. But, since this is a private communication between you and him, you could say that it is not that fun.

So – let’s make it more fun!

  • Go to All Integrations screen again and add Incoming Webhook.
  • Choose any channel to post to. (Don’t worry, Slapbot is not betrayer – it will use the channel you type in when you do your slapping.)
  • Copy and paste that token part of the URL that you got (it will be something like this: https://hooks.slack.com/services/sadaUSh12/s218jS/ajd123)
  • Take the part after services, as in the above example it will be -> /sadaUSh12/s218jS/ajd123
  • Go back to Slash Command and edit the URL to add the token part from above so it should be at the end something like: http://slapbot.spfr.co/slap?callback=/sadaUSh12/s218jS/ajd123.

BTW, if you feel like it, replace slapbot.spfr.co with your own URL. If not, feel free to use this one.

Congratulations, you’ve activated your own Slapbot for Slack!

Now, move on and enjoy your slapping wisely! ;)


Slapbot instructions are also available at our GitHub account.