No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
stubs
tests
.editorconfig
.gitignore
.styleci.yml
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

BotMan driver for ChatWork

ChatWork用のBotManドライバー。
https://go.chatwork.com/
https://botman.io/

Requirements

  • PHP >= 7.0
  • Laravel >= 5.5

Demo

Installation

BotMan Studio

Create new project by BotMan Studio
https://botman.io/2.0/botman-studio
https://github.com/botman/studio

Composer

composer require revolution/botman-chatwork

config/botman/chatwork.php

php artisan vendor:publish --provider="Revolution\BotMan\Drivers\ChatWork\Providers\ChatWorkDriverServiceProvider"

.env

CHATWORK_API_TOKEN=
CHATWORK_WEBHOOK_ROOM_TOKEN=
CHATWORK_WEBHOOK_ACCOUNT_TOKEN=

app/Providers/BotMan/DriverServiceProvider.php

Set ChatWorkRoomDriver or ChatWorkAccountDriver or both.
ここで設定したドライバーが有効化される。

<?php

namespace App\Providers\BotMan;

use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Studio\Providers\DriverServiceProvider as ServiceProvider;

use Revolution\BotMan\Drivers\ChatWork\ChatWorkRoomDriver;
use Revolution\BotMan\Drivers\ChatWork\ChatWorkAccountDriver;

class DriverServiceProvider extends ServiceProvider
{
    /**
     * The drivers that should be loaded to
     * use with BotMan
     *
     * @var array
     */
    protected $drivers = [
        //        ChatWorkRoomDriver::class,
        ChatWorkAccountDriver::class,
    ];

    /**
     * @return void
     */
    public function boot()
    {
        parent::boot();

        foreach ($this->drivers as $driver) {
            DriverManager::loadDriver($driver);
        }
    }
}

Webhook

アカウントイベントルームイベント 用にWebhookを2つ作成する。
https://www.chatwork.com/service/packages/chatwork/subpackages/api/token.php

  • アカウントイベントは ご自身へのメンション をチェック。
  • ルームイベントは メッセージ作成 をチェック。更新は非対応。ルームIDも入力。

どちらもトークンを .env で設定。

APIトークン

メッセージの投稿に必要なAPIトークン。 https://www.chatwork.com/service/packages/chatwork/subpackages/api/token.php

Use another API Token

$botman->hears('Hi', function ($bot) {
    $bot->reply('Hello!', ['api_token' => '...']);
});
$botman->say('say()', 'Room ID', ChatWorkAccountDriver::class, ['api_token' => '...']);

Supported Features

Basic hears-reply only.

LICENSE

MIT
Copyright kawax