Viber Business Messenger Integration with Website
Viber Business Messages allows sending transactional and marketing messages via official Viber API. Most popular in CIS and Eastern Europe countries. Available via Viber REST API or through aggregators (SMSC, MessageBird, Infobip).
Viber Account Types
Viber Bot — free, bot interacts with users through dialogs. Limited to 1-on-1 chats.
Viber Business Account — paid, allows sending messages to users who haven't started dialog with bot before. Business verification required.
Sending via Viber REST API
$authToken = env('VIBER_BOT_TOKEN');
// Send text message
$response = Http::withHeaders([
'X-Viber-Auth-Token' => $authToken
])->post('https://chatapi.viber.com/pa/send_message', [
'receiver' => $viberUserId, // unique Viber user ID
'type' => 'text',
'text' => "Your order #{$orderId} sent for delivery.",
'sender' => ['name' => 'My Store']
]);
Message with Button
Http::withHeaders(['X-Viber-Auth-Token' => $authToken])
->post('https://chatapi.viber.com/pa/send_message', [
'receiver' => $viberUserId,
'type' => 'rich_media',
'rich_media' => [
'Type' => 'rich_media',
'ButtonsGroupRows' => 2,
'Buttons' => [
[
'Columns' => 6,
'Rows' => 1,
'Text' => 'Track order',
'ActionType' => 'open-url',
'ActionBody' => "https://track.example.com/order/{$orderId}"
]
]
]
]);
Webhook and Incoming Processing
// Register webhook
Http::withHeaders(['X-Viber-Auth-Token' => $authToken])
->post('https://chatapi.viber.com/pa/set_webhook', [
'url' => 'https://yoursite.com/webhooks/viber',
'event_types' => ['delivered', 'seen', 'failed', 'subscribed', 'unsubscribed', 'conversation_started', 'message']
]);
// Handler
Route::post('/webhooks/viber', function (Request $request) {
$event = $request->json()->all();
$type = $event['event'];
if ($type === 'message') {
$userId = $event['sender']['id'];
$text = $event['message']['text'];
dispatch(new ProcessViberMessageJob($userId, $text));
}
if ($type === 'subscribed') {
// User subscribed to bot
ViberUser::updateOrCreate(['viber_id' => $event['user']['id']], [...]);
}
return response()->json(['status' => 0]); // 0 = OK for Viber
});
Getting User's Viber ID
User's Viber ID comes in conversation_started event (first dialog) or subscribed. Need to save user_id → viber_id link in DB.
Sending via Aggregators (SMSC)
To send Viber messages without own bot, use SMSC.ru — it supports Viber Business Messages via unified API.
Integration timeframe: 2–3 days for basic integration with notifications and incoming.







