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--keyboardString, Structure Of KeyAndValueKeyboard. 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://hut.openintegrations.dev/test_data/document.docx";

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

DocumentDD = New BinaryData(DocumentPath);

// In chat, by URL
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document);

// In chat, by URL, with file name
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document, , , "customname.docx");

// To channel, on disk
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath);

// To channel, from binary data, with file name
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD, , , "customname.docx");
    oint telegram SendDocument \
--token "***" \
--chat "@testsichee" \
--text "Строковое значение" \
--doc "/tmp/ixnpcuqj.f4s" \
--filename "customname.docx"
Result
{
"ok": true,
"result": {
"message_id": 17192,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titovets",
"username": "bayselonarrend",
"type": "private"
},
"date": 1760516441,
"document": {
"file_name": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_id": "BQACAgIAAxkDAAJDKGjvWVkZu5c6UqjUP1CmQS34hV_TAAIkhgACN295S7wh0OXZmfhNNgQ",
"file_unique_id": "AgADJIYAAjdveUs",
"file_size": 24069
},
"caption": "Строковое значение"
}
}