PHP 的 BotMan

看到「PHP BotMan」這個專案 (A framework agnostic PHP library to build chat bots),把各家 IM 工具都串起來讓你直接接上去用,在 initialize 完後,就可以這樣寫:

$botman->hears('keyword', function(BotMan $bot) {
    // do something to respond to message
    $bot->reply('You used a keyword!');


$botman->fallback(function(BotMan $bot) {
    return $bot->reply('Sorry I do not know this command');

把事情專注在 bot 邏輯本身,不需要去管怎麼跟 Facebook 或是 Slack 接的細節...

Leave a Reply

Your email address will not be published. Required fields are marked *