Skip to main content

Send image

Sends an image to a chat or channel

Function SendImage(Val Token, Val ChatID, Val Text, Val Image, Val Keyboard = "", Val Markup = "Markdown") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringBot token
ChatID--chatString, NumberTarget chat ID or ChatID*TopicID
Text--textStringMessage text
Image--pictureBinaryData, StringImage file
Keyboard--keyboardString, Structure Of KeyAndValueKeyboard. See FormKeyboardFromButtonArray
Markup--parsemodeStringText processing type (HTML, Markdown, MarkdownV2)

Returns: Map Of KeyAndValue - serialized JSON response from Telegram


tip

Method at API documentation: sendPhoto

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 = "Строковое значение";
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";

ImagePath = GetTempFileName("png");
CopyFile(Image, ImagePath);

ImageDD = New BinaryData(ImagePath);

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

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

// To channel, from binary data
Result = OPI_Telegram.SendImage(Token, ChannelID, Text, ImageDD);
    # JSON data can also be passed as a path to a .json file

oint telegram SendImage \
--token "***" \
--chat "@testsichee" \
--text "Строковое значение" \
--picture "https://hut.openintegrations.dev/test_data/picture.jpg" \
--keyboard "{'inline_keyboard':[[{'text':'Button1','callback_data':'Button1'}],[{'text':'Button2','callback_data':'Button2'}],[{'text':'Button3','callback_data':'Button3'}]],'rows':'1'}"
Result
{
"ok": true,
"result": {
"message_id": 17188,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titovets",
"username": "bayselonarrend",
"type": "private"
},
"date": 1760516219,
"photo": [
{
"file_id": "AgACAgIAAxkDAAJBAAFo3CVN6Pf6v6X3uuGDQ4vNCBViJgACzwEyG_J74Uoy83-foYP4SgEAAwIAA3MAAzYE",
"file_unique_id": "AQADzwEyG_J74Up4",
"file_size": 1568,
"width": 90,
"height": 67
},
{
"file_id": "AgACAgIAAxkDAAJBAAFo3CVN6Pf6v6X3uuGDQ4vNCBViJgACzwEyG_J74Uoy83-foYP4SgEAAwIAA20AAzYE",
"file_unique_id": "AQADzwEyG_J74Upy",
"file_size": 21633,
"width": 320,
"height": 240
},
{
"file_id": "AgACAgIAAxkDAAJBAAFo3CVN6Pf6v6X3uuGDQ4vNCBViJgACzwEyG_J74Uoy83-foYP4SgEAAwIAA3gAAzYE",
"file_unique_id": "AQADzwEyG_J74Up9",
"file_size": 99260,
"width": 800,
"height": 600
},
{
"file_id": "AgACAgIAAxkDAAJBAAFo3CVN6Pf6v6X3uuGDQ4vNCBViJgACzwEyG_J74Uoy83-foYP4SgEAAwIAA3kAAzYE",
"file_unique_id": "AQADzwEyG_J74Up-",
"file_size": 218651,
"width": 1280,
"height": 960
},
{
"file_id": "AgACAgIAAxkDAAJBAAFo3CVN6Pf6v6X3uuGDQ4vNCBViJgACzwEyG_J74Uoy83-foYP4SgEAAwIAA3cAAzYE",
"file_unique_id": "AQADzwEyG_J74Up8",
"file_size": 650214,
"width": 2560,
"height": 1920
}
],
"caption": "Строковое значение"
}
}