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!

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:
  1. The platform_id parameter can be passed without explicitly specifying numeric values.

platform_id was provided without any value

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.

  1. If you choose html:

for bold text, use "<b>caption</b>"

for italic text, use "<i>caption</i>"

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