Bot usage

How to work with a Telegram bot description (full and short)

To configure welcome message

tg_set_bot_description(description, language_code) - bot description shown when the chat with the bot is empty

Parameters:

Parameter
Description

description

Passing an empty string as the bot description will remove the existing description.

language_code

A two-letter language code according to the ISO 639-1 standard for text localization.

If left empty, the short description will be applied to all users who do not have a specific short description set.

Example

Example of configuring a welcome message and bot menu:

Configuring a block in MaviBot: using functions to set commands and descriptions

After the launch (this should be done once using an administrator command):

Welcome message and bot menu

Code example for copying:

tg_set_bot_description('Welcome! I am your virtual assistant, Yurgram.🤖') command = [["private_office", "Personal Account"]] tg_set_command(command, '', 'default')

To configure short preview description

tg_set_bot_short_description(description, language_code) - a short description of the bot that appears on the bot’s profile page and is sent along with the link when users share the bot.

Parameters:

Parameter
Description

description

Passing an empty string as the bot description will remove the existing description.

language_code

A two-letter language code according to the ISO 639-1 standard for text localization.

If left empty, the short description will be applied to all users who do not have a specific short description set.

To get current description

tg_get_bot_description(language_code) - use this method to get the current bot description for the specified user language.

Parameter
Description

language_code

A two-letter language code according to the ISO 639-1 standard for text localization.

If left empty, the short description will be applied to all users who do not have a specific short description set.

To get current short description

tg_get_bot_short_description(language_code) - use this method to get the current short description of the bot for the specified user language.

Parameter
Description

language_code

A two-letter language code according to the ISO 639-1 standard for text localization.

If left empty, the short description will be applied to all users who do not have a specific short description set.

How to configure commands for the bot

To configure commands

tg_set_command(commands, language, scope, platform_id, user_id)

Parameter
Description

! commands

Bot commands in the form of a list of lists, each nested list consists of 2 elements:

1 – the command name, 2 – its description (there is a limit of 100 commands).

language

A two-letter language code according to ISO 639-1, e.g., 'ru' or 'en'.

If not specified, the commands will apply to all users whose language does not have specifically assigned commands.

scope

A parameter that defines the scope of users for whom the commands are created. The default value is 'default'.

platform_id

Chat identifier within Telegram *.

Applies only for specific values of the scope parameter.

user_id

User identifier within Telegram *.

Applies only for specific values of the scope parameter.

Example

command = [["count", "return count of user"],["unpin", "unpin all message"]] tg_set_command(command, '', 'all_chat_administrators')

In this example, the commands are placed in a separate variable. You can also add these commands directly into the function.

tg_set_command('[["count", "return count of user"],["unpin", "unpin all message"]]', '', 'all_chat_administrators')

To use commands, configure a reaction to messages containing commands.

How to view commands for the bot

tg_get_command()

To view commands

tg_get_command(language, scope, platform_id, user_id)

Parameter
Description

language

A two-letter language code according to ISO 639-1, e.g., 'ru' or 'en'. If not specified, commands applied to all users within the given area who do not have dedicated commands for their language will be shown.

scope

A parameter that defines the scope of users for whom the commands should be shown (optional parameter; if not used, the default value 'default' will be applied).

platform_id

Chat identifier within Telegram *.

Applies only for specific values of the scope parameter.

user_id

User identifier within Telegram *.

Applies only for specific values of the scope parameter..

If you do not want to use the language parameter but need to use the scope parameter, be sure to specify an empty parameter first, as in the example:

tg_get_command('', scope)

Example

command = tg_get_command('', 'all_chat_administrators')

Assign this function to a variable, and the variable will contain the server’s response with commands for the user scope specified in the parameter.

{"ok":true,"result":[{"command":"count","description":"return count of user"},{"command":"unpin","description":"unpin all message"}]}

If the function is called without parameters, the scope will be set to 'default'.

command = tg_get_command()

How to delete commands in the bot

tg_delete_command()

To delete commands

tg_delete_command(language, scope, platform_id, user_id), where

Parameter
Description

language

A two-letter language code according to ISO 639-1, e.g., 'ru' or 'en' (optional parameter; if not specified, commands applied to all users within the given scope who do not have dedicated commands for their language will be deleted).

scope

A parameter that defines the scope of users for whom the commands will be deleted. If not specified, the default value 'default' will be applied.

platform_id

Chat identifier (optional parameter, applies only for specific values of the scope parameter).

user_id

User identifier (optional parameter, applies only for specific values of the scope parameter).

If you do not want to use the language parameter but need to use the scope parameter, be sure to specify an empty value for the first parameter, as in the example:

tg_delete_command('', scope)

A command like tg_delete_command() will delete commands without specifying the language parameter, using the default scope value.

Example

You can delete the set commands by calling the function with parameters in the calculator:

Code example for copying:

tg_delete_command('', 'all_chat_administrators')

How to configure reactions to commands

For commands in a private chat with the bot, you need to react to messages like: '/command_name' – where command_name is the command.

For commands in groups and chats, messages will appear as: '/command_name@bot_username' – where command_name is the command and @bot_username is the bot’s username.

Scope values list:

Parameter
Value

'default'

The default parameter implies that the commands will work in private messages with the bot.

'all_private_chats'

All private chats: commands are available to everyone in private chats where the bot has been added.

'all_group_chats'

All group and supergroup chats: commands are available to everyone in these types of chats where the bot has been added.

'all_chat_administrators'

Commands for administrators of all group and supergroup chats where the bot has been added.

'chat'

Commands for a specific chat (if you choose this option, you should specify the platform_id).

'chat_administrators'

Commands for administrators of a specific chat (if you choose this option, you should specify the platform_id).

'chat_member'

Commands for a specific member of a particular chat (if you choose this option, you should specify both platform_id and user_id; the specified user must be a member of the given chat).

If you do not want to use the language parameter but need to use the scope parameter, be sure to specify an empty value for the first parameter, as in the example:

tg_delete_command('', scope)

Last updated