# Viber Bots over API

Make sure that you are familiar with [compliance and guidelines](https://www.infobip.com/docs/compliance-guidelines) and details of [message types](https://www.infobip.com/docs/message-types) before sending Viber Bots messages.

## Bots API

Use the [Viber Bots API](https://www.infobip.com/docs/api/channels/viber/viber-bot) to send messages to end users.

Follow the [Authentication guide](https://www.infobip.com/docs/api/authentication) to secure your connection with Infobip.

### Outbound messages [#outbound-messages-bots-api]

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 [#message-options-bots-api]

Additional message options can be applied to your API request.

##### Bulk messages [#bulk-messages-bots-api]

You can send multiple text messages or message templates in a single API request.

##### Scheduling messages [#scheduling-messages-bots-api]

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.

```json showLineNumbers copy filename="json"
    "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**.

```json showLineNumbers copy filename="json"
    "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.

```json showLineNumbers copy filename="json"
    "deliveryTimeWindow": {
        "days": [
            "MONDAY",
            "TUESDAY",
            "WEDNESDAY",
            "THURSDAY",
            "FRIDAY",
            "SATURDAY",
            "SUNDAY"
            ],
        "from": {
            "hour": 6,
            "minute": 0
            },
        "to": {
            "hour": 15,
            "minute": 30
            }
        }
```

##### Validity period [#validity-period-bots-api]

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**.

```json showLineNumbers copy filename="json"
    "validityPeriod":  {
        "amount": 30,
        "timeUnit": "MINUTES"
        }
```

##### SMS Failover [#sms-failover-bots-api]

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.

```json showLineNumbers copy filename="json"
    "smsFailover":  {
        "sender": "41793026726",
        "text": "Failover message text",
        "validityPeriod":  {
            "amount": 2,
            "timeUnit": "HOURS"
            }
        }
```

##### Platform [#platform-bots-api]

Viber APIs work seamlessly with [CPaaS X](https://www.infobip.com/docs/cpaas-x/application-and-entity-management). 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](https://www.infobip.com/docs/cpaas-x).

```json showLineNumbers copy filename="json"
    "platform": {
        "entityId": "priorityCustomer",
        "applicationId": "clientTestEnvironment"
        }
```

##### Webhooks [#webhooks-bots-api]

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.

```json showLineNumbers copy filename="json"
    "webhooks": {
        "delivery": {
            "url": "https://www.example.com/viberbots"
            },
        }
```

### Inbound messages [#inbound-messages-bots-api]

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 <apidocslink href="channels/viber/viber-bot/receive-viber-bot-api-incoming-messages">receive</apidocslink> the following types of messages from end users:

- Text
- Image
- Video
- File
- Audio
- Location
- Contact
- Sticker

### Reports [#reports-bots-api]

After you successfully send a message, you can check the status of the sent message. The following reports are forwarded to a defined endpoint:

- <apidocslink href="channels/viber/viber-bot/get-outbound-viber-bot-message-delivery-reports">Delivery reports</apidocslink>

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.