Responding to multiple commands | laravel-slack-slash-command | Spatie

 SPATIE

  Laravel Slack Slash Command
==============================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-slack-slash-command](https://spatie.be/docs/laravel-slack-slash-command/v1)  Advanced-usage  Responding to multiple commands

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/laravel-slack-slash-command/v1)

  Responding to multiple commands
- [ Introduction ](https://spatie.be/docs/laravel-slack-slash-command/v1/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-slack-slash-command/v1/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-slack-slash-command/v1/requirements)
- [ Installation and Setup ](https://spatie.be/docs/laravel-slack-slash-command/v1/installation-and-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-slack-slash-command/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-slack-slash-command/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-slack-slash-command/v1/about-us)

Usage
-----

- [ General flow ](https://spatie.be/docs/laravel-slack-slash-command/v1/usage/general-flow)
- [ Sending a basic response ](https://spatie.be/docs/laravel-slack-slash-command/v1/usage/sending-a-basic-response)
- [ Making your response look good ](https://spatie.be/docs/laravel-slack-slash-command/v1/usage/making-your-response-look-good)
- [ Making your attachments interactive ](https://spatie.be/docs/laravel-slack-slash-command/v1/usage/making-your-attachments-interactive)

Advanced usage
--------------

- [ Sending delayed responses ](https://spatie.be/docs/laravel-slack-slash-command/v1/advanced-usage/sending-delayed-responses)
- [ Using signature handlers ](https://spatie.be/docs/laravel-slack-slash-command/v1/advanced-usage/using-signature-handlers)
- [ Responding to multiple commands ](https://spatie.be/docs/laravel-slack-slash-command/v1/advanced-usage/responding-to-multiple-commands)

 Responding to multiple commands
===============================

You may choose to set up multiple slack commands. On the integrations settings on slack.com you should let them all point to the `url` you configured in `app/config/laravel-slack-slash-command`.

Image you've created two slack commands `/jaime` and `/johnsnow`

```
namespace App\SlashCommandHandlers;

use Spatie\SlashCommand\Request;
use Spatie\SlashCommand\Response;

class Jaime extends BaseHandler
{

    public function canHandle(Request $request): bool
    {
        return $request->command == 'jaime';
    }

    public function handle(Request $request): Response
    {
        return $this->respondToSlack("A Lannister always pays his debts");
    }
}
```

```
namespace App\SlashCommandHandlers;

use Spatie\SlashCommand\Request;
use Spatie\SlashCommand\Response;

class JohnSnow extends BaseHandler
{

    public function canHandle(Request $request): bool
    {
        return $request->command == 'johnsnow';
    }

    public function handle(Request $request): Response
    {
        return $this->respondToSlack("I know nothing");
    }
}
```

You'll see a response `A Lannister always pays his debts` after issueing the `/jaime` command, and `I know nothing` after issuing the `/johnsnow` command.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
