Setting up a slash command at Slack.com
In order to use this package you'll need to setup a slash command. Head over to the create apps page
at slack.com to get started. There click "slash commands" and on the next page click "Create 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.
POST in the
If you would like to test your Slash command locally, you can use ngrok (for example with
valet share) to generate an url. Be aware that you should reinstall your app if the ngrok url expires.
After you created your slash command you can head over to "Basic information" and copy the
Verification Token. You need this for the
SLACK_SLASH_COMMAND_VERIFICATION_TOKEN value in your .env
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:
'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:
'url' => 'slack',
'token' => env('SLACK_SLASH_COMMAND_VERIFICATION_TOKEN'),
'handlers' => [