PHPackages                             lisennk/laravel-slack-events-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lisennk/laravel-slack-events-api

ActiveLibrary[API Development](/categories/api)

lisennk/laravel-slack-events-api
================================

Slack Events API for Laravel 5, 6, 7 and 8

1.3(5y ago)3911.4k↓66.7%18[1 issues](https://github.com/Lisennk/Slack-Events/issues)[1 PRs](https://github.com/Lisennk/Slack-Events/pulls)MITPHP

Since Aug 23Pushed 2y ago4 watchersCompare

[ Source](https://github.com/Lisennk/Slack-Events)[ Packagist](https://packagist.org/packages/lisennk/laravel-slack-events-api)[ RSS](/packages/lisennk-laravel-slack-events-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (6)Used By (0)

🔔 Slack Events API for Laravel 🔔
================================

[](#bell-slack-events-api-for-laravel-bell)

[![Latest Stable Version](https://camo.githubusercontent.com/e2039269d7c69ca1f717dc5c9b04c416dd4650bff3bd7d184ebc363ccbd51ace/68747470733a2f2f706f7365722e707567782e6f72672f6c6973656e6e6b2f6c61726176656c2d736c61636b2d6576656e74732d6170692f762f737461626c65)](https://packagist.org/packages/lisennk/laravel-slack-events-api)[![License](https://camo.githubusercontent.com/d13b0aba52fe5bc401b056b407fea583c4978ba5d039dab98107b66211a71874/68747470733a2f2f706f7365722e707567782e6f72672f6c6973656e6e6b2f6c61726176656c2d736c61636b2d6576656e74732d6170692f6c6963656e7365)](https://packagist.org/packages/lisennk/laravel-slack-events-api)[![Build Status](https://camo.githubusercontent.com/00e7556185381c5a08acb8ff4cd32da3e2762c7af2fa6f145f7cdae938e5a46c/68747470733a2f2f7472617669732d63692e6f72672f4c6973656e6e6b2f536c61636b2d4576656e74732e7376673f6272616e63683d312e302e30)](https://travis-ci.org/Lisennk/Slack-Events)

*Work with Slack Events API as easily as with native Laravel 7 events and event listeners.*

**🔗 Reasons to use this package for the [Slack Events API](https://api.slack.com/events-api):**

- Based on native Laravel Events
- Supports all Slack Event types (including events for new Workspace Apps!)
- Supports token validation
- Supports URL verification and "challenge" requests
- PSR compatible code
- Full documentation
- Almost full test coverage
- Lots of emoji in the documentation (even cats! 🐈)

🌎 Installation
--------------

[](#earth_americas-installation)

**1)** Require the package with Composer

```
composer require lisennk/laravel-slack-events-api
```

**2)** If you're using Laravel version 5.5 or higher, the SlackEventsServiceProvider will be automatically discovered. Get started fast!

**3)** If you're using a version of Laravel lower than 5.5, you'll still have to register the service provider manually. Open `config/app.php` and add `\Lisennk\LaravelSlackEvents\SlackEventsServiceProvider::class` to the `providers[]` array.

*For example:*

```
// ...

'providers' => [
// ...
// A whole bunch of providers
// ...

\Lisennk\LaravelSlackEvents\SlackEventsServiceProvider::class,
],

// ...
```

If you are using Laravel 5.3 or higher, you will find a comment in `config/app.php` with text like `/* Package Service Providers... */`, which can help you find the right place.

**4)** Publish the config file

```
php artisan vendor:publish
```

Choose the option for the Service Provider, or find `slack-events` in the `Tag:` list at the bottom.

Next we'll configure some settings to use the [Slack API](https://api.slack.com).

**5)** Create an App or Open an Existing One If you want to work with Slack's new *Workspace Apps*, read over the information in the [Developer Preview](https://api.slack.com/workspace-apps-preview) for Workspace Apps, and create a new *workspace token* App to get started.

If you're not using a Workspace App, open the [Slack Apps](https://api.slack.com/apps) page and create a new *user token* App.

If you want to modify an existing app to use with Slack-Events, you can find both *Workspace Token* Apps and *User Token* Apps on the [Your Apps](https://api.slack.com/apps) page.

**6)** Once you've created or opened your app you should see the *Basic Information* page. Scroll down to the "App Credentials" section, and copy the *Verification Token* at the bottom.

[![verification_token](https://cloud.githubusercontent.com/assets/8103985/17901937/ebdbdb3e-696d-11e6-96b4-b0794d74ed9a.png)](https://cloud.githubusercontent.com/assets/8103985/17901937/ebdbdb3e-696d-11e6-96b4-b0794d74ed9a.png)

Open `.env` and paste your Verification Token under the `'SLACK_EVENT_TOKEN'` key:

```
SLACK_EVENT_TOKEN=your-token
```

**7)** Now open the "Event Subscriptions" page. Here you must enable events, add events you wish to listen for and set **Request URL**. Request URL is the `'route'` key in your `config/slackEvents.php` file:

```
return [
    /*
    |-------------------------------------------------------------
    | Your validation token from "App Credentials"
    |-------------------------------------------------------------
    */
    'token' => env('SLACK_EVENT_TOKEN', 'your-validation-token-here'),

    /*
    |-------------------------------------------------------------
    | Events Request URL — path, where events will be served
    |-------------------------------------------------------------
    */
    'route' => '/api/slack/event/fire', // data` instead of `$event->event`.public $type;This reflects the type of callback you're receiving.public $authed\_users;An array of string-based User IDs.For example, if you want to get the reaction name from [reaction\_added](https://api.slack.com/events/reaction_added) event, you can get it from the `ReactionAdded` event class like this:

```
$reactionAdded->event['reaction']; // reaction name, something like :thumbsup:
```

So, suppose we want to make a `reaction_added` Slack Event listener. What do we need to do?

### Example

[](#example)

**1)** Open the `App/Listeners` directory (or create it if it doesn't exist). Now create a new file and call it `ReactionAddedListener.php`. Paste in this code:

```
