This package is an addon for rtippin/messenger
- This package is not required to use the bots feature built into
Messenger
. - For more documentation on creating custom bot handlers and packages, visit the official Chat Bots documentation.
- Ready-made bot action handlers and packages that will plug into the core messenger package.
- Register only the selected bots you wish to use, or let us auto-register all bots we provide.
- Included Bot Handlers:
- Chuck Norris Bot
- Coin Toss Bot
- Commands Bot
- Dad Joke Bot
- Document Finder Bot
- Giphy Bot
- Insult Bot
- Invite Bot
- Joke Bot
- Kanye West Bot
- Knock Bot
- Location Bot
- Nuke Bot
- Random Image Bot
- Reaction Bomb Bot
- Reaction Bot
- Reply Bot
- Rock Paper Scissors Bot
- Roll Bot
- Weather Bot
- Wikipedia Bot
- YoMomma Bot
- YouTube Bot
- Included Packaged Bots:
- Games Package
- Jokester Package
- Neo package
- To use this package, you must already have the core Messenger package installed.
- You must have bots enabled from within the messenger.php config, or your
.env
. - The built-in bot subscriber should also be enabled, unless you wish to register your own event subscriber.
- If the subscriber is queued, be sure to have your queue worker process the defined channel,
messenger-bots
is the default.
MESSENGER_BOTS_ENABLED=true
'bots' => [
'enabled' => env('MESSENGER_BOTS_ENABLED', false),
'subscriber' => [
'enabled' => true,
'queued' => true,
'channel' => 'messenger-bots',
],
],
composer require rtippin/messenger-bots
'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),
php artisan vendor:publish --tag=messenger-bots
- To use weather bot, you must get an API key from Weather API
- To use YouTube bot, you must get an API key from Google Developers Console
- To use Giphy bot, you must get an API key from Giphy
- You may use the location bot without an API key, but for commercial use, you must get an API key from IP API
- Random image bot will use unsplash as the default endpoint to grab a random image from. You may overwrite this endpoint.
- If you plan to use all the bot handlers and packaged bots provided, you can skip registering them manually by enabling the
BOT_AUTO_REGISTER_ALL
flag.
Update your .env
BOT_AUTO_REGISTER_ALL=true
- Inside your
MessengerServiceProvider
(or any of your providers), you must register all bot handlers and bot packages you want enabled in your application. - You can use the
MessengerBots
facade to register the handlers and packages. Be sure you do it inside theboot
method.
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,
]);
}
}