What the command menu is
According to Telegram's bot features page, Telegram apps highlight commands in messages, suggest a list of supported commands with descriptions when the user types /, and show a menu button containing all or some of the bot's commands. For the suggestions to appear, you must provide the list to @BotFather or through the Bot API. Without a published list, users can still type commands, but nobody will discover them.
A command must start with /. In the API object BotCommand, the command text is 1 to 32 characters and may contain only lowercase English letters, digits and underscores. The description is 1 to 256 characters. Telegram recommends specific names such as /newlocation over a vague /new that then needs a second answer from the user.
Setting the list with setMyCommands
The method setMyCommands takes a JSON list of commands, with at most 100 entries, plus two optional parameters: scope and language_code. It returns True on success. A minimal call looks like this:
import os, requests
TOKEN = os.environ["BOT_TOKEN"]
API = f"https://api.telegram.org/bot{TOKEN}"
commands = [
{"command": "start", "description": "Start the bot"},
{"command": "help", "description": "What I can do"},
{"command": "settings", "description": "Your preferences"},
]
r = requests.post(f"{API}/setMyCommands", json={"commands": commands}, timeout=10)
r.raise_for_status()
print(r.json())
Telegram asks every developer to support a few global commands so bots feel consistent: /start to begin the interaction, /help for a short description and the command list, and /settings when the bot has per-user settings. /start can also carry a parameter, which is covered in Telegram deep links and the start parameter.
Run this call at deploy time or on startup, not on every message. The list is stored by Telegram, so it only needs to change when your commands change. Keep the bot token out of source control; see securing bot tokens.
Scopes: different commands for different people
Scopes control who sees which list. The API documents seven scope types:
default: used when no narrower scope has a list for the user.all_private_chats: every private chat with the bot.all_group_chats: every group and supergroup.all_chat_administrators: administrators of every group and supergroup.chat: one specific chat.chat_administrators: administrators of one specific group.chat_member: one specific member of one specific group.
You pass the scope as a JSON object with a type field. For the chat-specific scopes you also pass the chat_id, and for chat_member the user_id.
admin_commands = commands + [
{"command": "ban", "description": "Ban a user from this group"},
{"command": "rules", "description": "Edit the group rules"},
]
requests.post(f"{API}/setMyCommands", json={
"commands": admin_commands,
"scope": {"type": "all_chat_administrators"},
}, timeout=10).raise_for_status()
A typical layout is a short default list, a smaller list for groups, and a longer list for administrators.
How Telegram picks the list
The API documentation describes an algorithm: Telegram returns the first list that is set, checking from the most specific scope to the least specific one, and for each scope it checks the version with a matching language_code first and then the version without one.
In a private chat with the bot the order is: chat, then all_private_chats, then default. In groups and supergroups it is: chat_member, chat_administrators (administrators only), chat, all_chat_administrators (administrators only), all_group_chats, then default.
This has a practical consequence. If you set a list for all_group_chats, it fully replaces the default list in groups. It does not merge, so repeat the commands you still want. deleteMyCommands removes the list for a given scope and language, and after that the higher-level list is shown to the affected users. getMyCommands lets you read what is currently stored, which is the fastest way to debug a menu that looks wrong.
Translating the menu
The language_code parameter is a two-letter ISO 639-1 code. When you leave it empty, that list applies to all users in the scope whose language has no dedicated list. Telegram recommends that interfaces adapt to the user's language without user intervention, and notes that command lists can be specified per language.
es = [
{"command": "start", "description": "Iniciar el bot"},
{"command": "help", "description": "Que puedo hacer"},
{"command": "settings", "description": "Tus preferencias"},
]
requests.post(f"{API}/setMyCommands", json={
"commands": es, "language_code": "es",
}, timeout=10).raise_for_status()
Keep the command names themselves identical across languages and translate only the descriptions. Your handlers then stay simple. In your reply text, remember that the language_code field on a user is optional and can be missing, so fall back to the last recorded language or to English.
The menu is not access control
Telegram states this clearly: Bot API updates do not contain information about the scope of a command sent by a user, and they may contain commands that do not exist in your bot at all. Anyone can type /ban by hand. Your backend must always check that the command is valid and that the user is authorized, regardless of scope.
A safe handler does three things: parse the command name (and strip the @botname suffix used in groups), look it up in a known table, and check the sender's role before acting. Check admin status with a server-side call such as getChatMember rather than trusting anything in the message text.
Also remember privacy mode. Bots in groups with privacy mode enabled only see commands under special conditions, such as commands addressed explicitly as /command@this_bot. If commands seem to vanish in a group, read Telegram group privacy mode before changing your code.
Where the pieces run
The command menu is only metadata. The handlers behind it need a server that is online and a stable HTTPS address if you use webhooks. A short domain from Namecheap domains gives you a durable name such as bot.example.com, and Namecheap hosting can serve a small static page that explains your commands to users and to reviewers. The bot process itself usually belongs on a VPS or container host; compare options in bot hosting compared. If you are still choosing a registrar, Namecheap covers both domains and basic hosting.
Checklist
- Publish at least
/startand/help, and/settingsif you have user settings. - Use lowercase names of 1 to 32 characters and clear descriptions under 256 characters.
- Set a default list first, then add scopes only where the audience really differs.
- Remember that a narrower scope replaces, not extends, the wider list.
- Add a
language_codelist for each language you support and keep a language-less fallback. - Verify with
getMyCommandsafter each change. - Authorize every command on the server; the menu is a convenience, not a lock.
Sources
- Telegram Bot API, setMyCommands, getMyCommands, deleteMyCommands and BotCommandScope: core.telegram.org/bots/api#setmycommands
- Telegram Bot API, BotCommand and determining the list of commands: core.telegram.org/bots/api#determining-list-of-commands
- Telegram, Bot features: commands, command scopes, global commands and language support: core.telegram.org/bots/features#commands