Working with platform IDs in MaviBot

In MaviBot, all Telegram entities (users, groups, channels) are identified by a generic platform_id variable. This variable does not distinguish between entity types.

Problem: To use functions like accept or reject that require specific entity types, you need to know both the chat ID and the user ID separately.

Solution: When you receive a callback or message, immediately store the platform_id value in two distinct, purpose-named variables:

  • chat_id – to store the ID of the group/channel.
  • user_id – to store the ID of the individual user.

This allows you to reference the correct ID later in your application logic.

How to change the chat name via Telegram bot

Description

tg_set_group_title(platform_id, title)

Changes the title of a Telegram group.

Parameters

Parameter Description
platform_id The chat ID inside Telegram.
title New chat name.
Parameter Description
**!** platform_id the chat ID inside Telegram *
**!** title new chat name

How to change chat description via Telegram bot

Description

tg_set_chat_description(platform_id, description)

Changes the description of a Telegram chat.

Parameters

Parameter Description
platform_id The chat ID inside Telegram.
description New chat description.
Parameter Description
**!** platform_id the chat ID inside Telegram *
**!** description new chat name

How to set an avatar in a group/chat in Telegram

Description

tg_set_chat_photo(platform_id, photo)

Sets a new profile photo for a Telegram chat.

Parameters

Parameter Description
platform_id The chat ID inside Telegram where you want to set a new profile photo.
photo Direct link to the photo.
Parameter Description
**!** platform_id chat ID inside Telegram *, in which you want to set an avatar
**!** photo link photo

How to delete an avatar in a group/chat in Telegram

Description

tg_delete_chat_photo(platform_id)

Removes the current profile photo from a Telegram chat.

Parameters

Parameter Description
platform_id The chat ID inside Telegram from which you want to remove the profile photo.
Parameter Description
**!** platform_id chat ID inside Telegram *, in which you need to set an avatar

How to ban a Telegram group

Description

tg_ban_chat_sender_chat(platform_id, sender_chat_id)

Bans a sender chat from posting messages in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID where the sender chat will be banned.
sender_chat_id The ID of the sender chat to ban.

Note

Once banned, the owner of the sender chat will no longer be able to post messages on behalf of that chat in the specified Telegram chat until the ban is removed.

Parameter Description
**!** platform_id chat ID inside Telegram *, which you need to ban
**!** sender_chat_id chat ID which is going to ban

At the same time, the banned chat owner can't write on behalf of his /her other chats until he/ she is banned.

How to unblock Telegram group

Description

tg_unban_chat_sender_chat(platform_id, sender_chat_id)

Unbans a previously banned sender chat in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID where the sender chat will be unbanned.
sender_chat_id The ID of the sender chat to unban.
Parameter Description
**!** platform_id chat ID inside Telegram *, in which you unblock
**!** sender_chat_id chat ID which you unblock
Description

Creates a new invite link for a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
member_limit Maximum number of users who can join using this invite link.
hours Invite link expiration time, in hours.
request If set to True, users who click the link must submit a join request that an administrator can approve.
name Custom name for the invite link.

Important

If the member_limit parameter is specified, the request parameter is automatically set to False.

To require users to submit join requests, leave the member_limit parameter empty.

Parameter Description
**!** platform_id chat ID in Telegram *
member_limit limit on the number of participants
hours Link expiration time (in hours)
request a parameter that after clicking on the link, a request to join the chat should be generated.
name link name

When passing the member_limit parameter, the value of the request parameter is automatically changed to False. If you need to accept applications for membership, then leave the member_limit parameter empty.

Creating chat invite link

Description

Revokes an existing invite link for a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
invite_link The invite link to revoke.
Parameter Description
**!** platform_id chat ID inside Telegram *
**!** invite_link link that you need to delete
Description

Creates a new primary invite link for a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.

Warning

This method generates a new primary invite link for the chat.

All previously generated primary invite links will become inactive. The newly generated link will be the only active primary invite link until additional invite links are created.

Use this method with caution.

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** invite_link link, that you need to delete

How to accept request and add user in Telegram channel/chat

Description

tg_approve_chat_join_request(chat_id, user_id)

