{"_id":"589384daa7a53c3b00299cc1","project":"54d3007669578e0d002730c9","user":"58927c129bc9f319002bc59d","category":{"_id":"5845a4a89f6fbb1b004307bd","project":"54d3007669578e0d002730c9","__v":0,"version":"5845a4a89f6fbb1b004307b7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-08T18:48:02.369Z","from_sync":false,"order":5,"slug":"integrations","title":"Integrations"},"parentDoc":null,"__v":0,"version":{"_id":"5845a4a89f6fbb1b004307b7","project":"54d3007669578e0d002730c9","__v":2,"createdAt":"2016-12-05T17:32:24.708Z","releaseDate":"2016-12-05T17:32:24.708Z","categories":["5845a4a89f6fbb1b004307b8","5845a4a89f6fbb1b004307b9","5845a4a89f6fbb1b004307ba","5845a4a89f6fbb1b004307bb","5845a4a89f6fbb1b004307bc","5845a4a89f6fbb1b004307bd","5845a4a89f6fbb1b004307be","5845a4a89f6fbb1b004307bf","5845a4a89f6fbb1b004307c0","592deb23644f060f008e5aa6"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"25.0.0","version":"25"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-02-02T19:13:30.211Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":16,"body":"* [Overview](#overview)\n* [Setting Up Your Public Account in Viber](#setting-up-your-public-account-in-viber)\n* [Configuring Viber Integration in API.AI](#configuring-viber-integration-in-apiai)\n* [Testing Your Viber Bot](#testing-your-viber-bot)\n* [Publishing Your Viber Public Account](#publishing-your-viber-public-account)\n* [Using Welcome Intent in Viber](#using-welcome-intent-in-viber)\n* [Rich Messages in One-click Viber Integration](#rich-messages-in-one-click-viber-integration)\n * [Text response](#section-text-response)\n * [Image](#section-image)\n * [Card](#section-card)\n * [Quick replies](#section-quick-replies)\n * [Custom payload](#section-custom-payload)\n   * [Text](#section-text)\n   * [Picture](#section-picture)\n   * [Video](#section-video)\n   * [File](#section-file)\n   * [Stickers](#section-stickers)\n   * [Location](#section-location)\n   * [Contact](#section-contact)\n   * [Keyboards (buttons)](#section-keyboards-buttons-)\n* [Getting \"originalRequest\" through a Webhook](#getting-originalrequest-through-a-webhook)\n* [Using API.AI Source Code for Custom Implementations](#using-apiai-source-code-for-custom-implementations)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Overview\"\n}\n[/block]\n**API.AI Viber Integration** allows you to easily create Viber bots with natural language understanding based on the API.AI technology. For more information about Viber go to [viber.com](http://viber.com).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting Up Your Public Account in Viber\"\n}\n[/block]\nGo to [https://www.viber.com/en/public-accounts](https://www.viber.com/en/public-accounts) and click the 'Apply to Public Account' button. Fill in all the required fields and submit your application. \n\nYou will receive a confirmation in your Viber mobile app:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6bcc3db-image00.png\",\n        \"image00.png\",\n        640,\n        1136,\n        \"#eef1f1\"\n      ]\n    }\n  ]\n}\n[/block]\nFollow the instructions in this message and start creating your Public Account as described at [https://developers.viber.com/public-accounts/index.html\\#access](https://developers.viber.com/public-accounts/index.html#access).\n\nYour Public Account consists of three parts:\n\n1. Info screen is the place where users choose how to interact.\n2. Public chat allows Public Account owners to share content about their \n   brand.\n3. 1-on-1 chat allows Viber users and businesses to interact directly.\n\nThe third part allows Public Account owners to create a chatbot.\n\nAfter the setup has been completed, you'll be able to get your Viber App Key as described at [https://developers.viber.com/public-accounts/index.html\\#authentication-token](https://developers.viber.com/public-accounts/index.html#authentication-token). \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a80fb6f-image01.jpg\",\n        \"image01.jpg\",\n        640,\n        1136,\n        \"#7d75b4\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Configuring Viber Integration in API.AI\"\n}\n[/block]\n[Create an API.AI agent](https://console.api.ai/api-client/#/newAgent) with the help of the [API.AI NLU technology tools](https://docs.api.ai/docs/key-concepts).\n\nIn the left hand menu of your API.AI developer console, click 'Integrations' and enable Viber integration.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/db930ae-image02.jpg\",\n        \"image02.jpg\",\n        2030,\n        786,\n        \"#faf3fa\"\n      ]\n    }\n  ]\n}\n[/block]\nFill in the integration settings fields:\n\n* Paste the Viber App Key that you copied from your mobile Viber app settings to \n  the respective field. \n* Enter a bot name. It can be up to 28 characters long. \n* Enter a public URL that points to your bot's avatar. Avatar file size should \n  not exceed 100kb. Recommended dimensions are 720x720 pixels.\n\nThen, click 'START'.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/705ef76-image03.jpg\",\n        \"image03.jpg\",\n        2200,\n        1272,\n        \"#495163\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Testing Your Viber Bot\"\n}\n[/block]\nStart chatting with your bot in your Viber mobile or desktop app. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8a1cf58-image04.png\",\n        \"image04.png\",\n        640,\n        1136,\n        \"#e0e9ea\"\n      ]\n    }\n  ]\n}\n[/block]\nBefore publishing your Public Account to the community, you can invite friends to test your bot. There are several options:\n\n* Share your Public Account with them\n* Add them as account participants \n* Add them as account admins\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/13119fd-image05.jpg\",\n        \"image05.jpg\",\n        2394,\n        1324,\n        \"#dee4e4\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b8f28b0-image06.jpg\",\n        \"image06.jpg\",\n        640,\n        1136,\n        \"#4c459e\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Publishing Your Viber Public Account\"\n}\n[/block]\nIn order to make your Viber bot visible to the general public, you need to publish your Viber Public Account. To do so, go to your Public Account settings in your Viber mobile app and tap the 'Publish' button.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ad3a4fe-image07.jpg\",\n        \"image07.jpg\",\n        677,\n        1136,\n        \"#e6abaa\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Using Welcome Intent in Viber\"\n}\n[/block]\nWhen you create a new agent, a [Default Welcome Intent](https://docs.api.ai/docs/concept-events#default-welcome-intent) is automatically added. It has the WELCOME [event](https://docs.api.ai/docs/concept-events) that is generic to all currently supported messaging platform one-click integrations including Viber integration.\n\nThis intent will be triggered every time the user taps on the chat icon.\n\nYou can use the default text responses defined in the 'Response' section or define your own custom responses.\n\nNote that if you don't have a welcome intent and have a fallback intent, the bot will use responses from the fallback intent. \n\nIf you want to create a separate welcome intent for Viber integration only, you can create a new intent and set the VIBER_WELCOME event in it. Otherwise, you can set an event with such name in the Default Welcome Intent instead of the default WELCOME event.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Rich Messages in One-click Viber Integration\"\n}\n[/block]\nIf you use our one-click integration, your Viber bot can reply with both text messages or [rich messages](https://docs.api.ai/docs/rich-messages). To add rich messages in intents, click the 'ADD MESSAGE CONTENT' button in the 'Viber' tab in the 'Response' section and choose a specific element. \n\nYou can choose up to 10 elements. They will be given by your Viber bot as sequential messages in response to a user query. You can drag response elements in the UI to reorder them. \n\n##Text response\n\nYour bot can send up to 10 sequential text messages in response to a user input (assuming no other message types are defined in the intent). Line breaks are supported. All other features described at [https://docs.api.ai/docs/concept-intents\\#section-text-response](https://docs.api.ai/docs/concept-intents#section-text-response) are supported.\n\n##Image\n\nTo set the 'Image' element, enter a public URL to a picture in JPEG format. Maximum file size is 1MB. \n\n##Card\n\nIn 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.\n\nFor images, provide a public URL to a JPEG picture file up to 1MB in size.\n\nPostback for buttons can be defined either as text or a URL. \n\n* 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.\n* 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](https://developers.viber.com/tools/keyboards/index.html#replyLogic).\n\n##Quick replies\n\nQuick replies correspond to the text version of [Viber Keyboards](https://developers.viber.com/api/rest-bot-api/index.html#keyboards). You can add up to 10 quick replies.\n\n##Custom payload\n\nYou can define custom payloads using the following format `{\"viber\": {<data>}}`, where `<data>` should be defined according to the [Viber REST API documentation](https://developers.viber.com/api/rest-bot-api/index.html#send-message).\n\nAvailable message types are listed below.\n\n###Text\n\nInstead of defining a text response in the 'Text response' element of the 'Response' section, you can do it in the 'Custom payload' element.\n\nIt may look like this:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"text\",  \n    \"text\": \"This text is being sent via Custom Payload\"  \n  }  \n}\n```\n\n###Picture\n\nInstead of setting a picture URL in the 'Image' element of the \"Response' section, you can do it in the 'Custom payload' element.\n\nHere's an example of how you can send a picture with text via custom payload:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"picture\",  \n    \"text\": \"New Year picture\",  \n    \"media\": \"https://examples.api.ai/RichMessagesFiles/new_year_1MB.jpg\"  \n  }  \n}\n```\n\nMaximum 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. \n\nThe \"text\" field value is a string of up to 120 characters long. It can have an empty value, but the field is mandatory. \n\nYou 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.\n\n###Video\n\nYour Viber bot can send videos. Here's an example of how the 'Custom payload' element may look  for sending a video:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"video\",  \n    \"media\": \"https://examples.api.ai/RichMessagesFiles/studebaker_1950.mp4\",  \n    \"size\": 1728614,  \n    \"duration\": 20  \n  }  \n}\n```\n\nNote 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. \n\nYou 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.\n\n###File\n\nYour Viber bot can send files. Here's an example of how the 'Custom payload' element may look for sending a file:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"file\",  \n    \"media\": \"https://examples.api.ai/RichMessagesFiles/LoremIpsum.pdf\",  \n    \"size\": 27780,  \n    \"file_name\": \"LoremIpsum.pdf\"  \n  }  \n}\n```\n\nNote the all the fields – \"type\", \"media\", \"size\", and \"file_name\" – are mandatory. Maximum file size is 50MB. See the list of [unsupported file formats](https://developers.viber.com/api/rest-bot-api/index.html#forbiddenFileFormats). 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.\n\n###Stickers\n\nYour bot can reply with stickers. Sticker IDs can be found [here](https://developers.viber.com/tools/sticker-ids/index.html).\n\nHere's an example of how the custom payload can be defined to send a sticker:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"sticker\",  \n    \"sticker_id\": 40123  \n  }  \n}\n```\n\n###Location\n\nYour bot can send a message that will be displayed as a map, showing a specific location. Here's an example:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"location\",  \n    \"location\": {  \n        \"lat\": \"37.7898\",  \n        \"lon\": \"-122.3942\"  \n    }  \n  }  \n}\n```\n\n###Contact\n\nYour bot can send contacts (name and phone number). See an example below:\n\n```\n{  \n  \"viber\": {  \n    \"type\": \"contact\",  \n    \"contact\": {  \n      \"name\": \"Alex\",  \n      \"phone_number\": \"+972511123123\"  \n    }  \n  }  \n}\n```\n\nThe \"name\" field value can be up to 28 characters long. The \"phone_number\" field value can be up to 18 characters long.\n\n###Keyboards (buttons)\n\nUsing the 'Custom payload' element, you can send custom keyboards (buttons) with any of the other message types available for sending via 'Custom payload'. \n\nThe 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](https://developers.viber.com/tools/keyboards/index.html).\n\nSee a sample keyboard example below. \n\n```\n{  \n  \"viber\": {  \n    \"type\": \"contact\",  \n    \"contact\": {  \n      \"name\": \"Alex\",  \n      \"phone_number\": \"+972511123123\"  \n    },  \n    \"keyboard\": {  \n        \"Type\": \"keyboard\",  \n        \"DefaultHeight\": true,  \n        \"Buttons\": [{  \n            \"ActionType\": \"reply\",  \n            \"ActionBody\": \"reply to PA\",  \n            \"Text\": \"Key text\",  \n            \"TextSize\": \"regular\"  \n        }]  \n    }  \n  }  \n}\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Getting \\\"originalRequest\\\" through a Webhook\"\n}\n[/block]\nIf you connect your Viber integration API.AI agent with your web service via a [webhook](https://docs.api.ai/docs/webhook), you will receive the \"originalRequest\" field in the request from API.AI. This field contains some data about the user profile: user name and user ID. User ID can be used in your business logic to get more information about the user with the help of [Viber REST API](https://developers.viber.com/api/rest-bot-api/index.html#get-user-details).\n\nHere's an example of the \"originalRequest\" part received in a web service when testing API.AI Viber integration:\n\n```\n{  \n\t\"originalRequest\": {  \n\t\t\"source\": \"viber\",  \n\t\t\"data\": {  \n\t\t\t\"message\": {  \n\t\t\t\t\"text\": \"shipping costs for asia\",  \n\t\t\t\t\"token\": 5.006988580567908e+18,  \n\t\t\t\t\"trackingData\": {},  \n\t\t\t\t\"timestamp\": 1485816879019.0  \n\t\t\t},  \n\t\t\t\"userProfile\": {  \n\t\t\t\t\"name\": \"S\",  \n\t\t\t\t\"id\": \"X1f634csh6uR1VPMNVMl0w==\"  \n\t\t\t}  \n\t\t}  \n\t}  \n}\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Using API.AI Source Code for Custom Implementations\"\n}\n[/block]\nYou can use our source code from Github and deploy it to your own server, to Heroku, or any other service. This option will allow your to modify the code and customize the integration.","excerpt":"","slug":"viber-integration","type":"basic","title":"Viber"}
* [Overview](#overview) * [Setting Up Your Public Account in Viber](#setting-up-your-public-account-in-viber) * [Configuring Viber Integration in API.AI](#configuring-viber-integration-in-apiai) * [Testing Your Viber Bot](#testing-your-viber-bot) * [Publishing Your Viber Public Account](#publishing-your-viber-public-account) * [Using Welcome Intent in Viber](#using-welcome-intent-in-viber) * [Rich Messages in One-click Viber Integration](#rich-messages-in-one-click-viber-integration) * [Text response](#section-text-response) * [Image](#section-image) * [Card](#section-card) * [Quick replies](#section-quick-replies) * [Custom payload](#section-custom-payload) * [Text](#section-text) * [Picture](#section-picture) * [Video](#section-video) * [File](#section-file) * [Stickers](#section-stickers) * [Location](#section-location) * [Contact](#section-contact) * [Keyboards (buttons)](#section-keyboards-buttons-) * [Getting "originalRequest" through a Webhook](#getting-originalrequest-through-a-webhook) * [Using API.AI Source Code for Custom Implementations](#using-apiai-source-code-for-custom-implementations) [block:api-header] { "type": "basic", "title": "Overview" } [/block] **API.AI Viber Integration** allows you to easily create Viber bots with natural language understanding based on the API.AI technology. For more information about Viber go to [viber.com](http://viber.com). [block:api-header] { "type": "basic", "title": "Setting Up Your Public Account in Viber" } [/block] Go to [https://www.viber.com/en/public-accounts](https://www.viber.com/en/public-accounts) and click the 'Apply to Public Account' button. Fill in all the required fields and submit your application. You will receive a confirmation in your Viber mobile app: [block:image] { "images": [ { "image": [ "https://files.readme.io/6bcc3db-image00.png", "image00.png", 640, 1136, "#eef1f1" ] } ] } [/block] Follow the instructions in this message and start creating your Public Account as described at [https://developers.viber.com/public-accounts/index.html\#access](https://developers.viber.com/public-accounts/index.html#access). Your Public Account consists of three parts: 1. Info screen is the place where users choose how to interact. 2. Public chat allows Public Account owners to share content about their brand. 3. 1-on-1 chat allows Viber users and businesses to interact directly. The third part allows Public Account owners to create a chatbot. After the setup has been completed, you'll be able to get your Viber App Key as described at [https://developers.viber.com/public-accounts/index.html\#authentication-token](https://developers.viber.com/public-accounts/index.html#authentication-token). [block:image] { "images": [ { "image": [ "https://files.readme.io/a80fb6f-image01.jpg", "image01.jpg", 640, 1136, "#7d75b4" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Configuring Viber Integration in API.AI" } [/block] [Create an API.AI agent](https://console.api.ai/api-client/#/newAgent) with the help of the [API.AI NLU technology tools](https://docs.api.ai/docs/key-concepts). In the left hand menu of your API.AI developer console, click 'Integrations' and enable Viber integration. [block:image] { "images": [ { "image": [ "https://files.readme.io/db930ae-image02.jpg", "image02.jpg", 2030, 786, "#faf3fa" ] } ] } [/block] Fill in the integration settings fields: * Paste the Viber App Key that you copied from your mobile Viber app settings to the respective field. * Enter a bot name. It can be up to 28 characters long. * Enter a public URL that points to your bot's avatar. Avatar file size should not exceed 100kb. Recommended dimensions are 720x720 pixels. Then, click 'START'. [block:image] { "images": [ { "image": [ "https://files.readme.io/705ef76-image03.jpg", "image03.jpg", 2200, 1272, "#495163" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Testing Your Viber Bot" } [/block] Start chatting with your bot in your Viber mobile or desktop app. [block:image] { "images": [ { "image": [ "https://files.readme.io/8a1cf58-image04.png", "image04.png", 640, 1136, "#e0e9ea" ] } ] } [/block] Before publishing your Public Account to the community, you can invite friends to test your bot. There are several options: * Share your Public Account with them * Add them as account participants * Add them as account admins [block:image] { "images": [ { "image": [ "https://files.readme.io/13119fd-image05.jpg", "image05.jpg", 2394, 1324, "#dee4e4" ] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/b8f28b0-image06.jpg", "image06.jpg", 640, 1136, "#4c459e" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Publishing Your Viber Public Account" } [/block] In order to make your Viber bot visible to the general public, you need to publish your Viber Public Account. To do so, go to your Public Account settings in your Viber mobile app and tap the 'Publish' button. [block:image] { "images": [ { "image": [ "https://files.readme.io/ad3a4fe-image07.jpg", "image07.jpg", 677, 1136, "#e6abaa" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Using Welcome Intent in Viber" } [/block] When you create a new agent, a [Default Welcome Intent](https://docs.api.ai/docs/concept-events#default-welcome-intent) is automatically added. It has the WELCOME [event](https://docs.api.ai/docs/concept-events) that is generic to all currently supported messaging platform one-click integrations including Viber integration. This intent will be triggered every time the user taps on the chat icon. You can use the default text responses defined in the 'Response' section or define your own custom responses. Note that if you don't have a welcome intent and have a fallback intent, the bot will use responses from the fallback intent. If you want to create a separate welcome intent for Viber integration only, you can create a new intent and set the VIBER_WELCOME event in it. Otherwise, you can set an event with such name in the Default Welcome Intent instead of the default WELCOME event. [block:api-header] { "type": "basic", "title": "Rich Messages in One-click Viber Integration" } [/block] If you use our one-click integration, your Viber bot can reply with both text messages or [rich messages](https://docs.api.ai/docs/rich-messages). To add rich messages in intents, click the 'ADD MESSAGE CONTENT' button in the 'Viber' tab in the 'Response' section and choose a specific element. You can choose up to 10 elements. They will be given by your Viber bot as sequential messages in response to a user query. You can drag response elements in the UI to reorder them. ##Text response Your bot can send up to 10 sequential text messages in response to a user input (assuming no other message types are defined in the intent). Line breaks are supported. All other features described at [https://docs.api.ai/docs/concept-intents\#section-text-response](https://docs.api.ai/docs/concept-intents#section-text-response) are supported. ##Image To set the 'Image' element, enter a public URL to a picture in JPEG format. Maximum file size is 1MB. ##Card 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](https://developers.viber.com/tools/keyboards/index.html#replyLogic). ##Quick replies Quick replies correspond to the text version of [Viber Keyboards](https://developers.viber.com/api/rest-bot-api/index.html#keyboards). You can add up to 10 quick replies. ##Custom payload You can define custom payloads using the following format `{"viber": {<data>}}`, where `<data>` should be defined according to the [Viber REST API documentation](https://developers.viber.com/api/rest-bot-api/index.html#send-message). Available message types are listed below. ###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://examples.api.ai/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://examples.api.ai/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://examples.api.ai/RichMessagesFiles/LoremIpsum.pdf", "size": 27780, "file_name": "LoremIpsum.pdf" } } ``` Note the all the fields – "type", "media", "size", and "file_name" – are mandatory. Maximum file size is 50MB. See the list of [unsupported file formats](https://developers.viber.com/api/rest-bot-api/index.html#forbiddenFileFormats). 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](https://developers.viber.com/tools/sticker-ids/index.html). 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](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" }] } } } ``` [block:api-header] { "type": "basic", "title": "Getting \"originalRequest\" through a Webhook" } [/block] If you connect your Viber integration API.AI agent with your web service via a [webhook](https://docs.api.ai/docs/webhook), you will receive the "originalRequest" field in the request from API.AI. This field contains some data about the user profile: user name and user ID. User ID can be used in your business logic to get more information about the user with the help of [Viber REST API](https://developers.viber.com/api/rest-bot-api/index.html#get-user-details). Here's an example of the "originalRequest" part received in a web service when testing API.AI Viber integration: ``` { "originalRequest": { "source": "viber", "data": { "message": { "text": "shipping costs for asia", "token": 5.006988580567908e+18, "trackingData": {}, "timestamp": 1485816879019.0 }, "userProfile": { "name": "S", "id": "X1f634csh6uR1VPMNVMl0w==" } } } } ``` [block:api-header] { "type": "basic", "title": "Using API.AI Source Code for Custom Implementations" } [/block] You can use our source code from Github and deploy it to your own server, to Heroku, or any other service. This option will allow your to modify the code and customize the integration.