Platforms: Slash Commands

Slash Commands

It's incredibly easy to give your Dexter Slack bot the ability to support slash commands. In your Dexter bot, create a new topic named slack-commands (it must be named exactly this, NOT "slash-commands"). Inside this topic, simply create triggers that match your slash command's name. For example, if you had a /randomnumber slash command, your slack-commands topic might look like:

+ randomnumber
- 42. It's always 42.

Or if you wanted to call an API based on user input, you might write something like the below to support a /weather 10014 slash command (this example uses the star and HTTP GET syntax):

+ weather *
$ GET https://myweatherapi.com/zipcode/<star>
- The current weather in ${{data.temperature}} degrees.

Once you've written your slash command trigger, find your app inside Slack (https://api.slack.com/apps) and click on "Slash Commands" in the left menu:

  1. Click Create New Command
  2. Give it a command name that matches exactly your command name inside Dexter
  3. Copy the Event Subscription Request URL from your Dexter bot into the Request URL field in the Slack app
  4. Fill out the rest of the information as you see fit

Slash commands

Once you hit Save inside of Slack and publish the slack-commands topic, you should be able to use your slash command!