Usage samples: Viber
Please see Messaging Apps API for the full API reference.
Sending a Text Message
Text only
{
"user": {
"msisdn": "+6500000"
},
"type": "text",
"content": {
"text": "Here is your booking reference: ABC1234. For more information, visit https://8x8.com/1234!"
}
}
The corresponding message the user will receive:
![Viber text message including URL](https://files.readme.io/bc9e730-Viber_2.png)
Viber text messages can include URL
Sending a Rich Media Message
Image only
{
"user": {
"msisdn": "+6500000"
},
"type": "image",
"content": {
"url": "https://www.redbrick.sg/wp-content/uploads/2020/04/coleen-rivas-OZ2rS2zCjNo-unsplash-1125x1500.jpg"
}
}
The corresponding message the user will receive:
![Viber Rich Media: Image only message](https://files.readme.io/5d1713d-Image_only.png)
Viber Rich Media: Image only message
Video only
Refer to Supported Content Types for more info on supported file formats and size limits.
Sample Request:
{
"user": {
"msisdn": "+6500000"
},
"type": "video",
"content": {
"url": "https://samplelib.com/lib/preview/mp4/sample-5s.mp4",
"video": {
"filesize": "2700",
"duration": "5",
"thumbnail": "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg"
}
}
}
The corresponding message the user will receive:
![Viber Rich Media: Video-only message](https://files.readme.io/6f354c1-Video_only.png)
Viber Rich Media: Video-only message
File only
Refer to Supported Content Types for more info on supported file formats and size limits.
Sample Request:
{
"user": {
"msisdn": "+6500000"
},
"type": "file",
"content": {
"url": "https://www.clickdimensions.com/links/TestPDFfile.pdf"
}
}
The corresponding message the user will receive:
![File](https://files.readme.io/b2535c2-File_only.png)
Viber Rich Media: File-only message
Text + Button
{
"user": {
"msisdn": "+6500000"
},
"type": "buttons",
"content": {
"text": "Hello Jessie,\n\nYour order #420007 has been processed and is now ready for pickup at our MBS store. \n\nFor your convenience, the store is open from 9am to 9pm. We look forward to seeing you!\n\nBest,\nThe Snackbar Team",
"button": {
"caption": "Get Directions to Store",
"action": "https://maps.google.com/?q=Your+Store+Location"
}
}
}
The corresponding message the user will receive:
![Viber Rich Media: text and call-to-action button](https://files.readme.io/8863a85-Viber_Text__Button.png)
Viber Rich Media: text and call-to-action button
Text + Image
{
"user": {
"msisdn": "+650000"
},
"type": "buttons",
"content": {
"text": "Hello Mr Jobs,\n\nDon't miss our upcoming summer sale! Starting next Monday, enjoy up to 20% off on selected apple-based products.\n\nBest,\nThe Grocerio Team",
"url": "https://www.abc.net.au/reslib/201408/r1320712_18276029.jpg",
"button": {
"caption": "",
"action": ""
}
}
}
Button Object
The button attribute is required but it will not show up in the message if the caption and action fields are blank.
The corresponding message the user will receive:
![Viber Rich Media message: Text and Image](https://files.readme.io/bd07ae3-a955628-TextImage.png)
Viber Rich Media message: Text and Image
Text + Image + Button
{
"user": {
"msisdn": "+6500000"
},
"type": "buttons",
"content": {
"text": "π Successful Purchase! π\n\nHello Ana,\n\nThank you for purchasing your Singapore OCBC Skyway ticket! Your ticket is now confirmed and ready for use.\n\nπ
Date: October 15, 2023\nβ° Time: 3:00 PM - 4:00 PM\nπ« Ticket ID: SKY98723\n\nTo view your e-ticket, click the button below.",
"url": "https://www.redbrick.sg/wp-content/uploads/2020/04/coleen-rivas-OZ2rS2zCjNo-unsplash-1125x1500.jpg",
"button": {
"caption": "View E-ticket",
"action": "https://ocbcskyway.com/e-ticket/SKY1234"
}
}
}
The corresponding message the user will receive:
![Viber Rich Media message](https://files.readme.io/1974898-Viber_Rich_Media.png)
Viber Rich Media message: Text, image, and call-to-action button
Optional: Adding SMS Fallback
If you want to add a fallback to SMS, add the following fields to the "content
" object in your existing JSON payload:
{
"fallbackText": "ΔΓ’y lΓ OTP của bαΊ‘n: 23124. Δα»«ng chia sαΊ» nΓ³ vα»i bαΊ₯t cα»© ai.",
"sms": {
"encoding": "AUTO",
"source": "<senderId>"
}
}
You may find out more about SenderID here
Updated about 2 months ago