Skip to main content

Send text message

Sends a text message to a chat or channel

Function SendTextMessage(Val Token, Val Text, Val UserID, Val SendingToChannel, Val Keyboard = "") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringToken
Text--textStringMessage text
UserID--userString, NumberUser ID. For channel > administrator, for bot > recipient
SendingToChannel--ischannelBooleanSending to channel or bot chat
Keyboard--keyboardStructure Of StringSee CreateKeyboardFromArrayButton

Returns: Map Of KeyAndValue - serialized JSON response from Viber


1C:Enterprise/OneScript code example
    Text = "TestMessage";

UserID = "d3jxe61Z4W73nmNkjYGgZg==";
Token = "523b5b25ed27e6ec-fdf013e4...";
SendingToChannel = False;

ButtonArray = New Array;
ButtonArray.Add("Button 1");
ButtonArray.Add("Button 2");
ButtonArray.Add("Button 3");

Keyboard = OPI_Viber.CreateKeyboardFromArrayButton(ButtonArray);

Result = OPI_Viber.SendTextMessage(Token, Text, UserID, SendingToChannel, Keyboard);

UserID = "tMNGhftyUPrB3r1lD+bT4g==";
Token = "523b58ba82afffaa-7ef3b426...";
SendingToChannel = True;

Result = OPI_Viber.SendTextMessage(Token, Text, UserID, SendingToChannel, Keyboard);
    # JSON data can also be passed as a path to a .json file

oint viber SendTextMessage \
--token "***" \
--text "TestMessage" \
--user "tMNGhftyUPrB3r1lD+bT4g==" \
--ischannel true \
--keyboard "{'Buttons':[{'ActionType':'reply','ActionBody':'Button 1','Text':'Button 1','BgColor':'#2db9b9','Coloumns':3},{'ActionType':'reply','ActionBody':'Button 2','Text':'Button 2','BgColor':'#2db9b9','Coloumns':3},{'ActionType':'reply','ActionBody':'Button 3','Text':'Button 3','BgColor':'#2db9b9','Coloumns':3}],'Type':'keyboard'}"
Result
{
"status": 0,
"status_message": "ok",
"message_token": 6024682517702263447,
"chat_hostname": "SN-CHAT-01_",
"billing_status": 3
}