PHPackages                             binary-cats/laravel-bigbluebutton-webhooks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. binary-cats/laravel-bigbluebutton-webhooks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

binary-cats/laravel-bigbluebutton-webhooks
==========================================

Handle BigBlueButton webhooks in a Laravel application

12.1.0(1mo ago)65934MITPHPCI passing

Since Jun 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/binary-cats/laravel-bigbluebutton-webhooks)[ Packagist](https://packagist.org/packages/binary-cats/laravel-bigbluebutton-webhooks)[ Docs](https://github.com/binary-cats/laravel-bigbluebutton-webhooks)[ RSS](/packages/binary-cats-laravel-bigbluebutton-webhooks/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (7)Versions (13)Used By (0)

Handle BigBlueButton Webhooks in a Laravel application
======================================================

[](#handle-bigbluebutton-webhooks-in-a-laravel-application)

[![https://github.com/binary-cats/laravel-bigbluebutton-webhooks/actions](https://github.com/binary-cats/laravel-bigbluebutton-webhooks/workflows/run-tests/badge.svg)](https://github.com/binary-cats/laravel-bigbluebutton-webhooks/workflows/run-tests/badge.svg)[![https://github.styleci.io/repos/270848719](https://camo.githubusercontent.com/bceb2654d5647a251c16717e6724f26377b458bc5aeb261a520285805cac1e42/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3237303834383731392f736869656c64)](https://camo.githubusercontent.com/bceb2654d5647a251c16717e6724f26377b458bc5aeb261a520285805cac1e42/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3237303834383731392f736869656c64)[![https://scrutinizer-ci.com/g/binary-cats/laravel-bigbluebutton-webhooks/](https://camo.githubusercontent.com/d951a67b6f2b920ed616f88a04b33468206524e22d6d921b59917cfe47f9049d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e6172792d636174732f6c61726176656c2d626967626c7565627574746f6e2d776562686f6f6b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/d951a67b6f2b920ed616f88a04b33468206524e22d6d921b59917cfe47f9049d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e6172792d636174732f6c61726176656c2d626967626c7565627574746f6e2d776562686f6f6b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)

[BigBlueButton](https://bigbluebutton.org/) can notify your application of mail events using webhooks. This package can help you handle those webhooks. Out of the box it will verify the BigBlueButton signature of all incoming requests. It appears that the signature validation is below simplie right now and does not match the documentation. All valid calls will be logged to the database. You can easily define jobs or events that should be dispatched when specific events hit your app.

This package will not handle what should be done after the webhook request has been validated and the right job or event is called. You should still code up any work (eg. regarding payments) yourself.

Before using this package we highly recommend reading [the entire documentation on webhooks over at BigBlueButton](http://docs.bigbluebutton.org/).

This package is an almost line-to-line adapted copy of absolutely amazing [spatie/laravel-stripe-webhooks](https://github.com/spatie/laravel-stripe-webhooks)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require binary-cats/laravel-bigbluebutton-webhooks
```

The service provider will automatically register itself.

You must publish the config file with:

```
php artisan vendor:publish --provider="BinaryCats\BigBlueButtonWebhooks\BigBlueButtonWebhooksServiceProvider" --tag="config"
```

This is the contents of the config file that will be published at `config/bigbluebutton-webhooks.php`:

```
return [

    /*
     * BigBlueButton will sign each webhook using a shared secret.
     */
    'signing_secret' => env('BBB_SECRET'),

    /*
     * You can define the job that should be run when a certain webhook hits your application
     * here. The key is the name of the BigBlueButton event type with the `.` replaced by a `_`.
     *
     * The package will automatically convert the keys to lowercase, but you should
     * be cognisant of the fact that array keys are case-sensitive
     */
    'jobs' => [
        'meeting-created' => \BinaryCats\BigBlueButtonWebhooks\Jobs\MeetingCreatedJob::class,
    ],

    /*
     * The classname of the model to be used. The class should equal or extend
     * Spatie\WebhookClient\Models\WebhookCall
     */
    'model' => \BinaryCats\BigBlueButtonWebhooks\WebhookCall::class,

    /*
     * The classname of the model to be used. The class should equal or extend
     * Spatie\WebhookClient\ProcessWebhookJob
     */
    'process_webhook_job' => \BinaryCats\BigBlueButtonWebhooks\ProcessBigBlueButtonWebhookJob::class,
];
```

In the `signing_secret` key of the config file you should add a valid shared secret of the BigBlueButton server.

**You can skip migrating is you have already installed `Spatie\WebhookClient`**

Next, you must publish the migration with:

```
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="migrations"
```

After migration has been published you can create the `webhook_calls` table by running the migrations:

```
php artisan migrate
```

### Routing

[](#routing)

Finally, take care of the routing: You must configure at what url BigBlueButton webhooks should hit your app. In the routes file of your app you must pass that route to `Route::bigbluebuttonWebhooks()`:

I like to group functionality by domain, so I would suggest `webhooks/bigbluebutton` (especially if you plan to have more webhooks), but it is really up to you.

```
# routes\web.php
Route::bigbluebuttonWebhooks('webhooks/bigbluebutton');
```

Behind the scenes this will register a `POST` route to a controller provided by this package. Because BigBlueButton has no way of getting a csrf-token, you must add that route to the `except` array of the `VerifyCsrfToken` middleware:

```
protected $except = [
    'webhooks/bigbluebutton',
];
```

Usage
-----

[](#usage)

BigBlueButton will send out webhooks for several event types. I tried to locate the comprehensive list of all BigBLueButton events, however in vain. If you have it, please let me know

BigBlueButton will sign all requests hitting the webhook url of your app. This package will automatically verify if the signature is valid. If it is not, the request was probably not sent by BigBlueButton.

Unless something goes terribly wrong, this package will always respond with a `200` to webhook requests. Sending a `200` will prevent BigBlueButton from resending the same event over and over again. All webhook requests with a valid signature will be logged in the `webhook_calls` table. The table has a `payload` column where the entire payload of the incoming webhook is saved.

If the signature is not valid, the request will NOT be logged in the `webhook_calls` table but a `BinaryCats\BigBlueButtonWebhooks\Exceptions\WebhookFailed` exception will be thrown. If something goes wrong during the webhook request the thrown exception will be saved in the `exception` column. In that case the controller will send a `500` instead of `200`.

**The package will ALWAYS cast events to lowercase - so your configured keys must be lowercase, too**

**N.B.: According to the docs:**

> Hooks are only removed if a call to /hooks/destroy is made or if the callbacks for the hook fail too many times (~12) for a long period of time (~5min).

**N.N.B.: Payload structure:**

> The payload that is sent from BigBlueButton is sort of split between into three sections. Out of the box the package will store whatever BBB sends back to you within payload via `$request->input()`. If you want to transform the payload, you may want to use custom model. [Advanced Usage](#advanced-usage)

There are two ways this package enables you to handle webhook requests: you can opt to queue a job or listen to the events the package will fire.

### Handling webhook requests using jobs

[](#handling-webhook-requests-using-jobs)

If you want to do something when a specific event type comes in you can define a job that does the work. Here's an example of such a job:

```
