Installation and Setup

Setting up a slash command at

In order to use this package you'll need to setup a slash command. Head over to the custom integrations page at to get started. There click "slash commands" and on the next page click "Add configuration". On that screen you can choose a name for your Slack command. You can choose anything that Slack allows. And finally you can setup your new command.

You should now be on a screen that looks like this.

These are things you'll need to do:

  • In the url you should type the domain name of your Laravel app followed by one or more segments. In the screenshot we've added a slack segment. You can choose any segment you want. You'll also need to specify this later on in the config file of the package.
  • Choose POST in the method field
  • Specify a token in the token field. You'll need to copy that value over to the config file of this package.

Installing the package

The package can be installed in your Laravel app via composer:

composer require spatie/laravel-slack-slash-command

Next, you must install the service provider:

// config/app.php
'providers' => [

You can publish the config file with this command:

php artisan vendor:publish --provider="Spatie\SlashCommand\SlashCommandServiceProvider" --tag="config"

This is the contents of the published config file:

return [

     * Over at Slack you can configure to which url the slack commands must be send.
     * url here. You must specify that. Be sure to leave of the domain name.
    'url' => 'slack',

     * The token generated by Slack with which to verify if a incoming slash command request is valid.

     * The handlers that will process the slash command. We'll call handlers from top to bottom
     * until the first one whose `canHandle` method returns true.
    'handlers' => [
        //add your own handlers here

        //this handler will display instructions on how to use the various commands.

        //this handler will respond with a `Could not handle command` message.