Send a message to one or several Viber numbers.As a rule, messages are queued in the service and sent to the recipient instantly or after a couple of minutes.

Check their status on TurboSMS Admin Panel. Messages are sent on behalf of a registered sender. Your name must be approved by TurboSMS. Specify this name in the integration settings.

 

Specify advanced parameters: delayed dispatch time, add a file to a message, enable clicking statistics, show a picture, message title, message transaction options.

 

Syntax

function mIntegrationTurboSMSViberSendExt(const sMsg, sRecipients: string; const dtStart: double; const iTTL: integer;

                                         const sImageURL, sCaption, sAction: string; const iFileID: integer;

                                         const bCountClicks, bIsTransactional: boolean; var sJSONResponse: string): integer;

 

Parameters and return values

Parameter

Type

Value

sMsg

string

message text, maximum 1000 characters in UNICODE;

sRecipients

string

message recipients, phone numbers in international format divided by comma, without leading "+" spaces, for example: "380504451213,380671234587.;

dtStart

double

dispatch date/time (not more than 14 days from current time), or NoDate, if the message needs to be sent right now;

iTTL

integer

message expiration time in seconds, from 60 to 86400; by default — 3600. If during this time the message is not delivered, there will be no more repeat delivery attempts;

sImageURL

string

image URL in a message; by default is an empty string;

sCaption

string

message button text; by default is an empty string;

sAction

string

URL where a user will be followed after pressing a button; by default is an empty string;

iFileID

integer

file's ID returned by the method file/add (according to TurboSMS documentation); 0 by default;

bCountClicks

boolean

"true" if you need to enable the transition statistics; "false" by default;

bIsTransactional

boolean

flag of the transactional message, "false" by default. Sending transactional messages on behalf of a common sender is forbidden;

sJSONResponse

string

JSON object, full response from the service.

 

Function result

-2

integration is off, enable it in the settings;

-3

incorrect TTL value (must be from 60 to 86400);

-4

incorrect FileID;

-5

message is too long;

-6

message is empty;

-7

list of message recipients is empty;

-8

dispatch date/time more or less than 14 days from the current time;

800, 801, 802, 803

message sent successfully, check the details in the full response from the service.

 

Example

Sending a regular Viber test message to one phone number using a default test sender in the settings ("Mobibon"). You need to register your sender name.

Added an image, button, and URL for Добавлена картинка, кнопка и URL for visiting a website after pressing the button.


var
  iResult: integer;
  sJSONResponse: string;
begin
  iResult := mIntegrationTurboSMSViberSendExt('Viber ext test message from MyChat',
                                              '380504452169'
                                              NoDate,
                                              3600,
                                              'https://nsoft-s.com/img/logo.png',
                                              'About MyChat',
                                              'https://nsoft-s.com/en/aboutmychat.html',
                                              0,
                                              false,
                                              false,
                                              sJSONResponse);
     
  mLogScript('Result: ' + IntToStr(iResult), '');
  mLogScript(sJSONResponse, '');
end.


Script work result

[16:59:50] (Log "TurboSMSViberSendExt"): Result: 800

[16:59:50] (Log "TurboSMSViberSendExt"): {"response_code":800,"response_status":"SUCCESS_MESSAGE_ACCEPTED","response_result":[{"phone":"380504452169","message_id":"55630390-60a1-0ca9-a739-d72cb9358aac","response_code":0,"response_status":"OK"}]}

[16:59:50] (Run "TurboSMSViberSendExt"): Script operation time: 1293 ms

[16:59:50] (Run "TurboSMSViberSendExt"): Script done successfully.

 

Advanced message in Viber sent from MyChat via TurboSMS

 

See also

Help page for TurboSMS service via HTTP API, commands, answers, possible errors

IntToStr

mLogScript

Created with the Personal Edition of HelpNDoc: Free EPub producer