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!
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.

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


