Skip to main content

Send document

Sends a document to a chat or channel

Function SendDocument(Val Token, Val ChatID, Val Text, Val Document, Val Keyboard = "", Val Markup = "Markdown", Val FileName = "") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringBot token
ChatID--chatString, NumberTarget chat ID or ChatID*TopicID
Text--textStringMessage text
Document--docBinaryData, StringDocument file
Keyboard--keyboardStringKeyboard. See FormKeyboardFromButtonArray
Markup--parsemodeStringText processing type (HTML, Markdown, MarkdownV2)
FileName--filenameStringCustom displayed file name with extension, if necessary

Returns: Map Of KeyAndValue - serialized JSON response from Telegram


tip

Method at API documentation: sendDocument

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Token     = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
Document = "https://api.athenaeum.digital/test_data/document.docx";

DocumentPath = GetTempFileName("docx");
CopyFile(Document, DocumentPath);

DocumentDD = New BinaryData(DocumentPath);

Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document);

Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document, , , "customname.docx");

Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath);

Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD, , , "customname.docx");
    oint telegram SendDocument \
--token "***" \
--chat "@testsichee" \
--text "Строковое значение" \
--doc "C:\Users\Administrator\AppData\Local\Temp\4g2w2bvansh.docx" \
--filename "custom.docx"
Result
{
"ok": true,
"result": {
"message_id": 8307,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titowets",
"username": "JKIee",
"type": "private"
},
"date": 1728453390,
"document": {
"file_name": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_id": "BQACAgIAAxkDAAIgc2cGGw4a6yPdiNLubNQsFLQQPLHoAAJPWgAC_cg4SJF9HYfiILIbNgQ",
"file_unique_id": "AgADT1oAAv3IOEg",
"file_size": 24069
},
"caption": "Строковое значение"
}
}