You can:
- create long file name like
6320c1115d5bc2b6ca615b96be050884.php
and register it as webhook url. - Check Viber backend IP address range (you can find it in dev docs).
You need to create own event checker. For example:
// ...
// $bot - \Viber\Bot instance
$bot->on(function ($event) {
return isThisIsCatPicture(event);
}, function ($event) {
// process cat pictures here
});
Inside viber ecosystem each device/client send delivery status. So, if you want to track delivery process you can:
First, subscribe to delivery events:
use Viber\Api\Event\Type;
// ...
// register to all events
$result = $client->setWebhook($webhookUrl, [
Type::DELIVERED, // if message delivered to device
Type::SEEN, // if message is seen device
Type::FAILED, // if message not delivered
Type::SUBSCRIBED,
Type::UNSUBSCRIBED,
Type::CONVERSATION,
Type::MESSAGE
]);
Then setup event handler callback inside bot-manager:
// ...
$bot
->on(function (Event $event) {
return ($event instanceof \Viber\Api\Event\DELIVERED);
}, function($event) {
// process delivered
})
->on(function (Event $event) {
return ($event instanceof \Viber\Api\Event\SEEN);
}, function($event) {
// process seen
})
->on(function (Event $event) {
return ($event instanceof \Viber\Api\Event\FAILED);
}, function($event) {
// process failed
});