Slack Slash Commands

Let's get started! First, setup a slash command in Slack. You can do that here: https://slack.com/apps/A0F82E8CA-slash-commands 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: https://tonicdev.io/matt/56aa6f873c22eb0d00bb37c0/branches/master/tonic 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!" app.post("/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 = 'http://www.mattgardner.com/media/tonic/slashTonic.png'
This is really great for prototyping slack slash comands. No deploying necessary – Give it a shot!

no comments

    sign in to comment

    running