Approves a pending join request for a Telegram group or channel.

Parameters

Parameter Description
chat_id The Telegram group or channel ID.
user_id The Telegram user ID of the user whose join request should be approved.
**!** chat_id group/channel ID inside Telegram *
**!** user_id user ID inside Telegram *

Request acceptance:

How to decline request in Telegram channel/chat

Description

tg_decline_chat_join_request(chat_id, user_id)

Declines a pending join request for a Telegram group or channel.

Parameters

Parameter Description
chat_id The Telegram group or channel ID.
user_id The Telegram user ID of the user whose join request should be declined.
**!** chat_id group/channel ID inside Telegram *
**!** user_id user ID inside Telegram *

How to block user in Telegram

Description

tg_ban_chat_member(chat_id, user_id, hours)

Bans a user from a Telegram chat.

Parameters

Parameter Description
chat_id The Telegram chat ID.
user_id The Telegram user ID of the user to ban.
hours Ban duration, in hours. If omitted, the ban is permanent.

Note

If the hours value exceeds 366 days, the user will be banned permanently.

Parameter Description
**!** chat_id chat ID inside Telegram *
**!** user_id user ID inside Telegram * for block
hours Block duration in hours. By default, the block is permanent. If you specify a block duration of more than 366 days, the block will be set as permanent.

How to unblock user in Telegram

Description

tg_unban_chat_member(chat_id, user_id)

Unbans a user from a Telegram chat.

Parameters

Parameter Description
chat_id The Telegram chat ID.
user_id The Telegram user ID of the user to unban.
Parameter Description
**!** chat_id chat ID inside Telegram *
**!** user_id user ID inside Telegram *, who you need to unblock

How to check subscription status in Telegram

Description

tg_get_chat_member(chat_id, user_id)

Retrieves information about a user's membership status in a Telegram chat.

Parameters

Parameter Description
chat_id The Telegram chat ID.
user_id The Telegram user ID of the user whose membership status will be checked.
Parameter Description
**!** chat_id chat ID inside Telegram *
**!** user_id user ID inside Telegram *, whose subscription we are checking

How to determine the number of members in channel/chat

Description

tg_get_chat_member_count(platform_id)

Returns the total number of members in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
Parameter Description
**!** platform_id chat ID in Telegram *

How to check if a chat member is in a specific list

some_client_in_list(list_id, recepient)

Checks whether a Telegram user is included in the specified list.

Parameters

Parameter Description
list_id The ID of the list to check.
recepient The Telegram user ID. For chat members, use the chat_member_id variable.
Parameter Description
**!** list_id list number
**!** recepient user's ID inside Telegram *. For chat clients, this value is in the chat_member_id variable.

How to show bot's actions to the user (print/select a sticker and ect.)

Description

tg_send_chat_action(platform_id, bot_action, message_thread_id)

Sends a chat action (such as typing or uploading a file) to a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
bot_action The chat action to display. Choose one of the supported Telegram chat actions.
message_thread_id The topic ID. Available only for supergroups with Topics (Forums) enabled.

Note

This function is supported when working with Telegram Business accounts.

Parameter Description
**!** platform_id chat ID in Telegram *
**!** bot_action bot's action from the list
message_thread_id topic ID (available for supergroups if the forum functionality is available).
**Available actions list bot_action**

typing for text messages,
&#xNAN;upload_photo for photos,
&#xNAN;record_video or upload_video for videos ,
&#xNAN;record_voice or upload_voice for voice notes,
&#xNAN;upload_document for common documents,
&#xNAN;choose_sticker for stickers,
&#xNAN;find_location for location data,
&#xNAN;record_video_note or upload_video_note for video note.

This notification will be displayed until any response is received from the bot, but no more than 5 seconds.

How to show Alert-notification to the user

Description

tg_answer_callback_query(callback_query_id, text, show_alert, cache_time)

Sends a response to a callback query triggered when a user clicks an inline button in Telegram.

Parameters

Parameter Description
callback_query_id The callback query ID received when the user clicks an inline button. This identifies which callback to answer.
text The text to display in the notification.
show_alert Controls how the notification is displayed. Set to False to show a temporary tooltip-style notification, or True to display a persistent alert dialog.
cache_time The maximum time, in seconds, that the callback response can be cached on the client side. Defaults to 0. Telegram clients support caching starting from version 3.14.

