Facebook messenger-platform with Laravel

dev-master 2016-12-17 03:02 UTC

This package is not auto-updated.

Last update: 2020-05-15 18:54:13 UTC


Laravel 5 Package for Facebook messenger-platform with Laravel.

This is package for Laravel and Lumen 5.0, 5.1, 5.2, & 5.3

Note: Before you start, you should follow Facebook message setup.

  1. Create an App and a Page

  2. Have a https:// url.


PHP 5.5.9+, and Composer are required.

Add the Laravel Facebook Message package to your composer.json file.

    "require": {
        "denise92/facebook-message": "dev-master"

You'll then need to run composer update to download it and have the autoloader updated.

Service Provider

In your app config, add the FacebookMessageServiceProvider to the providers array.

'providers' => [

For Lumen, add the provider to your bootstrap/app.php file.


Configuration File

After Create an App and a Page, you'll need to provide the app ID, page ID and Access token. In Laravel you can publish the configuration file with artisan.

$ php artisan vendor:publish

Where's the file? Laravel 5 will publish the config file to /config/facebook_message.php.

In Lumen you'll need to manually copy the config file from vendor/denise92/facebook-message/src/config/FacebookMessage.php, and rename to facebook_message.php in your config folder. Lumen doesn't have a /config folder by default so you'll need to create it if you haven't already.

Required config values

You'll need to update the fb_app_id, fb_page_id and fb_access_token values in the config file with your app ID, page ID and access token.

By default the configuration file will look to environment variables for your app ID and secret. It is recommended that you use environment variables to store this info in order to protect your app secret from attackers. Make sure to update your /.env file with your app ID & secret.


How to setup webhook from Facebook:

Callback URL:

This url is defined in src/route.php, you can rewrite it if you like:

Route::get('test/webhook', '\Denise92\FacebookMessage\FacebookMessageController@webhook');
Route::post('test/webhook', '\Denise92\FacebookMessage\FacebookMessageController@conversation');

Verify Token: any-string-you-like

Subscription Fields: You can checked all.

Then press Save button. If Facebook get the verify code from, than you can start chat with your Pages message bot now.