Viber

Dialogflow Viber Integration allows you to easily create Viber bots with natural language understanding based on the Dialogflow technology. For more information about Viber go to viber.com.

Setting Up Viber

In order to set up the Viber integration for your agent, you'll need the
following:

Once your Public Account has been approved, get your Viber App Key from the app, as described here.

Setting Up Dialogflow

  1. In Dialogflow, go to Integrations in the left hand menu
  2. Click on the Viber tile
  3. Enter the related info into the following fields:
    • Viber App Key
    • Bot Name
    • Public URL to bot's avatar
  4. Click the Start button

Testing

You can test your bot in the Viber mobile or desktop app. Additionally, you can invite others to test your bot, using one of the following methods:

Events

The following events are invoked by this integration:

Event Description
VIBER_WELCOME Triggered when a user starts a conversation with your Viber bot.

Rich response messages

The following rich response messages are supported.

Image responses

Supported formats and sizes:

  • jpeg
  • 1 MB max size

Card responses

In the 'Card' element, you can send a picture with a title and a subtitle accompanied by up to 3 buttons. None of these 'Card' elements are mandatory in the Viber integration, so you can use them individually.

For images, provide a public URL to a JPEG picture file up to 1MB in size.

Postback for buttons can be defined either as text or a URL.

  • For text, the button name will appear in the chat as a request from the user, whereas the postback text is sent to the bot and is not visible.
  • For a URL, the link will be open in a separate window and the URL will be sent in the chat as request from the user. More information about buttons logic can be found in the Viber REST API documentation.

Quick reply responses

Quick replies correspond to the text version of Viber Keyboards. You can add up to 10 quick replies.

Custom payload responses

See the integration's developer docs for more information:

Text

Instead of defining a text response in the 'Text response' element of the 'Response' section, you can do it in the 'Custom payload' element.

It may look like this:

{
  "viber": {
    "type": "text",
    "text": "This text is being sent via Custom Payload"
  }
}

Picture

Instead of setting a picture URL in the 'Image' element of the "Response' section, you can do it in the 'Custom payload' element.

Here's an example of how you can send a picture with text via custom payload:

{
  "viber": {
    "type": "picture",
    "text": "New Year picture",
    "media": "https://example.com/RichMessagesFiles/new_year_1MB.jpg"
  }
}

Maximum picture size is 1MB. Only JPEG format is supported. Other image formats as well as animated GIFs can be sent as URL messages or file messages.

The "text" field value is a string of up to 120 characters long. It can have an empty value, but the field is mandatory.

You can also include an optional "thumbnail" field that contains public URL to the reduced size image of up to 100kb size. Recommended size is 400x400. Only JPEG format is supported.

Video

Your Viber bot can send videos. Here's an example of how the 'Custom payload' element may look for sending a video:

{
  "viber": {
    "type": "video",
    "media": "https://example.com/RichMessagesFiles/studebaker_1950.mp4",
    "size": 1728614,
    "duration": 20
  }
}

Note the all the fields – "type", "media", "size", and "duration" – are mandatory. Maximum video file size is 50MB. Only MP4 and H264 are supported. Maximum duration of the video is 180 seconds.

You can also add a "thumbnail" field with a URL of a reduced size image (JPEG). Maximum size of the thumbnail is 100kb. Recommended dimensions are 400x400 pixels.

File

Your Viber bot can send files. Here's an example of how the 'Custom payload' element may look for sending a file:

{
  "viber": {
    "type": "file",
    "media": "https://example.com/RichMessagesFiles/LoremIpsum.pdf",
    "size": 27780,
    "file_name": "LoremIpsum.pdf"
  }
}

Note that all the fields – "type", "media", "size", and "file_name" – are mandatory. The maximum file size is 50MB. See the list of unsupported file formats. The "size" field has a numeric value and indicates the file size in bytes. The file name can be up to 256 characters including the file extension.

Stickers

Your bot can reply with stickers. Sticker IDs can be found here.

Here's an example of how the custom payload can be defined to send a sticker:

{
  "viber": {
    "type": "sticker",
    "sticker_id": 40123
  }
}

Location

Your bot can send a message that will be displayed as a map showing a specific location. Here's an example:

{
  "viber": {
    "type": "location",
    "location": {
        "lat": "37.7898",
        "lon": "-122.3942"
    }
  }
}

Contact

Your bot can send contacts (name and phone number). See an example below:

{
  "viber": {
    "type": "contact",
    "contact": {
      "name": "Alex",
      "phone_number": "+972511123123"
    }
  }
}

The name field value can be up to 28 characters long. The phone_number field value can be up to 18 characters long.

Keyboards (buttons)

Using the 'Custom payload' element, you can send custom keyboards (buttons) with any of the other message types available for sending via 'Custom payload'.

The keyboard JSON object defines different visual and logic attributes (background color, number of buttons etc). For more information, see https://developers.viber.com/tools/keyboards/index.html.

See a sample keyboard example below.

{
  "viber": {
    "type": "contact",
    "contact": {
      "name": "Alex",
      "phone_number": "+972511123123"
    },
    "keyboard": {
        "Type": "keyboard",
        "DefaultHeight": true,
        "Buttons": [{
            "ActionType": "reply",
            "ActionBody": "reply to PA",
            "Text": "Key text",
            "TextSize": "regular"
        }]
    }
  }
}