Important

This function can only be used in response to a user clicking an inline callback button in Telegram.

Example

The following inline keyboard sends different callback values when each button is clicked:

[{"line":0,"index_in_line":0,"text":"111","type":"inline","callback":"first"}, {"line":1,"index_in_line":0,"text":"222","type":"inline","callback":"second"}, {"line":2,"index_in_line":0,"text":"333","type":"inline","callback":"third"}]

After clicking a button, a callback arrives with the text contained in the corresponding field. When you click on the “111” button, you will receive a callback with the text “first".

Let’s create a Start block and specify the desired text in the trigger. In our case: "first

If in the Matches field you select Ignoring errors and inaccuracies, this block can later be reused for all similar variants that differ by 1–2 characters. For example, to thank the user for providing a rating with such a button.

Next, in the calculator, use the tg_answer_callback_query function and pass the following parameters:
callback_query_id - this ID allows you to identify the user who pressed the button and display Alert - notification to them
text - text Alert-notification.

Code example to copy:

tg_answer_callback_query('#{callback_query_id}', "You pressed the button 111")

Pay attention! The callback_query_id parameter should be passed exactly as shown in the example, i.e. inside '#{}'

If everything is set up correctly, pressing the button will result in an Alert - notification with the specified text. In the mobile version, the bot’s name will appear as the header above the text.

If you want to show a simple popup message instead, pass False as the third parameter, as shown in the example below:
tg_answer_callback_query('#{callback_query_id}', "You passed the button 222", False)

Adding a bot redirect with a tag as a callback button responses

Description

tg_callback_url_open(callback_query_id, url, cache_time)

Opens a Telegram bot using a deep link in response to an inline button callback.

Parameters

Parameter Description
callback_query_id The callback query ID received when the user clicks an inline button. This identifies which callback to answer.
url A deep link to the bot in the format https://t.me/your_bot?start=XXXX, where your_bot is the bot's username and XXXX is the start parameter.
cache_time The maximum time, in seconds, that the callback response can be cached on the client side. Defaults to 0. Telegram clients support caching starting from version 3.14.

Important

This function can only be used in response to a user clicking an inline callback button in Telegram.

Example

ВIn the callback button response, you can add a transition to the bot using tag thetg_callback_url_open('#{callback_query_id}', 't.me/bot_name?start=XXXX')

For example, let’s use the following buttons:

[{"line":0,"index_in_line":0,"text":"111","type":"inline","callback":"first"}, {"line":1,"index_in_line":0,"text":"222","type":"inline","callback":"second"}, {"line":2,"index_in_line":0,"text":"333","type":"inline","callback":"third"}]

After clicking a button, a callback arrives with the text contained in the corresponding field. When you click on the “111” button, you will receive a callback with the text “first".

Create a block with a primary condition check and specify the desired text in the condition. In our case: “first”:

If in the Matching option field you select Ignore errors and inaccuracies, this block can later be reused for all similar variants that differ by 1–2 characters. For example, to thank the user for providing a rating with such a button.

Next, in the block’s calculator, specify tg_callback_url_open('#{callback_query_id}', 't.me/bot_name?start=XXXX'):

How to promote a user to administrator in a supergroup or channel

Description

tg_promote_user(platform_id, user_id, promote_options_list)

Promotes a Telegram user to an administrator in a supergroup or channel with the specified permissions.

Parameters

Parameter Description
platform_id The identifier of the Telegram supergroup, or the channel username in the format @channelusername when promoting a user in a channel.
user_id The Telegram user ID of the user to promote.
promote_options_list A list of administrator permissions to grant to the user.

Note

Only the permissions included in promote_options_list will be granted to the user.

**Required parameter: promote_options_list**

