Wooxy API v.3.0

Send Triggered Viber message

The Send Triggered Viber message method allows sending Viber messages to contacts added to our system and saved to a list. The Viber messages are sent from the domain where the list was created, and templates previously created and saved within our system are used.

Request

POST
https://api.wooxy.com/v3/viber/trigger

IMPORTANT: Do not send more than 10 concurrent API requests.

Body Example

                                        {
  "contactListId": "YOUR_CONTACT_LIST_ID",
  "contact": "user@example.com",
  "senderId": "Viber_SenderName",
  "templateId": "YOUR_TEMPLATE_ID",
  "device": "all",
  "ttl": 3600,
  "tags": [ 
    "registeredTag", 
    "registeredTag 2" 
  ],
  "variables": [
    {
      "name": "variableName",
      "value": "variableValue"
    },
    {
      "name": "newVariableName2",
      "value": "YYYY-MM-DD"
    }
  ]
}
                                    

Parameters

Title Type Default Description

contactListId

required
string

ID of the contact list which the contact belongs to.   
The list should be already created in your account on Lists page:   
https://app.wooxy.com/email-list

contact

required
string

The 'email' address, 'userId' or 'phoneNumber' of the recipient stored in the corresponding contactList.

senderId

optional
string Wooxysender’s default name

Your own registered name in Viber.
IMPORTANT: If you are using Wooxysender’s default name, leave this field blank.

templateId

optional
string

The Viber template you want to send. The template should be already created in your account on the Templates page:    
https://app.wooxy.com/templates

device

optional
string all

Add kind of devices to the parameter:

  • all: We send to all devices: desktop and mobile;
  • phone: The message will only be shown on the mobile app.

ttl

optional
integer 3600

Time to live must be specified in seconds. Between 30 minutes to  72 hour.

variables

optional
array null

You can add an associative array of custom variables that will be placed in your template which we host.
Please take into account variables usage priorities is case of conflicting variables:

  • First Priority: Variable from API request;
  • Second Priority: Variable from the Content Custom Variables;
  • Third Priority: Variable from the selected list.

variables.name

required
string

Variable name in lowerCamelCase format
WARNING: Please use only Latin lowerCamelCase format. No numbers or other symbols are allowed.

variables.value

required
string

Variable value in 'ENUM_STRING' or 'ENUM_DATE' format correspondingly

tags

optional
array null

An array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or changed frequently. Tags should be 50 characters or less.
Important: Use only registered tags.
Any tags starting with an underscore are reserved for internal use and will cause errors.

Response

                                        {
"result": true,
"Viber_message_ids": ["5e1c888bd132d5e7d00f17f8"]
}
                                    

Parameters

Title Type Description

result

boolean

The value indicates that the triggered message was successfully sent out:

  • true: The message was successfully sent out.

viber_message_ids

string

The message unique identification number in the Wooxy system. This ID number allows you to get all the statistics on each message sent.

Method Errors

                                        {
   "result": false,
   "errors": [
      "Error description text"
   ]
}
                                    
Error

“Argument ‘domain’ must be a non-empty string”

“Argument senderId must be a non-empty string”

“{phoneNumber} is not a valid E.164 phone number”

“Argument text must be a non-empty string”

“Argument button must be an array with “text” and “url” string elements”

“Argument ttl must be a positive integer”

“Argument device must be all or phone”

“Argument tags must be an array”

“Tag name must be a non-empty string”

“Tags should be 50 characters or less”

“Any tags starting with an underscore are reserved for internal use and will cause errors”

“Domain {domain} not found in your account”

“Current method is not allowed for country {code}”

“There is no default list in domain {id}”

”Sender with senderId {id} not registered in account”

“Sender with senderId {id} not approved”

“Country of contact is not allowed for senderId {id}”

“There is no registered senderId {id} in account”

”Tag {tag} is not registered in account tags”

“Invalid authorization token!”

“Internal server error”

“Bad Request”

“No matches found for access token {accessToken}”

“User {id} not enabled”

“No data found for key {userId}“

“Access token check failed for key/secret $key/$accessToken“

Code Examples

PHP
                $accessToken = "YOUR_API_KEY";
$url         = 'https://api.wooxy.com/v3/viber/trigger';
$body        = json_encode([
    "contactListId" => "YOUR_CONTACT_LIST_ID",
    "contact"       => "user@example.com",
    "senderId"      => "Viber_SenderName",
    "templateId"    => "YOUR_TEMPLATE_ID",
    "device"        => "all",
    "ttl"           => 3600,
    "tags"          => [
            "registeredTag1", 
            "registeredTag2", 
    ],
    "variables"     => [
        [
            'name'  => 'variableName1',
            'value' => 'variableValue',
        ],
        [
            'name'  => 'variableName2',
            'value' => 'YYYY-MM-DD',
        ],
    ],
]);
/**
 * Request Example
 */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_INFILESIZE, null);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Access-Token: $accessToken",
    'Content-Type: application/json',
    'Content-Length: ' . strlen($body),
]);

$result = curl_exec($ch);
if ($result === false) {
    echo 'cURL error:' . curl_error($ch) . PHP_EOL;
} else {
    echo strval($result) . PHP_EOL;
}
curl_close($ch);