Viber Bots over API
Make sure that you are familiar with compliance and guidelines and details of message types before sending Viber Bots messages.
Bots API
Use the Viber Bots API (opens in a new tab) to send messages to end users.
Follow the Authentication guide (opens in a new tab) to secure your connection with Infobip.
Outbound messages
You can send the following types of messages over API:
- Text
- Image
- Video
- File
- Carousel
- Location
- Contact
- Sticker
- URL
Remember to add supplementary options to your send request in case you would like to benefit from our additional features.
Message options
Additional message options can be applied to your API request.
Bulk messages
You can send multiple text messages or message templates in a single API request.
Scheduling messages
Every communication can be scheduled. You can set a start date, time and time zone. This feature comes in handy when you don not want to disturb your customers during the night, or you want to send messages only during a specific period for optimal conversion.
"SendAt": 2015-07-07T17:00:00.000+01:00
An additional scheduling option is to set sending speed limit. For example, you can limit the sending speed when sending messages in bulk to deliver messages over a longer period of time. This feature can be beneficial when you expect recipients to react to your call-to-action embedded within the dispatched message. In that way you could avoid overwhelming your system or agents with an influx of responses from end customers and avoid operational strain. You can set the number (amount) of messages that will be sent periodically. Available time units are: minutes, hours, days.
"sendingSpeedLimit": {
"amount": 30,
"timeUnit": "HOUR"
}
You can also set a specific message delivery window outside of which messages won’t be delivered. You can set start time (hour/minute), end time (hour/minute) and days of the week. Time is expressed in the UTC time zone.
"deliveryTimeWindow": {
"days": [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY"
],
"from": {
"hour": 6,
"minute": 0
},
"to": {
"hour": 15,
"minute": 30
}
}
Validity period
There is a specific time period for messages during which the system will try to deliver them. For example, when you want to send a message to your audience and some users have their cell phones turned off, the system will retry delivery to these users until the validity period passes. The default and also the maximum validity period is 48 hours. It does not need to be set for each request. If you want to set a shorter period, you should define it under Validity period. Available time units are: seconds, minutes, hours. Default value is minutes.
"validityPeriod": {
"amount": 30,
"timeUnit": "MINUTES"
}
SMS Failover
Add a failover to SMS option in case your Viber message does not reach the end user within the defined period. You can also set a validity period for the SMS message.
"smsFailover": {
"sender": "41793026726",
"text": "Failover message text",
"validityPeriod": {
"amount": 2,
"timeUnit": "HOURS"
}
}
Platform
Viber APIs work seamlessly with CPaaS X. This gives you greater flexibility in managing your configurations and resources in whatever manner that suits your needs. For more information about CPaaS X, refer to our CPaaS X documentation.
"platform": {
"entityId": "priorityCustomer",
"applicationId": "clientTestEnvironment"
}
Webhooks
Use the webhooks
> delivery
> url
parameter option if you want users to be able to set the URL where they want to receive API responses. Define the URL under the webhooks parameter of the API request.
"webhooks": {
"delivery": {
"url": "https://www.example.com/viberbots"
},
}
Inbound messages
Incoming messages are forwarded to you in real-time when you use the API for two-way communication. The messages are forwarded to the endpoint that you provided when you set up your Viber account on Infobip solutions.
To enable messages from the Infobip web interface to be forwarded to an API endpoint, you must grant the relevant permission to the API endpoint. Use additional authorization headers to secure connections.
You can receive (opens in a new tab) the following types of messages from end users:
- Text
- Image
- Video
- File
- Audio
- Location
- Contact
- Sticker
Reports
After you successfully send a message, you can check the status of the sent message. The following reports are forwarded to a defined endpoint:
You can have delivery reports forwarded to your URL in real time. To set this feature, provide the URL to your Infobip Account Manager.
(Optional) You can define the endpoint in the webhooks
> delivery
> url
parameter of the API request of a message. If you do not define this endpoint, the reports are forwarded to the endpoint that is defined in the platform.