The following permissions can be specified in the promote_options_list :

  1. is_anonymous — пhides the administrator’s presence in the chat,
  2. can_manage_chat — the administrator can access the chat event log, chat statistics, message statistics in channels, view channel members, view anonymous administrators in supergroups, and bypass slow mode. This permission level is granted by default if any of the subsequent privileges are specified
  3. can_post_messages — — the administrator can create channel posts (channels only)
  4. can_edit_messages — the administrator can edit other users’ messages and pin messages (channels only)
  5. can_delete_messages — the administrator can delete other users’ messages
  6. can_manage_video_chats — he administrator can manage video chats,
  7. can_restrict_members — the administrator can restrict members, ban/unban them in the chat,
  8. can_promote_members — the administrator can appoint new administrators with a subset of their own privileges, or demote administrators whom they have appointed directly or indirectly (e.g., administrators appointed by them)
  9. can_change_info — the administrator can change the chat title, photo, and other settings
  10. can_invite_users — the administrator can invite new users to the chat
  11. can_pin_messages — the administrator can pin messages (supergroups only).
Example

Example: Promoting a user to administrator in a supergroup:

In this example, in addition to the specified permissions, the can_manage_chat permission will be granted by default.

Code example to copy

Example 1. 
promote_options_list = ‘[“can_promote_members”,”can_change_info”,”can_invite_users”]’ 
tg_promote_user(platform_id, user_id, promote_options_list)

Example 2. 
promote_options_list = '["can_manage_chat","can_post_messages","can_edit_messages","can_delete_messages","can_manage_video_chats","can_promote_members","can_restrict_members","can_invite_users","can_pin_messages"]' 
result=tg_promote_user(platform_id, reply_from, promote_options_list)  

How to change an administrator title using a bot in Telegram

Description

tg_set_administrator_title(platform_id, user_id, title)

Sets a custom administrator title for a Telegram supergroup administrator.

Parameters

Parameter Description
platform_id The Telegram supergroup ID.
user_id The Telegram user ID of the administrator.
title The custom administrator title.

Important

  • The title must be between 0 and 16 characters long.
  • Emojis are not allowed in the title.
  • This function works only for administrators who were promoted by the bot.

Example

result = tg_set_administrator_title(platform_id, reply_from, "firetitle")

General restrictions for regural chat members or specific Telegram users

Description

tg_chat_permission(platform_id, permission, media_permissions)

Sets the default permissions for members in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
permission An array of general chat permissions. Each element corresponds to a permission in the supported permission list. Use 1 to allow the action and 0 to forbid it.
media_permissions An array of media-related permissions. Each element corresponds to a permission in the supported media permission list. Use 1 to allow the action and 0 to forbid it.

Note

The order of values in both arrays must match the order of the corresponding permission lists. Each array element controls a specific permission:

  • 1 — Permission is granted.
  • 0 — Permission is denied.
List of restrictions for the required parameter **permission**

List of restrictions for permission:
1. ! can_send_messages - permission to send text messages, contacts, locations, and venues.
2. ! can_send_media_messages - permission to send audio, documents, photos, videos, video notes, and voice notes. It requires can_send_messages
3. ! can_send_polls - permission to send polls. It requires can_send_messages
4. ! can_send_other_messages - permission to send animations, games, stickers, and to use inline bots. It requires can_send_media_messages
5. ! can_add_web_page_previews - permission to add web-page previews to messages. It requires can_send_media_messages
6. ! can_change_info - permission to change the chat title, photo, and other settings. This is ignored in public supergroups.
7. ! can_invite_users - permission to invite users
8. ! can_pin_messages - permission to pin messages. This is ignored in public supergroups.
9. can_manage_topics - permission to create topics in forum groups. If used in a group of the wrong type, the function will fail and return an error.

List of values for the required parameter **media_permissions**

Values for granting media-related permissions media_permissions:

1. can_send_audios - permission to send audio files
2. can_send_documents -permission to send documents
3. can_send_photos - permission to send photos
4. can_send_videos - permission to send videos
5. can_send_video_notes - permission to send round video messages
6. can_send_voice_notes - permission to send voice messagesя

Telegram Personal restrictions for regular chat users or for specific Telegram users

Description

tg_restrict_chat_member(platform_id, user_id, minutes, permission, media_permissions).

Parameters:

