{"_id":"57c974903a28560e00040823","project":"54eb50e5615ffc1900305a16","version":{"_id":"54eb63b859b1172100334fae","project":"54eb50e5615ffc1900305a16","forked_from":"54eb63a1867e1917009b711d","__v":28,"createdAt":"2015-02-23T17:30:32.501Z","releaseDate":"2015-02-23T17:30:32.501Z","categories":["54eb63b959b1172100334faf","54eb63b959b1172100334fb0","54eb63b959b1172100334fb1","54eb63b959b1172100334fb2","54ed8dd4ab373e2300f50eae","54ed99b2ab373e2300f50ede","55153a6de68daa2f00cff838","551546edbc466623002afe72","5515472ac28d6125001b8884","55154749c28d6125001b8885","555d9b4106dfec0d00d38ea7","5613e06e433e5735007c7708","5624bbb785a31117001c5403","56669e857cc81e0d00253f8e","568b8d837a42220d00498311","56a632277ef6620d00e2f18a","56d8147c3eb4dd0b00201aac","57a9ce2fac6db30e000d7efd","57a9cf4e944ea60e00dc3f74","58172386715dce0f00da4aa0","582dc59ee1b8692300c0dd03","589b19b4fec2730f0082e040","58b04a023529383900a759b5","58b92d1598157a0f004869bf","592e7685c58275000f20174f","59392839e376d4002f8a0474","59393064e376d4002f8a05a1","5947ae0d4005e2000f3a4fec","594a74df1d1de5001ab3517a","5954bc387a147f001b918915","59b8eeeb707542001076d3b6"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"parentDoc":null,"user":"5683bbad70331a0d00484b27","__v":1,"category":{"_id":"56669e857cc81e0d00253f8e","project":"54eb50e5615ffc1900305a16","__v":8,"pages":["568ceacb8a7ca5190039643a","5693a7995f1c951900644b25","5698e793d36db20d00ddba45","56a0ce7441766e0d00b28cf8","56a0d36544f3d80d00a2c242","56a0d3e0aca0730d003e3475","56a5ecf7b91d8d0d008349cc","56d595dba0b5600b000b1e75"],"version":"54eb63b859b1172100334fae","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-12-08T09:10:29.254Z","from_sync":false,"order":6,"slug":"omni-channel-messaging","title":"OMNI channel messaging"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-02T12:46:08.485Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":true,"order":9,"body":"In the following examples, we'll show you how to configure the Viber-SMS failover scenario, send your first messages and retrieve message reports. \n\nThe messages will firstly be sent over the Viber communication channel. If the messages are rejected on Viber (for example, the user doesn't have Viber installed), the messages will be sent using the SMS communication channel. For each communication channel, a specific validity period can be set. \n\nThere are three easy steps to follow: \n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"VIBER - SMS OMNI process\",\n  \"body\": \"1. [Create an OMNI Scenario](#1-create-omni-scenario)\\n2. [Send message using an OMNI scenario](#2-send-omni-message)\\n3. [Get Delivery Reports](#3-get-delivery-reports)\\n4. [Receive incoming Viber message](#4-receive-incoming-viber-message)\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Create OMNI scenario\"\n}\n[/block]\nThe first step is to create an  **OMNI scenario**. In the OMNI scenario configuration, you need to define the OMNI steps which will be sequentially executed. The key parameters are **`channel`** and **`from`**, respectively identifying the communication channels and senders for each communication channel.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Prerequisites\",\n  \"body\": \"To be able to send Viber messages using the Infobip platform you need to configure the Viber service. Please [contact us](mailto:support:::at:::infobip.com) for service activation and configuration.\"\n}\n[/block]\nFor Viber sender (**\"channel\": \"VIBER\"** flow) you should use the Viber sender provided during the activation process.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /omni/1/scenarios HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{\\n  \\\"name\\\":\\\"My VIBER-SMS scenario\\\",\\n  \\\"flow\\\": [\\n    {\\n      \\\"from\\\": \\\"ViberSender\\\",\\n      \\\"channel\\\": \\\"VIBER\\\"\\n    },\\n    {\\n      \\\"from\\\": \\\"InfoSMS\\\",\\n      \\\"channel\\\": \\\"SMS\\\"\\n    }    \\n  ],\\n  \\\"default\\\": true\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n# Response format \n\nIf successful, the response header HTTP status code will be `200 OK` and the scenario will be created, as shown in the example bellow.\n\nIf you try to create the scenario without authorization, you will receive a `401 Unauthorized` error.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"key\\\": \\\"CC9F01A5DC7BEE2C2B829D203482A654\\\",\\n  \\\"name\\\":\\\"My VIBER-SMS scenario\\\",\\n  \\\"flow\\\": [\\n    {\\n      \\\"from\\\": \\\"ViberSender\\\",\\n      \\\"channel\\\": \\\"VIBER\\\"\\n    },\\n    {\\n      \\\"from\\\": \\\"InfoSMS\\\",\\n      \\\"channel\\\": \\\"SMS\\\"\\n    }    \\n  ],\\n  \\\"default\\\": true\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe **`key`** parameter needs to be stored as it will be used when sending the message.\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Info\",\n  \"body\": \"More information about creating an OMNI scenario can be found at the following page: [Scenario: Create](doc:omni-create-scenario) .\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"2. Send OMNI message\"\n}\n[/block]\nOnce you've created an OMNI scenario (identified by the **`key`** parameter) as described in the previous chapter, you are ready to send your OMNI messages through defined VIBER and SMS communication channels. Firstly, the VIBER message will be sent to the defined phoneNumber. If, for some reason, the message is rejected on the VIBER application or the end user doesn't have the Viber application installed, the message will be sent using the SMS communication channel.\n\nFor sending OMNI messages, you can use the **advanced** API method. Detailed descriptions about the **advanced** API method can be found here: [OMNI: Send an advanced message](doc:omni-send-advanced-message). \n\nThe parameters that should be set are the scenario key, phoneNumber and specific text for each communication channels, as shown below. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /omni/1/advanced HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{ \\n\\t\\\"scenarioKey\\\":\\\"CC9F01A5DC7BEE2C2B829D203482A654\\\",  \\n  \\\"destinations\\\":[ \\n  \\t{ \\n    \\t\\\"to\\\":{\\n        \\\"phoneNumber\\\": \\\"41793026727\\\"\\n      }\\n    }\\n  ],\\n  \\\"viber\\\": {\\n  \\t\\\"text\\\": \\\"This Viber message will be delivered to Viber application on the user device.\\\"\\n  },\\n  \\\"sms\\\": {\\n  \\t\\\"text\\\": \\\"This is the SMS failover message\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n# Response format \n\nIf successful, the response header HTTP status code will be `200 OK` and the message will be sent.\n\nIf you try to send the message without authorization, you will receive a `401 Unauthorized` error.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HTTP/1.1 200 OK\\nContent-Type: application/json\\n\\n{   \\n    \\\"messages\\\":[   \\n       {   \\n            \\\"to\\\":{\\n              \\\"phoneNumber\\\": \\\"41793026731\\\"\\n            },\\n            \\\"status\\\": {\\n                \\\"groupId\\\": 1,\\n                \\\"groupName\\\": \\\"PENDING\\\",\\n                \\\"id\\\": 7,\\n                \\\"name\\\": \\\"PENDING_ENROUTE\\\",\\n                \\\"description\\\": \\\"Message sent to next instance\\\"\\n            },\\n            \\\"messageId\\\": \\\"50c24400-124f-4678-9f4b-309e994a4deb\\\"\\n        }\\n    ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"3. Get Delivery Reports\"\n}\n[/block]\nOnce you've successfully sent your message using the **advanced** API method you can check the status of sent messages using the [OMNI reports](doc:omni-reports) method. \n\nThe simplest way is to use the method without any query parameters. In that case, the response will contain all messages sent to a specific account.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"GET /omni/1/reports HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nAccept: application/json\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe response will contain all messages, rejected and delivered, as shown in the example below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HTTP/1.1 200 OK\\nContent-Type: application/json\\n\\n{  \\n   \\\"results\\\":[  \\n      {  \\n         \\\"messageId\\\":\\\"1215f543ab19-345f-adbd-12ad31451ed25f35\\\",\\n         \\\"to\\\":\\\"41793026731\\\",\\n         \\\"messageCount\\\": 1,\\n         \\\"sentAt\\\":\\\"2016-02-23T17:41:11.833+0100\\\",\\n         \\\"doneAt\\\":\\\"2016-02-23T17:41:11.843+0100\\\",\\n         \\\"mccMnc\\\":\\\"22801\\\",\\n         \\\"price\\\":{  \\n            \\\"pricePerMessage\\\":0.0104,\\n            \\\"currency\\\":\\\"EUR\\\"\\n         },\\n         \\\"status\\\":{  \\n            \\\"groupId\\\":2,\\n            \\\"groupName\\\":\\\"UNDELIVERABLE\\\",\\n            \\\"id\\\":9,\\n            \\\"name\\\":\\\"UNDELIVERABLE_NOT_DELIVERED\\\",\\n            \\\"description\\\":\\\"Message sent not delivered\\\"\\n         },\\n         \\\"error\\\":{  \\n            \\\"groupId\\\":1,\\n            \\\"groupName\\\":\\\"HANDSET_ERRORS\\\",\\n            \\\"id\\\":6,\\n            \\\"name\\\":\\\"EC_ABSENT_SUBSCRIBER_SM\\\",\\n            \\\"description\\\":\\\"Absent Subscriber\\\",\\n            \\\"permanent\\\":false\\n         },\\n        \\\"channel\\\": \\\"VIBER\\\"\\n      },\\n      {  \\n         \\\"messageId\\\":\\\"2315d543441c-335f-1d3d-142d31451ed25f35\\\",\\n         \\\"to\\\":\\\"41793026731\\\",\\n         \\\"sentAt\\\":\\\"2016-06-23T17:40:31.773+0100\\\",\\n         \\\"doneAt\\\":\\\"2016-06-23T17:40:31.787+0100\\\",\\n         \\\"messageCount\\\":1,\\n         \\\"mccMnc\\\":\\\"22801\\\",\\n         \\\"price\\\":{  \\n            \\\"pricePerMessage\\\":0.01,\\n            \\\"currency\\\":\\\"EUR\\\"\\n         },\\n         \\\"status\\\":{  \\n            \\\"groupId\\\":3,\\n            \\\"groupName\\\":\\\"DELIVERED\\\",\\n            \\\"id\\\":5,\\n            \\\"name\\\":\\\"DELIVERED_TO_HANDSET\\\",\\n            \\\"description\\\":\\\"Message delivered to handset\\\"\\n         },\\n         \\\"error\\\":{  \\n            \\\"groupId\\\":0,\\n            \\\"groupName\\\":\\\"OK\\\",\\n            \\\"id\\\":0,\\n            \\\"name\\\":\\\"NO_ERROR\\\",\\n            \\\"description\\\":\\\"No Error\\\",\\n            \\\"permanent\\\":false\\n         },\\n        \\\"channel\\\": \\\"SMS\\\"\\n      }\\n   ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"4. Receive incoming Viber message\"\n}\n[/block]\nProvided that your Viber service account is two-way, you can receive messages that users send to you. In order to start receiving messages, you should set up an MO configuration and an HTTP forward action, as described in [Number configuration](doc:number-configuration).\n\nAll messages will be forwarded in the following format:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"results\\\": [{\\n        \\\"from\\\": \\\"385919998888\\\",\\n        \\\"to\\\": \\\"1234\\\",\\n        \\\"text\\\": \\\"Message text\\\",\\n        \\\"receivedAt\\\": \\\"2017-10-03T12:28:18.857+0000\\\",\\n        \\\"messageId\\\": \\\"5095978370419896438\\\",\\n        \\\"pairedMessageId\\\": \\\"1234567890123456\\\",\\n        \\\"callbackData\\\": \\\"calbackDataOnResourceAction\\\",\\n        \\\"price\\\": {\\n            \\\"pricePerMessage\\\": 0.000000,\\n            \\\"currency\\\": \\\"EUR\\\"\\n        }\\n    }],\\n    \\\"messageCount\\\": 1,\\n    \\\"pendingMessageCount\\\": 0\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Additional Examples\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Send Rich Viber message\"\n}\n[/block]\nIf you would like to send Viber messages containing text, images and CTA buttons please check the example provided below. The example also shows how to configure the custom validity period for each communication channel. \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-1\": \"string\",\n    \"0-0\": \"text\",\n    \"1-0\": \"imageURL\",\n    \"2-0\": \"buttonText\",\n    \"3-0\": \"buttonURL\",\n    \"1-1\": \"string\",\n    \"2-1\": \"string\",\n    \"3-1\": \"string\",\n    \"4-0\": \"isPromotional\",\n    \"4-1\": \"boolean\",\n    \"4-2\": \"Indicates if content is of promotional character.\",\n    \"3-2\": \"Viber Button Call To Action. Should point to your landing page.\",\n    \"2-2\": \"Viber button label. Max 20 characters.\",\n    \"1-2\": \"URL of the image sent in the Viber message.\",\n    \"0-2\": \"Text of the message that will be sent. Max 1000 characters.\",\n    \"5-0\": \"validityPeriod\",\n    \"5-2\": \"The message validity period in minutes. When the period expires, the message will be automatically sent using the next OMNI step.\",\n    \"5-1\": \"string\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Info\",\n  \"body\": \"Default validity period in OMNI for Viber messages is 24h and 48h for SMS messages.\"\n}\n[/block]\nRich Viber message request example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /omni/1/advanced HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{ \\n\\t\\\"scenarioKey\\\":\\\"CC9F01A5DC7BEE2C2B829D203482A654\\\",  \\n  \\\"destinations\\\":[ \\n  \\t{ \\n    \\t\\\"to\\\":{\\n        \\\"phoneNumber\\\": \\\"41793026727\\\"\\n      }\\n    }\\n  ],\\n \\\"viber\\\": {\\n    \\\"text\\\": \\\"This is the message which will be displayed in Viber Application. It can contain up to 1000 characters. \\\",\\n    \\\"imageURL\\\": \\\"http://www.infobip.com/infobip-logo.png\\\",\\n    \\\"buttonText\\\": \\\"More information\\\",\\n    \\\"buttonURL\\\": \\\"http://www.infobip.com/\\\",\\n    \\\"isPromotional\\\": true,\\n    \\\"validityPeriod\\\":1\\n  },\\n  \\\"sms\\\": {\\n    \\\"text\\\": \\\"This text will be received via SMS if Viber message is not delivered.\\\",\\n    \\\"validityPeriod\\\":1\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe message received in the Viber application is shown below:  \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0a7d82a-vibermsg.png\",\n        \"vibermsg.png\",\n        750,\n        1334,\n        \"#87c2de\"\n      ]\n    }\n  ]\n}\n[/block]\nIf you have any additional questions please contact us at [contact us](mailto:support@infobip.com).","excerpt":"Find out about the simple methods which will allow you to send messages and retrieve message reports using the Viber and SMS communication channels.","slug":"omni-channel-viber-example","type":"basic","title":"OMNI channel: Viber example"}

OMNI channel: Viber example

Find out about the simple methods which will allow you to send messages and retrieve message reports using the Viber and SMS communication channels.

In the following examples, we'll show you how to configure the Viber-SMS failover scenario, send your first messages and retrieve message reports. The messages will firstly be sent over the Viber communication channel. If the messages are rejected on Viber (for example, the user doesn't have Viber installed), the messages will be sent using the SMS communication channel. For each communication channel, a specific validity period can be set. There are three easy steps to follow: [block:callout] { "type": "warning", "title": "VIBER - SMS OMNI process", "body": "1. [Create an OMNI Scenario](#1-create-omni-scenario)\n2. [Send message using an OMNI scenario](#2-send-omni-message)\n3. [Get Delivery Reports](#3-get-delivery-reports)\n4. [Receive incoming Viber message](#4-receive-incoming-viber-message)" } [/block] [block:api-header] { "type": "basic", "title": "1. Create OMNI scenario" } [/block] The first step is to create an **OMNI scenario**. In the OMNI scenario configuration, you need to define the OMNI steps which will be sequentially executed. The key parameters are **`channel`** and **`from`**, respectively identifying the communication channels and senders for each communication channel. [block:callout] { "type": "info", "title": "Prerequisites", "body": "To be able to send Viber messages using the Infobip platform you need to configure the Viber service. Please [contact us](mailto:support@infobip.com) for service activation and configuration." } [/block] For Viber sender (**"channel": "VIBER"** flow) you should use the Viber sender provided during the activation process. [block:code] { "codes": [ { "code": "POST /omni/1/scenarios HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{\n \"name\":\"My VIBER-SMS scenario\",\n \"flow\": [\n {\n \"from\": \"ViberSender\",\n \"channel\": \"VIBER\"\n },\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n } \n ],\n \"default\": true\n}", "language": "json" } ] } [/block] # Response format If successful, the response header HTTP status code will be `200 OK` and the scenario will be created, as shown in the example bellow. If you try to create the scenario without authorization, you will receive a `401 Unauthorized` error. [block:code] { "codes": [ { "code": "{\n \"key\": \"CC9F01A5DC7BEE2C2B829D203482A654\",\n \"name\":\"My VIBER-SMS scenario\",\n \"flow\": [\n {\n \"from\": \"ViberSender\",\n \"channel\": \"VIBER\"\n },\n {\n \"from\": \"InfoSMS\",\n \"channel\": \"SMS\"\n } \n ],\n \"default\": true\n}", "language": "json" } ] } [/block] The **`key`** parameter needs to be stored as it will be used when sending the message. [block:callout] { "type": "info", "title": "Info", "body": "More information about creating an OMNI scenario can be found at the following page: [Scenario: Create](doc:omni-create-scenario) ." } [/block] [block:api-header] { "type": "post", "title": "2. Send OMNI message" } [/block] Once you've created an OMNI scenario (identified by the **`key`** parameter) as described in the previous chapter, you are ready to send your OMNI messages through defined VIBER and SMS communication channels. Firstly, the VIBER message will be sent to the defined phoneNumber. If, for some reason, the message is rejected on the VIBER application or the end user doesn't have the Viber application installed, the message will be sent using the SMS communication channel. For sending OMNI messages, you can use the **advanced** API method. Detailed descriptions about the **advanced** API method can be found here: [OMNI: Send an advanced message](doc:omni-send-advanced-message). The parameters that should be set are the scenario key, phoneNumber and specific text for each communication channels, as shown below. [block:code] { "codes": [ { "code": "POST /omni/1/advanced HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{ \n\t\"scenarioKey\":\"CC9F01A5DC7BEE2C2B829D203482A654\", \n \"destinations\":[ \n \t{ \n \t\"to\":{\n \"phoneNumber\": \"41793026727\"\n }\n }\n ],\n \"viber\": {\n \t\"text\": \"This Viber message will be delivered to Viber application on the user device.\"\n },\n \"sms\": {\n \t\"text\": \"This is the SMS failover message\"\n }\n}", "language": "json" } ] } [/block] # Response format If successful, the response header HTTP status code will be `200 OK` and the message will be sent. If you try to send the message without authorization, you will receive a `401 Unauthorized` error. [block:code] { "codes": [ { "code": "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{ \n \"messages\":[ \n { \n \"to\":{\n \"phoneNumber\": \"41793026731\"\n },\n \"status\": {\n \"groupId\": 1,\n \"groupName\": \"PENDING\",\n \"id\": 7,\n \"name\": \"PENDING_ENROUTE\",\n \"description\": \"Message sent to next instance\"\n },\n \"messageId\": \"50c24400-124f-4678-9f4b-309e994a4deb\"\n }\n ]\n}", "language": "json", "name": "200 OK" } ] } [/block] [block:api-header] { "type": "get", "title": "3. Get Delivery Reports" } [/block] Once you've successfully sent your message using the **advanced** API method you can check the status of sent messages using the [OMNI reports](doc:omni-reports) method. The simplest way is to use the method without any query parameters. In that case, the response will contain all messages sent to a specific account. [block:code] { "codes": [ { "code": "GET /omni/1/reports HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nAccept: application/json", "language": "json" } ] } [/block] The response will contain all messages, rejected and delivered, as shown in the example below. [block:code] { "codes": [ { "code": "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{ \n \"results\":[ \n { \n \"messageId\":\"1215f543ab19-345f-adbd-12ad31451ed25f35\",\n \"to\":\"41793026731\",\n \"messageCount\": 1,\n \"sentAt\":\"2016-02-23T17:41:11.833+0100\",\n \"doneAt\":\"2016-02-23T17:41:11.843+0100\",\n \"mccMnc\":\"22801\",\n \"price\":{ \n \"pricePerMessage\":0.0104,\n \"currency\":\"EUR\"\n },\n \"status\":{ \n \"groupId\":2,\n \"groupName\":\"UNDELIVERABLE\",\n \"id\":9,\n \"name\":\"UNDELIVERABLE_NOT_DELIVERED\",\n \"description\":\"Message sent not delivered\"\n },\n \"error\":{ \n \"groupId\":1,\n \"groupName\":\"HANDSET_ERRORS\",\n \"id\":6,\n \"name\":\"EC_ABSENT_SUBSCRIBER_SM\",\n \"description\":\"Absent Subscriber\",\n \"permanent\":false\n },\n \"channel\": \"VIBER\"\n },\n { \n \"messageId\":\"2315d543441c-335f-1d3d-142d31451ed25f35\",\n \"to\":\"41793026731\",\n \"sentAt\":\"2016-06-23T17:40:31.773+0100\",\n \"doneAt\":\"2016-06-23T17:40:31.787+0100\",\n \"messageCount\":1,\n \"mccMnc\":\"22801\",\n \"price\":{ \n \"pricePerMessage\":0.01,\n \"currency\":\"EUR\"\n },\n \"status\":{ \n \"groupId\":3,\n \"groupName\":\"DELIVERED\",\n \"id\":5,\n \"name\":\"DELIVERED_TO_HANDSET\",\n \"description\":\"Message delivered to handset\"\n },\n \"error\":{ \n \"groupId\":0,\n \"groupName\":\"OK\",\n \"id\":0,\n \"name\":\"NO_ERROR\",\n \"description\":\"No Error\",\n \"permanent\":false\n },\n \"channel\": \"SMS\"\n }\n ]\n}", "language": "json" } ] } [/block] [block:api-header] { "title": "4. Receive incoming Viber message" } [/block] Provided that your Viber service account is two-way, you can receive messages that users send to you. In order to start receiving messages, you should set up an MO configuration and an HTTP forward action, as described in [Number configuration](doc:number-configuration). All messages will be forwarded in the following format: [block:code] { "codes": [ { "code": "{\n \"results\": [{\n \"from\": \"385919998888\",\n \"to\": \"1234\",\n \"text\": \"Message text\",\n \"receivedAt\": \"2017-10-03T12:28:18.857+0000\",\n \"messageId\": \"5095978370419896438\",\n \"pairedMessageId\": \"1234567890123456\",\n \"callbackData\": \"calbackDataOnResourceAction\",\n \"price\": {\n \"pricePerMessage\": 0.000000,\n \"currency\": \"EUR\"\n }\n }],\n \"messageCount\": 1,\n \"pendingMessageCount\": 0\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Additional Examples" } [/block] [block:api-header] { "type": "post", "title": "Send Rich Viber message" } [/block] If you would like to send Viber messages containing text, images and CTA buttons please check the example provided below. The example also shows how to configure the custom validity period for each communication channel. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-1": "string", "0-0": "text", "1-0": "imageURL", "2-0": "buttonText", "3-0": "buttonURL", "1-1": "string", "2-1": "string", "3-1": "string", "4-0": "isPromotional", "4-1": "boolean", "4-2": "Indicates if content is of promotional character.", "3-2": "Viber Button Call To Action. Should point to your landing page.", "2-2": "Viber button label. Max 20 characters.", "1-2": "URL of the image sent in the Viber message.", "0-2": "Text of the message that will be sent. Max 1000 characters.", "5-0": "validityPeriod", "5-2": "The message validity period in minutes. When the period expires, the message will be automatically sent using the next OMNI step.", "5-1": "string" }, "cols": 3, "rows": 6 } [/block] [block:callout] { "type": "info", "title": "Info", "body": "Default validity period in OMNI for Viber messages is 24h and 48h for SMS messages." } [/block] Rich Viber message request example: [block:code] { "codes": [ { "code": "POST /omni/1/advanced HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{ \n\t\"scenarioKey\":\"CC9F01A5DC7BEE2C2B829D203482A654\", \n \"destinations\":[ \n \t{ \n \t\"to\":{\n \"phoneNumber\": \"41793026727\"\n }\n }\n ],\n \"viber\": {\n \"text\": \"This is the message which will be displayed in Viber Application. It can contain up to 1000 characters. \",\n \"imageURL\": \"http://www.infobip.com/infobip-logo.png\",\n \"buttonText\": \"More information\",\n \"buttonURL\": \"http://www.infobip.com/\",\n \"isPromotional\": true,\n \"validityPeriod\":1\n },\n \"sms\": {\n \"text\": \"This text will be received via SMS if Viber message is not delivered.\",\n \"validityPeriod\":1\n }\n}", "language": "json" } ] } [/block] The message received in the Viber application is shown below: [block:image] { "images": [ { "image": [ "https://files.readme.io/0a7d82a-vibermsg.png", "vibermsg.png", 750, 1334, "#87c2de" ] } ] } [/block] If you have any additional questions please contact us at [contact us](mailto:support@infobip.com).