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.

 

Syntax

function mIntegrationTurboSMSViberSend(const sMsg, sRecipients: string; 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.

sJSONResponse

string

JSON object, full response from the service.

 

Function result

-2

integration is off, enable it in the settings;

-5

message is too long;

-6

message is empty;

-7

list of message recipients is empty;

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.


var
  iResult: integer;
  sJSONResponse: string;
begin
  iResult := mIntegrationTurboSMSViberSend('Viber test message from MyChat ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Now),
                                           '380504452169'
                                           sJSONResponse);
  
  mLogScript('Result: ' + IntToStr(iResult), '');
  mLogScript(sJSONResponse, '');
end.


Script work result

[16:22:51] (Log "TurboSMSViberSend"): Result: 800

[16:22:51] (Log "TurboSMSViberSend"): {"response_code":800,"response_status":"SUCCESS_MESSAGE_ACCEPTED","response_result":[{"phone":"380504452169","message_id":"aae54518-60a1-494e-aa0e-d0b23063bae2","response_code":0,"response_status":"OK"}]}

[16:22:51] (Run "TurboSMSViberSend"): Script operation time: 318 ms

[16:22:51] (Run "TurboSMSViberSend"): Script done successfully.

 

Message sent to Viber from MyChat via TurboSMS

 

See also

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

FormatDateTime

IntToStr

mLogScript

Now