Wooxy API v.3.0

Send Triggered Telegram message

The Send Triggered Telegram message method allows Telegram messages to be sent to contacts that have been added to our system and saved to a list. The Telegram messages are sent from the domain where the list was created, and templates previously designed and saved within our system are used.

Request

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

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

Body Example

                                        {
  "botId": "YOUR_TELEGRAM_BOT_ID",
  "contact": "user@example.com",
  "templateId": "YOUR_TELEGRAM_TEMPLATE_ID",
  "variables": [
    {
      "name": "variableName",
      "value": "variableValue"
    },
    {
      "name": "newVariableName2",
      "value": "YYYY-MM-DD"
    }
  ],
  "tags": [
    "triggerTag1",
    "triggerTag2"
  ]
}
                                    

Parameters

Title Type Default Description

botId

required
string

Unique Telegram botId that is already registered.

contact

required
string

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

templateId

required
string

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

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.
WARNING:Any tags starting with an underscore are reserved for internal use and will cause errors.

Response

                                        {
"result": true,
"telegram_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.

telegram_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 botId must be a non-empty string”

“Argument contact must be a non-empty string filled with valid email, phoneNumber or userId”

“Argument templateId must be a non-empty string”

“Telegram template {templateId} not found”

“Argument variables must be an array of arrays with \”name\” and \”value\” fields”

“name of variable must be a string”

“name of variable can not be empty”

“invalid name of variable {name}”

“Telegram template {templateId} not found”

“Bot {botId} does not have contact list”

“Argument botId must be a non-empty string”

“Argument contact must be a non-empty string filled with valid email, phoneNumber or userId”

“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”

“Telegram not allowed for your account”

“Telegram bot {bot} not found”

“Contact with {contact} not found”

“Contact {contact} is not subscribed to bot”

“Contact {contact} is not subscribed to telegram channel”

“Payment required”

“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”

“Argument {argument} required”

Code Examples

PHP
                $accessToken = "YOUR_API_KEY";
$url         = 'https://api.wooxy.com/v3/telegram/trigger';
$body        = json_encode([
    "botId"      => "YOUR_TELEGRAM_BOT_ID",
    "contact"    => "user@example.com",
    "templateId" => "YOUR_TEMPLATE_ID",
    "variables"  => [
        [
            'name'  => 'variableName1',
            'value' => 'variableValue',
        ],
        [
            'name'  => 'variableName2',
            'value' => 'YYYY-MM-DD',
        ],
    ],
    "tags"       => [
        "triggerTag1",
        "triggerTag2",
    ],
]);
/**
 * 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);