This is what makes adding custom commands a piece of cake. This is just one of the many ways you can structure your app, but if you’re new to Slack integrations, I suggest you stick with this. And I say ‘can’ because it’s fairly flexible and you can change it to work with a different directory via the configuration parameters (more on that later).
Npm install Project Structure Walkthroughįrom the list of dependencies in package.json, the only required dependency is slack-terminalize, but since the sample app has an example to show how to handle asynchronous commands, the request module is used to make REST calls.Īll the JSON files you might need for your app can go here. Now, let’s clone the sample app and install the dependencies: git clone Configure the other details of the bot, its profile image and real name, and hit Save Integration. With a process-and-dispatch approach and a plugin-like architecture to add custom commands, slack-terminalize abstracts things so you can focus more on defining the behavior of the app instead.įirst, let’s create a new bot user for your team, that can take your orders! Go to choose a username for it, and hit Add Bot Integration.Ĭopy the API token shown to you, as this is required for your bot to be able to interact with the channels. With that in mind, I felt the need for a module which could do exactly that. If you think about a command-line system, most of the times what the shell is doing is the grunt work of fetching, parsing, tokenizing and dispatching the commands (a gross oversimplification, I know). Simple commands especially make sense in a mobile device, helping you type less, do more. While there are many fancy hubot scripts that respond to natural language queries, a lot can be achieved with short commands and minimal keystrokes, as any Linux fan would agree. You’ll need node and npm installed You can follow this wonderful SitePoint introduction to npm, to set up your development environment. My assumption is that you have a working knowledge of JavaScript and NodeJS and that you’re familiar with Slack jargon: teams, channels, bots and integrations. So if you were looking to learn about Slash Commands, this might not be the appropriate tutorial. Note that we won’t be using Slash Commands here, but instead we’ll interpret regular messages as commands. It uses Slack’s Real-Time API Node client and prepares a bot to listen and respond to your requests. We’ll use a helper module called slack-terminalize ( disclaimer: I developed it), that abstracts away the initial processing of messages. This tutorial aims to help you get up and running with a simple node app that turns your Slack channel into a custom command-line terminal. If you’re thinking “no way that’s unique to Slack, HipChat (or your favorite app) has all that too!”, you might wanna take a look at this: Goal of the Tutorial Also, their APIs help developers extend the functionality and build a custom experience for their team. Its slick user-interface, concept of teams and channels to keep communication separate and relevant, tons of integrations for productivity (Dropbox, Box, Google Calendar, Hangouts etc) and things like giphy and reminders, make it fun to use.
Slack has a certain appeal and huge fan following in both developer and non-developer tech communities. Thanks to all of SitePoint’s peer reviewers for making SitePoint content the best it can be! This article was peer reviewed by Dan Prince and Matthew Wilkin.