Create a message
Learn the specifics on how to create a message with text formatting and parameters requirements.
1. Format your text
You can format your message by adding specific markdowns to any text string using the following guidelines:
Format | Markdown | String to be sent | Appearance on message |
---|---|---|---|
Bold | One asterisk at each end of the text: * | *This text will be bold* | This text will be bold |
Italics | One underscore at each end of the text: _ | _This text will be in italics_ | This text will be in italics |
Monospace | Three backticks at each end of the text: “` | “`This text will be in monospace“` | This text will be in monospace |
Strikethrough | One tilde at each end of the text: ~ | ~This text will have a strikethrough~ |
|
Transactional messages
Note that there must be a space between the last markdown symbol and the next word for the formatting to work. For example:
- *Viber*business will be shown as *Viber*business
- *Viber* business will be shown as Viber business
Formatted messages from users will be received on callback text with markdowns.
ℹ️ Only users with Viber version 14.6 and above will be able to see formatting messages; users with older versions will see the markdowns instead.
2. Add media
All business accounts can send text-based messages and rich content options, including images, action buttons, and file sharing.
Viber messages follow a standard structure and can be one of the following variations:
Text Message
Image only
Text + Action Button
Text, Image + Action Button
ℹ️It’s highly recommended by Viber that customers use only the secure HTTPS protocol when sending image links.
File transfer
You can send and receive files as long as they are on the following list of supported formats and under 200MB:
File type | File formats | File max. size |
---|---|---|
Documents | .doc, .docx, .rtf, .dot, .dotx, .odt, fodt, .txt, .info | 200MB |
.pdf, .xps, pdax, .eps | 200MB | |
Spreadsheet | .xls, .xlsx, .ods, .fods, .csv, .xlsm, .xltx | 200MB |
Files sent from a business account to the user
Files sent to users will be hosted and stored on your side. You will need to add a download link to the request as an action parameter, as well as give users access to the files:
- File type
- Filename – maximum 25 characters
{
"contentType": "file",
"file": {
"url": "string",
"filename": "string",
"type": "doc"
}
}
Files sent from the user to your business account
Each file sent from the user to you will be stored on Viber’s server for up to 7 days, after which it will no longer be available to download. The file URL can be found in the callback you receive (in the “media” field), with its name displayed in the “file_name” field.
The user also has the option to share files, photos, videos with the business.
Users will also have the option to send a photo, video, or a GIF back to the business using Viber’s internal camera.
Media type | Media formats | Media max size |
---|---|---|
Photos | .jpg, .jpeg, .png, .bmp, .gif, .svg, .webp | No limit (gif – 24MB) |
Videos | .avi, .wmv, .mov, .mp4, .m4v, 3gpp, .3gpp2, .asf, .mkv, .mp2ts, .webm | 100MB |
ℹ️ There is no option to forward other photos or videos from other chats to the selected business chat.
Emojis
Just like in any Viber chat, you can use emojis sent from the business account. Note that the overall character count of your message should be 1,000 characters or less, including emoji codes and markdowns.
ℹ️ Emojis can be added to the message using emoji codes. Please contact the Onboarding Team at support@tyntec.com for a complete list of emoji codes.
3. Send a message request
To send a simple Viber text message, you provide a recipient phone number (to), specify the channel and channel-specific data, such as your Service ID (from) and the text component of the message with content.
The rateType controls the charging by Viber and the available message types.
The most straightforward request with only required parameters looks as follows:
POST https://api.tyntec.com/conversations/v3/messages
{
"to": {{receiverPhoneNumber}}",
"channel" : "viber",
"from": "{{viberServiceId}}",
"rateType": "transaction|promotion|session",
"content": {
"type": "text",
"text": "Hello world!"
}
}
The initial response is synchronous and contains the ID of your message. This ID is valid for 48 hours to retrieve the message and 90 days for status and history. If you received status 202, then you know your message was accepted for sending.
{
"messageId": "8fb360a1-f58c-4af1-932b-8f6651603cd4"
}
ℹ️ Check our complete tutorial on how to send a message on Viber.