Parameter Description
! platform_id chat ID in Telegram *
! user_id user ID in Telegram *
minutes the number of minutes during which the restriction will stay active. If you do not set a value, the default is 3600, which equals 60 hours. If you set it to 0, the restriction becomes permanent
permission an array of values from the permission restriction list.
media_permissions a list of values for granting media-related permissions
List of restrictions for the required parameter **permission**

List of restrictions for permission:
1. ! can_send_messages - permission to send text messages, contacts, locations, and venues.
2. ! can_send_media_messages - permission to send audio, documents, photos, videos, video notes, and voice notes. It requires can_send_messages
3. ! can_send_polls - permission to send polls. It requires can_send_messages
4. ! can_send_other_messages - permission to send animations, games, stickers, and to use inline bots. It requires can_send_media_messages
5. ! can_add_web_page_previews - permission to add web-page previews to messages. It requires can_send_media_messages
6. ! can_change_info - permission to change the chat title, photo, and other settings. This is ignored in public supergroups.
7. ! can_invite_users - permission to invite users
8. ! can_pin_messages - permission to pin messages. This is ignored in public supergroups.
9. can_manage_topics - permission to create topics in forum groups. If used in a group of the wrong type, the function will fail and return an error.

List of values for the required parameter **media_permissions**

Values for granting media-related permissions media_permissions:

1. can_send_audios - permission to send audio files
2. can_send_documents -permission to send documents
3. can_send_photos - permission to send photos
4. can_send_videos - permission to send videos
5. can_send_video_notes - permission to send round video messages
6. can_send_voice_notes - permission to send voice messagesя

Example

Example of using the function, where the user is restricted from everything for 3 minutes:

When the user enters the chat, they will see a notification that they cannot send messages in the chat.
If a time limit is set, they will also see the duration of this restriction.

Code example to copy:

permission = [0, 0, 0, 0, 0, 0, 0, 0] 
tg_restrict_chat_member(-1001607137668, 473737685, 3, permission)

How to pin message

Description

tg_pin_chat_message(platform_id, message_id, disable_notification)

Pins a message in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
message_id The ID of the message to pin.
disable_notification Controls whether chat members are notified about the pinned message. Set to 1 to pin the message silently, or 0 to send a notification.

Note

Notifications are always disabled in channels and private chats, regardless of the value of disable_notification.

How to unpin message

Description

tg_unpin_chat_message(platform_id, message_id)

Unpins a message in a Telegram chat.

Parameters

Parameter Description
platform_id The Telegram chat ID.
message_id The ID of the message to unpin. If omitted, the most recently pinned message is unpinned.

Note

If message_id is not specified, the function unpins the latest pinned message based on its send time.

How to unpin all pinned messages

Description

