Installation with Laravel

BotMan comes with a Service Provider to make using this library in your Laravel application as simple as possible.

Go to your config/app.php and add the service provider:

Mpociot\BotMan\BotManServiceProvider::class,

Also add the alias / facade:

'BotMan' => Mpociot\BotMan\Facades\BotMan::class

Add your Facebook access token / Slack token to your config/services.php:

'botman' => [
    'hipchat_urls' => [
        'YOUR-INTEGRATION-URL-1',
        'YOUR-INTEGRATION-URL-2',
    ],
    'nexmo_key' => 'YOUR-NEXMO-APP-KEY',
    'nexmo_secret' => 'YOUR-NEXMO-APP-SECRET',
    'microsoft_bot_handle' => 'YOUR-MICROSOFT-BOT-HANDLE',
    'microsoft_app_id' => 'YOUR-MICROSOFT-APP-ID',
    'microsoft_app_key' => 'YOUR-MICROSOFT-APP-KEY',
    'slack_token' => 'YOUR-SLACK-TOKEN-HERE',
    'telegram_token' => 'YOUR-TELEGRAM-TOKEN-HERE',
    'facebook_token' => 'YOUR-FACEBOOK-TOKEN-HERE'
],

Using it:

<?php

use Mpociot\BotMan\BotMan;

$botman = app('botman');

$botman->hears('hello', function (BotMan $bot) {
    $bot->reply('Hello yourself.');
});

// start listening
$botman->listen();

Make sure that your controller method doesn't use the CSRF token middleware.

That's it.