API Telegram functions
API functions significantly expand the capabilities of a bot in Telegram. By using API functions, you can work with attachments, groups, and chats in Telegram — for example, automating the blocking or unblocking of users, and much more!
Source: Telegram bot API
Important!
To understand how to work with API functions, we strongly recommend reviewing the rules for specifying functions and parameters in the calculator.
NOTATION:
! — an exclamation mark indicates required parameters
parameter=None — this shows the default value for the specified parameter.
It's incorrect to simply copy the function text from the documentation, like this: tg_send_message(platform_id, "Some text", client_message_id=61818138, reply_markup=None, parse_mode=None, disable_web_page_preview=0, protect_content=False)
The values after the equals signs represent default values for each parameter. Therefore, if you don’t need a particular parameter but do need one that follows it, you can’t just skip the unused one — instead, you must explicitly pass its default value.
Thus, the correct usage would be: tg_send_message(platform_id, "Some text", 61818138, None, None, 0, True)
Where can I get the platform_id for sending notifications?
You need to have a Telegram bot connected to your project.
Send any message to this bot from the Telegram account where you want to receive notifications.
In the list of project clients, select the client dialog you want to send requests to.
Copy the ID value from the messenger field.

Example of passing the platform_id parameter:
The platform_id parameter can be passed without explicitly specifying numeric values.

react = tg_set_reaction(platform_id, 1556, '👌')
Functions with this parameter will work even without explicitly specifying a platform_id value. Important: In most functions, this parameter is required and must not be omitted.
2. If you need to use the function in a specific chat, channel, or group, you must provide the platform_id as a numeric value.

In the function tg_send_message(!platform_id, !text) shown above, the platform_id parameter is passed using quotation marks enclosing a numeric value:
tgmess = tg_send_message('1234566788', 'Hello!')

How to define buttons in the reply_markup parameter
Example of reply buttons:
opts = {"keyboard": [[{"text": "Left"}, {"text": "Right"}]]}
Example of inline buttons:
opts = {"inline_keyboard": [[{"text": "Package 1","callback_data":1}, {"text": "Package 2","callback_data":2}]]}
How to use text formatting (Markdown) in the parse_mode parameter?
The parse_mode parameter formats the entire text or parts of it in italic or bold. It can have the values: html, markdown, or markdownV2.
If you choose html:
for bold text, use "<b>caption</b>"
for italic text, use "<i>caption</i>"
For Markdown:
for bold text, use "*caption*"
for italic text, use "_caption_"
Example of sending italic text:
tg_send_message(47615196, "<i>italic</i>",None,None,"html")
Example of sending bold text:
tg_send_message(platform_id, '*test*', None, None, 'markdown')
Last updated