listCommands() as $command) { $bot->hears(call_user_func([$command, 'getPattern']), $command); } $bot->hears('(hello|hi|bonjour|salut)', function (Bot $bot) { $bot->replyPolitely('Bonjour'); }); $body = file_get_contents('php://input'); try { $data = json_decode($body, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { $data = []; } // Only on message, not on event or whatever if ($data['type'] !== 'Create' || $data['object']['name'] !== 'message') { return ; } try { $message = json_decode($data['object']['content'], true, 512, JSON_THROW_ON_ERROR)['message']; } catch (JsonException $e) { return; } $bot->listen($message);