PHP code example of yaroslav-kozhemiaka / botman-viber-driver
1. Go to this page and download the library: Download yaroslav-kozhemiaka/botman-viber-driver library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yaroslav-kozhemiaka / botman-viber-driver example snippets
DriverManager::loadDriver(\TheArdent\Drivers\Viber\ViberDriver::class);
// Create BotMan instance
BotManFactory::create($config);
/** @var \BotMan\BotMan\BotMan $botman */
$botman = resolve('botman');
$botman->on(
'conversation_started',
static function (array $payload, BotMan $bot) {
$bot->reply('Hi, ' . $bot->getUser()->getUsername());
}
);
$botman->hears('hi', static function (BotMan $bot) {
$bot->reply('👋');
});
$botman->fallback(static function (BotMan $bot) {
$bot->reply('I do not understand');
});
$botman->listen();
$carousel = Carousel::create(6,3)->addElement(
CarouselElement::create('<font color="#FFFFFF">Text1</font>',6,1),
CarouselElement::create('<font color="#FFFFFF">Text2</font>',6,1),
CarouselElement::create('<font color="#FFFFFF">Text3</font>',6,1)
);
$this->say("Default text",$carousel->toArray());
use App\Http\Middleware\CapturedMiddleware;
$botman->middleware->captured(new CapturedMiddleware());
php artisan botman:viber:register