Using Phone Number
It is possible to send messages to users using phone numbers they've associated with their Viber accounts. Viber calls this method Viber Business Messages.
Viber Business Messages offer the only way to send a message to Viber using a phone number. You cannot use a phone number with a Viber Bot account.
How it Works
The advantage of Viber is that every Viber account is associated with a phone number. That means the delivery rate is quite high.
- User receives a request - push notification
- User confirms the message
- User receives the message
Prerequisites
You can create Viber Business Message channel but it has to be confirmed by Viber.
Contact us at [email protected] if you are interested in Viber Business Messages.
Price
Viber charges for each delivered message. Price is different for each country and is usually around half the price for SMS. Contact us at [email protected] to get prices for your country. There is also a minimum payment required. The value is chosen regarding of a country selected (150/300/500 €/month).
Setup
1. Send Message
If you get a HTTP response 201
to your request, it means that the message was accepted to be processed by Viber, but it's not guaranteed that it will be delivered to the phone number. If Viber is unable to deliver the message (for example the when the phone number is not connected to any Viber account), you will receive Message Failed webhook.
Note that the phone number in response is in E.164 format.
{
"contact": {
"phone_number": "+1 (555) 857-6309"
},
"channel": {...},
"content": {...}
}
{
"id": "...",
"contact": {
"id": "15234390803083474",
"phone_number": "15558576309"
},
"channel": {...},
"content": {...}
}
See API reference for full documentation.
Message Types
Only certain message types (text, structure and image) can be send using phone number. See API reference for more details.
2. Listen to Message Delivered Webhook
When the message is delivered, you will receive a Messages Delivered webhook.
{
"event": "messages_delivered",
"timestamp" : "2017-12-29T17:26:17.331Z",
"data" : {
"channel": {
"id": "6456078759331238786",
"type": "viber_business_messages"
},
"contact": {
"id": "6456078781510718339",
"phone_number": "15558576309"
},
"messages": [
{ "id": "6456078996108088196" },
{ "id": "6456079002382766981" }
],
"delivered_timestamp": "2017-12-29T17:26:16.001Z"
}
}
3. (Optional) Listen to Message Failed Webhook
When the message fails to send, you will receive a Message Failed webhook. The most common reason of failure is that a given phone number doesn't have Viber account assigned.
{
"event": "message_failed",
"timestamp" : "2017-12-29T17:26:18.361Z",
"data" : {
"channel": {
"id": "6456078759331238786",
"type": "viber_business_messages"
},
"contact": {
"id": "6456078781510718339",
"phone_number": "15551111111"
},
"message": {
"id": "6456078996108088196"
},
"error_code": 3,
"reason": "Cannot find Viber user for given phone number."
}
}
Updated about 2 months ago