spatie/laravel-slack-slash-command
Build Slack slash commands in Laravel. Define handlers to validate and process incoming Slack requests, reply within 3 seconds or dispatch jobs for longer work, and send structured responses back to Slack. Includes request/response helpers and simple routing of commands.
spatie/laravel-slack-slash-command) with minimal configuration (Slack signing secret, command routes).spatie/laravel-slack-slash-command’s queue option for async responses..env with VIPER_DOTENV_SECURE_VALUES).user_id vs. custom token validation).Route::slack()), middleware, and service containers.spatie/laravel-slack-slash-command’s response helpers.spatie/laravel-slack-slash-command’s queue option to offload processing to Laravel Queues (e.g., Redis, database).ValidateSlackCommandRequest).composer require spatie/laravel-slack-slash-command
php artisan vendor:publish --provider="Spatie\SlackSlashCommand\SlackSlashCommandServiceProvider"
routes/slack.php:
Route::slack('/my-command', [MyCommandHandler::class, 'handle']);
app/Http/Commands/Slack/MyCommandHandler.php):
public function handle(SlackRequest $request) {
$response = new SlackResponse("Hello, {$request->user}!");
return $response;
}
use Spatie\SlackSlashCommand\SlackRequest;
use Illuminate\Foundation\Http\FormRequest;
class MyCommandRequest extends FormRequest {
public function rules() {
return ['text' => 'required|string'];
}
}
Route::slack('/slow-command', [SlowCommandHandler::class, 'handle'])
->queue();
public function test_slack_command() {
$response = $this->slack('/my-command', [
'user_id' => 'U123',
'text' => 'test',
]);
$response->assertSee('Hello, U123!');
}
spatie/laravel-slack-slash-command and Laravel core (follow semantic versioning)..env and config/slack-slash-command.php for stale secrets or misconfigurations.dd($request->all()) in handlers.dd(), Log::debug(), and telescope for debugging.How can I help you explore Laravel packages today?