tg_unpin_all(platform_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *

ATTENTION!

Telegram has a limitation for the pin/unpin message functions.

The time limits for using **tg_pin_chat_message / tg_unpin_chat_message / tg_unpin_all **are NOT set by the MaviBot system.

If the allowed time for pinning a message has passed, the function will still return true, but Telegram will not apply the change.

It is also important to note that pinned messages can remain in cache, so they may not disappear visually right away.

How to create a poll in Telegram

Description

tg_send_poll(platform_id, question, options, is_anonymous, allows_multiple_answers, reply_markup, disable_notification, protect_content, token, reply_to_message_id, message_thread_id, business_connection_id)

Parameters:

Parameter Description
**!** platform_id chat ID in Telegram *
**!** question question
**!** options an array of answer options
is_anonymous 1 - anonymous survey , '' - not anonymous
allows_multiple_answers 1 - multiple answers are available, '' - one answer
reply_markup keyboard or '' - without keyboard
disable_notification flag for sending with sound notification (default 0)
1 – disable notification on receipt, 0 – send with notification
protect_content 1 to protect from copying and screenshots, '' no protection
token bot token; if not provided, the current one is used
reply_to_message_id ID of quoted message
message_thread_id thread ID (available for supergroups if forum functionality exists)
business_connection_id value when connecting a bot (Business ID). Shows in channels. Should be provided if the bot token is used and the message must be sent through a user account connected to the bot
Important to know!

Notes

1. The function returns a response from Telegram with message_id. It is better to save it. Using message_id, you can stop the poll with tg_stop_poll (see description below) and get the result.

2. If a user adds a poll in a messenger, a callback is sent to the chat:

poll_added - неизменная часть
YOUR QUESTION - текст вопроса из опроса

Пример колбека при добавлении опроса в канал

Пример колбека при добавлении опроса в чат

Второй колбек после poll_added содержит цифры - это не что иное, как идентификатор пользователя в Telegram, который добавил опрос.

При создании опроса ботом колбек не приходит.

3. В канале можно создавать только анонимные опросы

Внимание, рекомендуется отправлять в группу только анонимные опросы!

4. После создания опроса в переменную сохраните его идентификатор, чтобы понимать на какой опрос пришел колбек.

Example

Client feedback is key to our growth. Polls offer a straightforward method to capture this feedback and translate it into concrete business conclusions.

Code example for copying:

/* Example of creating a simple poll */
options = ["white", "red", "blue", "green"]
poll1 = tg_send_poll(platform_id, 'What is your favorite color?', options, 1, '', '', 1, '')

Function for creating a poll in Telegram:

The poll we created in Telegram

How to create a quiz in Telegram

Description

tg_send_quiz_poll(platform_id, question, options, explanation, correct_option_id, is_anonymous, reply_markup, parse_mode, protect_content, disable_notification, token, reply_to_message_id, message_thread_id )

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** question question
**!** options an array of answer options
**!** explanation text displayed when a user selects a wrong answer or clicks the lamp icon in a quiz-style poll, 0–200 characters with no more than two line breaks after entity parsing.
**!** correct_option_id номер правильного ответа, нумерация с 1
is_anonymous 1 - anonymous survey , '' - not anonymous
reply_markup keyboard or '' - without keyboard
parse_mode explanation format: markdown, html, or '' (empty string for no formatting)
protect_content 1 to protect from copying and screenshots, '' no protection
disable_notification flag for sending with sound notification (default 0)
1 – disable notification on receipt, 0 – send with notification
token bot token; if not provided, the current one is used
reply_to_message_id quoted message ID
message_thread_id topic ID (available in supergroups with active forum features)
**Important to know!**

Notes

1. Save the message_id

The API function returns a Telegram response containing a message_id. Always save this ID, as it is required to:

  • End the quiz using the tg_stop_poll function (see description below).
  • Retrieve the final results.

2. Callback poll_added

If a user adds a poll to a channel, the bot receives a callback:

  • Format: poll_added + Poll question
  • If added to a group chat: the callback also includes the Telegram User ID of the person who added the poll.

If created by the bot: No poll_added callback is sent.

3. Channel restriction

Only anonymous quizzes can be created in channels.

4. Callback poll_answer (User voting)

When a user votes in a quiz sent to a private chat or group, a callback is sent to the bot's dialog with that client:

  • Format: poll_answer + Poll ID + [Answer index]
  • Example: poll_answer 5325838371359031648 [3]
  • Note: answer numbering starts from 0. [3] means the user selected the fourth answer option.

5. Webhook for non-anonymous group polls

For non-anonymous polls in groups where the bot is an admin, a webhook is sent for every vote. Upon receiving it, the bot will forward the poll_answer callback (as in point 4) to its dialog with the corresponding client.

6. Activation requirement & best practice

  • Requirement: a bot cannot initiate a conversation. If a client has never contacted the bot, you cannot send them a direct message in response to their vote until they activate the bot first (e.g., by sending a /start command).

Recommendation: to avoid this limitation, it is highly recommended to send only anonymous quizzes to groups.

7. Track your polls

Immediately after creating a quiz, save its unique Poll ID to a variable. This allows you to identify which specific poll an incoming callback refers to.

Example

Code example for copying.

options = ["white", "red", "blue", "green"] 
r = tg_send_quiz_poll(platform_id, "What color is a crocodile?", options, "That is the explanation", 4, '', '', '', '', 1)

Example: quiz creation.

How to end a poll

Description

tg_stop_poll(platform_id, message_id)

Parameters:

Parameter Description
**!** platform_id chat ID in Telegram *
**!** message_id poll/quiz message ID. It can be obtained from the webhook

Calling this function to end a poll/quiz returns a dictionary containing the final results.

How to work with topics in Telegram

Important: the main group topic does not have an ID and requires separate functions to work with it.

How to rename group's General Topic

Description

tg_edit_general_forum_topic(platform_id, topic_name)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** topic_name new topic name
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Example

The groups' General Topic can be changed using the tg_edit_general_forum_topic() function. It requires two mandatory parameters: the chat ID and the new name for the Group Topic:

Code example for copying

rename the General Topic chat/
answer = tg_edit_general_forum_topic(-1001839380031, 'General')

How to close General Topic

Description

tg_close_general_forum_topic(platform_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

/close the General Topic chat/
answer = tg_close_general_forum_topic(-1001839380031)

How to reopen a previously closed General Topic

Description

tg_reopen_general_forum_topic(platform_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code exmaple for copying

/reopen the General Topic chat/
answer = tg_reopen_general_forum_topic(-1001839380031)

How to hide General Topic

Description

tg_hide_general_forum_topic(platform_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

The General Topic chat can be closed for the Topic's participants (they can read but not write) and hidden from Telegram's general chat list for new users.

Code example for copying

/hide the General Topic chat/
answer = tg_hide_general_forum_topic(-1001839380031)

How to display General Topic or restore its visibility

Description

tg_unhide_general_forum_topic(platform_id)

Parameters:

Parameter Description
**!** platform_id topic ID inside Telegram *
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Important!

This function does not reopen General Topic; it only makes it visible.

Code example for copying

/display the General Topic chat/
answer = tg_unhide_general_forum_topic(-1001839380031)

How to create a new topic in Telegram

Description

tg_create_forum_topic(platform_id, name, icon, icon_color)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** name new topic name
icon emoji ID to be set for the topic. Passed as a string. You can only use emojis from the list retrieved by the tg_get_forum_icon function.
icon_color emoji color from the list: 7322096, 16766590, 13338331, 9367192, 16749490, 16478047. Not all emojis support color changes.
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

The set color cannot be changed; color can only be assigned when creating the topic.

When executed, the function will return a response containing the parameters of the new topic, including the topic ID (required for various functions).

Code example for copying

To create an additional topic chat
answer = tg_create_forum_topic(-1001839380031, 'second_bot_topic', None, 7322096)

To save the created additional topic chat ID
answer={"ok":true,"result":{"message_thread_id":254,"name":"second_bot_topic","icon_color":7322096}}/
idtema1=answer['result']['message_thread_id']

How to edit a topic. How to rename and/or change the emoji for a topic

Description

tg_edit_forum_topic(platform_id, message_thread_id, name, icon)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** message_thread_id additional topic chat ID
name new topic name
icon emoji ID to be set for the topic. Passed as a string. You can only use emojis from the list retrieved by the tg_get_forum_icon function.
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

answer = tg_edit_forum_topic(-1001839380031, 254)

How to close a selected topic

Description

Closing a topic means making it read-only; writing in a closed topic is not allowed.

tg_close_forum_topic(platform_id, message_thread_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** message_thread_id additional topic chat ID
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

answer = tg_close_forum_topic(-1001839380031, 254)

How to reopen a previously closed topic

Description

tg_reopen_forum_topic(platform_id, message_thread_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** message_thread_id additional topic chat ID
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

answer = tg_reopen_forum_topic(-1001839380031, 254)

How to delete a topic and all its messages

Description

tg_delete_forum_topic(platform_id, message_thread_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** message_thread_id additional topic chat ID
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

answer = tg_delete_forum_topic(-1001839380031, 254)

How to unpin all messages in a topic

Description

tg_unpin_topic_messages(platform_id, message_thread_id)

Parameters:

Parameter Description
**!** platform_id chat ID inside Telegram *
**!** message_thread_id additional topic chat ID
bot_name

optional parameter: bot name.

When working with topics, you can specify which bot should execute the function. This is useful if your project uses multiple Telegram bots. Find the bot name in the "Channels" section, in the "Group ID" field.

Code example for copying

answer = tg_unpin_topic_messages(-1001839380031, 254)

How to get the list of emojis for a Telegram Topic

Description

How to get the list of emojis

tg_get_forum_icon() – this function returns a list of emojis available for use as forum topic icons. The result must be assigned to a variable, as it returns a dictionary where each key is an emoji and its corresponding value is the emoji's unique identifier (id).

Parameters: none.

The content of the emoji list

To get the list of emojis for a Topic chat, send the command to the relevant chat.

The function will return the emoji list in its response. This means the variable answer will contain a dictionary as its value.

{'📰': '5434144690511290129', '💡': '5312536423851630001', '⚡️': '5312016608254762256', '🎙': '5377544228505134960', '🔝': '5418085807791545980', '🗣': '5368697802761185083', '🆒': '5420216386448270341', '❗️': '5379748062124056162', '📝': '5357193964787081133', '📆': '5433614043006903194', '📁': '5357315181649076022', '🔎': '5309965701241379366', '📣': '5309984423003823246', '🔥': '5312241539987020022', '❤️': '5312138559556164615', '❓': '5377316857231450742', '📈': '5350305691942788490', '📉': '5350713563512052787', '💎': '5309958691854754293', '💰': '5350452584119279096', '💸': '5309929258443874898', '\U0001fa99': '5377690785674175481', '💱': '5310107765874632305', '⁉️': '5377438129928020693', '🎮': '5309950797704865693', '💻': '5350554349074391003', '📱': '5409357944619802453', '🚗': '5312322066328853156', '🏠': '5312486108309757006', '💘': '5310029292527164639', '🎉': '5310228579009699834', '‼️': '5377498341074542641', '🏆': '5312315739842026755', '🏁': '5408906741125490282', '🎬': '5368653135101310687', '🎵': '5310045076531978942', '🔞': '5420331611830886484', '📚': '5350481781306958339', '👑': '5357107601584693888', '⚽️': '5375159220280762629', '🏀': '5384327463629233871', '📺': '5350513667144163474', '👀': '5357121491508928442', '\U0001fae6': '5357185426392096577', '🍓': '5310157398516703416', '💄': '5310262535021142850', '👠': '5368741306484925109', '✈️': '5348436127038579546', '\U0001f9f3': '5357120306097956843', '🏖': '5310303848311562896', '⛅️': '5350424168615649565', '🦄': '5413625003218313783', '🛍': '5350699789551935589', '👜': '5377478880577724584', '🛒': '5431492767249342908', '🚂': '5350497316203668441', '🛥': '5350422527938141909', '🏔': '5418196338774907917', '🏕': '5350648297189023928', '🤖': '5309832892262654231', '\U0001faa9': '5350751634102166060', '🎟': '5377624166436445368', '🏴\u200d☠️': '5386395194029515402', '🗳': '5350387571199319521', '🎓': '5357419403325481346', '🔭': '5368585403467048206', '🔬': '5377580546748588396', '🎶': '5377317729109811382', '🎤': '5382003830487523366', '🕺': '5357298525765902091', '💃': '5357370526597653193', '\U0001fa96': '5357188789351490453', '💼': '5348227245599105972', '\U0001f9ea': '5411138633765757782', '👨\u200d👩\u200d👧\u200d👦': '5386435923204382258', '👶': '5377675010259297233', '🤰': '5386609083400856174', '💅': '5368808634392257474', '🏛': '5350548830041415279', '\U0001f9ee': '5355127101970194557', '🖨': '5386379624773066504', '👮\u200d♂️': '5377494501373780436', '\U0001fa7a': '5350307998340226571', '💊': '5310094636159607472', '💉': '5310139157790596888', '\U0001f9fc': '5377468357907849200', '\U0001faaa': '5418115271267197333', '🛃': '5370947704199323325', '🍽': '5350344462612570293', '🐟': '5384574037701696503', '🎨': '5310039132297242441', '🎭': '5350658016700013471', '🎩': '5357504778685392027', '🔮': '5350367161514732241', '🍹': '5350520238444126134', '🎂': '5310132165583840589', '☕️': '5350392020785437399', '🍣': '5350406176997646350', '🍔': '5350403544182694064', '🍕': '5350444672789519765', '\U0001f9a0': '5312424913615723286', '💬': '5417915203100613993', '🎄': '5312054580060625569', '🎃': '5309744892677727325'}

Code example for copying
answer = tg_get_forum_icon()