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 optionTypeDescription
Token--tokenStringBot token
ChatID--chatString, NumberTarget chat ID or ChatID*TopicID
Text--textStringMessage text
Document--docBinaryData,StringDocument file
Keyboard--keyboardStringKeyboard JSON or path to .json
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


Code example
    Token     = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
Document = "https://openintegrations.dev/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");
CLI command example
    
oint telegram SendDocument --token "6129457865:AAFyzNYOAFbu..." --chat "461699897" --text "String value" --doc "https://openintegrations.dev/test_data/document.docx" --keyboard %keyboard% --parsemode %parsemode% --filename %filename%

Result
{
"ok": true,
"result": {
"message_id": 4642,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Vitaly The Bot",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titowets",
"username": "JKIee",
"type": "private"
},
"date": 1717072414,
"document": {
"file_name": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_id": "BQACAgIAAxkDAAISImZYch5MDU2ibeJ0S46yZfw6Dmb2AAKtUAACYCjISp3o6gzXeDCVNQQ",
"file_unique_id": "AgADrVAAAmAoyEo",
"file_size": 24069
},
"caption": "String value"
}
}