Home

Awesome

Messenger Bots

Latest Version on Packagist Total Downloads Tests StyleCI License


Preview

This package is an addon for rtippin/messenger

Notice

Features:


Prerequisites

MESSENGER_BOTS_ENABLED=true
'bots' => [
    'enabled' => env('MESSENGER_BOTS_ENABLED', false),
    'subscriber' => [
        'enabled' => true,
        'queued' => true,
        'channel' => 'messenger-bots',
    ],
],

Installation

Via Composer

composer require rtippin/messenger-bots

Config

'weather_api_key' => env('BOT_WEATHER_API_KEY'),
'ip_api_key' => env('BOT_LOCATION_API_KEY'),
'youtube_api_key' => env('BOT_YOUTUBE_API_KEY'),
'giphy_api_key' => env('BOT_GIPHY_API_KEY'),
'random_image_url' => env('BOT_RANDOM_IMAGE_URL', 'https://source.unsplash.com/random'),
'auto_register_all' => env('BOT_AUTO_REGISTER_ALL', false),

Publish the config file

php artisan vendor:publish --tag=messenger-bots

Auto Registering Handlers and Packages

Update your .env

BOT_AUTO_REGISTER_ALL=true

Manually Registering Handlers and Bot Packages

Example:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use RTippin\Messenger\Facades\MessengerBots;
use RTippin\MessengerBots\Bots\ChuckNorrisBot;
use RTippin\MessengerBots\Bots\CoinTossBot;
use RTippin\MessengerBots\Bots\CommandsBot;
use RTippin\MessengerBots\Bots\DadJokeBot;
use RTippin\MessengerBots\Bots\DocumentFinderBot;
use RTippin\MessengerBots\Bots\GiphyBot;
use RTippin\MessengerBots\Bots\InsultBot;
use RTippin\MessengerBots\Bots\InviteBot;
use RTippin\MessengerBots\Bots\JokeBot;
use RTippin\MessengerBots\Bots\KanyeBot;
use RTippin\MessengerBots\Bots\KnockBot;
use RTippin\MessengerBots\Bots\LocationBot;
use RTippin\MessengerBots\Bots\NukeBot;
use RTippin\MessengerBots\Bots\RandomImageBot;
use RTippin\MessengerBots\Bots\ReactionBombBot;
use RTippin\MessengerBots\Bots\ReactionBot;
use RTippin\MessengerBots\Bots\ReplyBot;
use RTippin\MessengerBots\Bots\RockPaperScissorsBot;
use RTippin\MessengerBots\Bots\RollBot;
use RTippin\MessengerBots\Bots\WeatherBot;
use RTippin\MessengerBots\Bots\WikiBot;
use RTippin\MessengerBots\Bots\YoMommaBot;
use RTippin\MessengerBots\Bots\YoutubeBot;
use RTippin\MessengerBots\Packages\GamesPackage;
use RTippin\MessengerBots\Packages\JokesterPackage;
use RTippin\MessengerBots\Packages\NeoPackage;

class MessengerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(): void
    {
        MessengerBots::registerHandlers([
            ChuckNorrisBot::class,
            CoinTossBot::class,
            CommandsBot::class,
            DadJokeBot::class,
            DocumentFinderBot::class,
            GiphyBot::class,
            InsultBot::class,
            InviteBot::class,
            JokeBot::class,
            KanyeBot::class,
            KnockBot::class,
            LocationBot::class,
            NukeBot::class,
            RandomImageBot::class,
            ReactionBombBot::class,
            ReactionBot::class,
            ReplyBot::class,            
            RockPaperScissorsBot::class,
            RollBot::class,
            WeatherBot::class,
            WikiBot::class,
            YoMommaBot::class,
            YoutubeBot::class,
        ]);

        MessengerBots::registerPackagedBots([
            GamesPackage::class,
            JokesterPackage::class,
            NeoPackage::class,
        ]);
    }
}

Registered handlers and packages will now be available to choose when adding an action to a bot or installing a packaged bot.


Credits - Richard Tippin

License - MIT

Please see the license file for more information.