2024-10-15 10:50:56 +03:00
---
2024-10-15 10:16:04 +03:00
sidebar_position: 5
2025-05-05 11:15:20 +03:00
description: Send document and other functions to work with Telegram in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Telegram]
2024-10-15 10:16:04 +03:00
---
2024-10-15 10:50:56 +03:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2024-10-15 10:16:04 +03:00
# 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`
2024-10-15 15:15:47 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Token | --token | String | ✔ | Bot token |
| ChatID | --chat | String, Number | ✔ | Target chat ID or ChatID*TopicID |
| Text | --text | String | ✔ | Message text |
| Document | --doc | BinaryData, String | ✔ | Document file |
2025-01-16 21:22:31 +03:00
| Keyboard | --keyboard | String, Structure Of KeyAndValue | ✖ | Keyboard. See FormKeyboardFromButtonArray |
2024-10-15 15:15:47 +03:00
| Markup | --parsemode | String | ✖ | Text processing type (HTML, Markdown, MarkdownV2) |
| FileName | --filename | String | ✖ | Custom displayed file name with extension, if necessary |
2024-10-15 10:16:04 +03:00
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
<br/>
:::tip
2024-11-21 14:55:35 +03:00
Method at API documentation: [sendDocument](https://core.telegram.org/bots/api#senddocument)
2024-10-15 13:51:58 +03:00
Parameters with Binary data type can also accept file paths on disk and URLs
2024-10-15 10:16:04 +03:00
:::
<br/>
2024-10-15 21:15:56 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2025-10-21 11:36:43 +03:00
Token = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
Document = "https://hut.openintegrations.dev/test_data/document.docx";
2024-10-15 10:16:04 +03:00
DocumentPath = GetTempFileName("docx");
CopyFile(Document, DocumentPath);
DocumentDD = New BinaryData(DocumentPath);
2025-09-22 22:16:56 +03:00
// In chat, by URL
2024-10-15 10:16:04 +03:00
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document);
2025-09-22 22:16:56 +03:00
// In chat, by URL, with file name
2024-10-15 10:16:04 +03:00
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document, , , "customname.docx");
2025-09-22 22:16:56 +03:00
// To channel, on disk
2024-10-15 10:16:04 +03:00
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath);
2025-09-22 22:16:56 +03:00
// To channel, from binary data, with file name
2024-10-15 10:16:04 +03:00
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD, , , "customname.docx");
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram SendDocument \
2024-10-22 08:59:24 +03:00
--token "***" \
2025-07-05 18:56:59 +03:00
--chat "@testsichee" \
2024-10-22 08:59:24 +03:00
--text "Строковое значение" \
2025-10-31 15:42:42 +03:00
--doc "C:\Users\bayse\AppData\Local\Temp\av1ot2g2.lsn" \
2025-09-16 09:07:33 +03:00
--filename "customname.docx"
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram SendDocument ^
2024-10-22 08:59:24 +03:00
--token "***" ^
2025-07-05 18:56:59 +03:00
--chat "@testsichee" ^
2024-10-22 08:59:24 +03:00
--text "Строковое значение" ^
2025-10-31 15:42:42 +03:00
--doc "C:\Users\bayse\AppData\Local\Temp\av1ot2g2.lsn" ^
2025-09-16 09:07:33 +03:00
--filename "customname.docx"
2024-10-20 22:36:03 +03:00
```
</TabItem>
</Tabs>
2024-10-15 10:16:04 +03:00
```json title="Result"
{
"ok": true,
"result": {
2025-10-31 15:42:42 +03:00
"message_id": 17748,
2024-10-15 10:16:04 +03:00
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
2025-09-12 20:23:31 +03:00
"last_name": "Titovets",
"username": "bayselonarrend",
2024-10-15 10:16:04 +03:00
"type": "private"
},
2025-10-31 15:42:42 +03:00
"date": 1761909126,
2024-10-15 10:16:04 +03:00
"document": {
"file_name": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2025-10-31 15:42:42 +03:00
"file_id": "BQACAgIAAxkDAAJFVGkEmYbnCvWpC2KZUhmmK2i0lV11AAK4fwACy8ooSMffuJJeW4RmNgQ",
"file_unique_id": "AgADuH8AAsvKKEg",
2024-10-15 10:16:04 +03:00
"file_size": 24069
},
"caption": "Строковое значение"
}
}
```