Sending Viber messages programmatically

Sending Viber messages programmatically

Viber Developers Hub suggests semi-official library Bogdaan/viber-bot-php: Php bot interface to work with Viber API

alserom/viber-php: Unofficial library to work with Viber REST API and for develop a bot for the Viber platform.

mileusna/viber: Viber messaging/chatbot for Go/Golang

boyanraichev/laravel-viberbot: Viber Bot package for Laravel sokil/php-viber-notifier: Broadcast notification through Viber to subscribed users

Doing it

Created a bot and have token: 51ad2aaabfa7e1e2-9cfdbf4fb1bae40e-dec69ae2d7d5b0d4

Created a small PHP webhook at viber.api.cvladan.com/api/viberwebhook

curl -X POST -H "X-Viber-Auth-Token: 51ad2aaabfa7e1e2-9cfdbf4fb1bae40e-dec69ae2d7d5b0d4" -d '{"url":"https://www.koviljaca.rs/api/viber/webhook.php"}' https://chatapi.viber.com/pa/set_webhook

When you want to send message to a user but not to a group:

curl -X POST -H "X-Viber-Auth-Token: 51ad2aaabfa7e1e2-9cfdbf4fb1bae40e-dec69ae2d7d5b0d4" -d '{
   "receiver":"r4nV/0mSV1RL1W3hpdrVsA==",
   "type":"text", "text":"Zdravo, bre!"
}' https://chatapi.viber.com/pa/send_message

Using Viber API, it is impossible

API can send messages to users who subscribe to the account and is possible only after the user has subscribed to the bot. The bot is shared with the users via a deep link.

So, the only way to accomplish this is by using some Autohotkey script or similar, with which you can “automatically-manually” send messages like any other user.

date 21. Sep 2023 | modified 10. Jun 2024
filename: Miscellaneous » Sending Viber Messages