Loading...
Skip to main content

Viber

Viber Requirements

  1. A Viber bot account. Make a note of the auth token.
  2. An active webhooks server that can receive POST requests from Viber. Viber provides a nodejs utility for handling these requests.
  3. The recipient must have an active Viber account logged into either the iOS or Android app.

Webhooks Server

Before sending notifications Viber requires a webhooks server to be registered. This can be done using the following cURL command:

 curl -X POST 'https://chatapi.viber.com/pa/set_webhook'\
-H 'Content-Type: application/json'\
-H 'X-Viber-Auth-Token: <VIBER_AUTH_TOKEN>'\
-d '{ "url": "<YOUR_WEBHOOK_SERVER_URL>", "event_types": ["delivered"] }'

This webhooks server will receive events from Viber such as UserID's of users who wish to subscribe, as well as notification delivery status events.

Sending a Direct Message

To send a direct message to a user, supply the Viber UserID to the viber.receiver property of the recipient profile. This UserID is sent to the webhooks server after they send a message to the Viber bot.

{
"message": {
// Recipient Profile
"to": {
"viber": {
"receiver": "12943673=="
}
}
}
}