Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rtippin/messenger-bots

Addon for rtippin/messenger that adds ready-made bot action handlers. This integrates with the core bots feature.
https://github.com/rtippin/messenger-bots

automation bots chat-bot messenger messenger-bots realtime

Last synced: 23 days ago
JSON representation

Addon for rtippin/messenger that adds ready-made bot action handlers. This integrates with the core bots feature.

Awesome Lists containing this project

README

        

# Messenger Bots

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Tests][ico-test]][link-test]
[![StyleCI][ico-styleci]][link-styleci]
[![License][ico-license]][link-license]

---

![Preview](https://raw.githubusercontent.com/RTippin/messenger-demo/master/public/examples/image2.png)

## This package is an addon for [rtippin/messenger][link-messenger]

## Notice
- 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][link-bots-docs] documentation.

### Features:
- 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

---

# Prerequisites
- To use this package, you must already have the core [Messenger][link-messenger] package installed.
- You must have bots enabled from within the [messenger.php][link-messenger-config] 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.

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

# Installation

### Via Composer

```bash
composer require rtippin/messenger-bots
```

---

# Config

```php
'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

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

- To use weather bot, you must get an API key from [Weather API][link-weather-api]
- To use YouTube bot, you must get an API key from [Google Developers Console][link-google-api]
- To use Giphy bot, you must get an API key from [Giphy][link-giphy-api]
- You may use the location bot without an API key, but for commercial use, you must get an API key from [IP API][link-ip-api]
- Random image bot will use unsplash as the default endpoint to grab a random image from. You may overwrite this endpoint.

---

# Auto Registering Handlers and Packages
- 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`***

```dotenv
BOT_AUTO_REGISTER_ALL=true
```

---

# Manually Registering Handlers and Bot Packages
- 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 the `boot` method.

***Example:***

```php