Write a message
Write a message to a user in the community's dialog
- Parameters
- Advanced call ?
Function WriteMessage(Val Text, Val UserID, Val Communitytoken, Val Keyboard = "", Val Parameters = "") Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Text | --text | String | ✔ | Message text |
| UserID | --user | String | ✔ | Recipient user ID |
| Communitytoken | --ct | String | ✔ | Community chat bot token, which can be obtained in the settings |
| Keyboard | --keyboard | String | ✖ | Keyboard JSON. See FormKeyboard |
| Parameters | --auth | Structure Of String | ✖ | Authorization parameters. See GetAuthParameters |
Returns
Map Of KeyAndValue - serialized JSON response from VK
| Parameter | Description |
|---|---|
| proxy | InternetProxy or a structure with fields Protocol, Host, Port, User, Password, UseOSAuthentication |
| timeout | Request execution timeout |
| adv_response | Formats the response as a complete HTTP structure with fields code, body, and headers |
| retries | Number of HTTP request send attempts on 5** status codes or internal client errors |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
1C:Enterprise/OneScript code example
Parameters = GetVKParameters();
Text = "Message from autotest";
UserID = "657846756";
Communitytoken = "vk1.a.phxjN1ZbTM9Lt-4F_i8d-LvqA9mOQH20qMstHTeytoRzDphTXA7aKpd57CJTn56Apn1ZHKPOpcrLDca43LFrKijMAtOYMwD4spRCAAuh...";
ButtonArray = New Array;
ButtonArray.Add("Button 1");
ButtonArray.Add("Button 2");
Keyboard = OPI_VK.FormKeyboard(ButtonArray);
Result = OPI_VK.WriteMessage(Text, UserID, Communitytoken, Keyboard, Parameters);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint vk WriteMessage \
--text "Message from autotest" \
--user "657846756" \
--ct "***" \
--keyboard "{'buttons':[[{'action':{'type':'text','label':'Button 1'}},{'action':{'type':'text','label':'Button 2'}}]],'one_time':false}" \
--auth "{'access_token':'***','owner_id':'-218861756','app_id':'51694790','group_id':'218861756'}"
:: JSON data can also be passed as a path to a .json file
oint vk WriteMessage ^
--text "Message from autotest" ^
--user "657846756" ^
--ct "***" ^
--keyboard "{'buttons':[[{'action':{'type':'text','label':'Button 1'}},{'action':{'type':'text','label':'Button 2'}}]],'one_time':false}" ^
--auth "{'access_token':'***','owner_id':'-218861756','app_id':'51694790','group_id':'218861756'}"
Result
{
"response": 1643
}