This package makes it easy to make your Laravel app respond to Slack's Slash commands.
Once you've setup your Slash command over at Slack and installed this package into a Laravel app you can create handlers that can handle a slash command. Here's an example of such a handler that will send a response back to Slack.
namespace App\SlashCommandHandlers;
use App\SlashCommand\BaseHandler;
use Spatie\SlashCommand\Request;
use Spatie\SlashCommand\Response;
class CatchAll extends BaseHandler
{
public function canHandle(Request $request): bool
{
return true;
}
public function handle(Request $request): Response
{
return $this->respondToSlack("You have typed this text: `{$request->text}`");
}
}
The package also provides many options to format a response. It also can respond to Slack from within a queued job.
##We have badges!