Slack Slash Commands

Let's get started! First, setup a slash command in Slack. You can do that here: You'll install the slash comamnds "app" to your slack account. Once you've got that setup, continue below. Ok now that it's installed, setup a slash command. We're going to use /tonic as our prefix here. Use the following values: command: /tonic url: method: POST
var tonicExpress = require("notebook")("tonic/express-endpoint/1.0.0") // Just provide the exports object to the tonicExpress helper var app = tonicExpress(module.exports) var bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({ extended: false })); // when someone types /tonic in slack, it'll hit this endpoint and return "Hey!""/tonic", (req, res) => { switch (req.body.text) { case "help": res.send("Help is on the way!"); break; default: res.send("Hey!"); break; } });
Want to see how to use it? Run the cell below (shift+return):
var exampleUsage = ''
This is really great for prototyping slack slash comands. No deploying necessary – Give it a shot!

no comments

    sign in to comment