Using Aliases in Your Bot¶
Having one command trigger name is clean, but users don't always do what you expect. If your keyboard button says Help, your users might type /help, /h, or help in lowercase.
Instead of copying and pasting the exact same answer and logic into four different commands, you can use Aliases to map all of these triggers to a single command.
What is an Alias?¶
An alias is just an alternative trigger word for an existing command.
No matter which one the user types, the exact same command runs.
Step 1: Open Your Command¶
Let's add aliases to the Help command we built in the last step:
- Open your bot dashboard and click Commands.
- Find your
Helpcommand and click Edit (pencil icon).
Step 2: Add Aliases¶
- Locate the Aliases field in the form.
- Type the aliases you want to support, separated by commas:
- Click Save Command.
Why are Aliases Awesome?¶
- Keyboard matching: If your menu button text says
ℹ️ About Us, you can name your commandabout_usinternally, and simply addℹ️ About Usas an alias. - Catching Typos & Shorthands: You can map shorthand forms (like
/hfor help, or/qfor quit) to make life easier for power users. - Case Sensitivity: TBL commands are case-sensitive. If your command name is
Help, typinghelpin lowercase won't work unless you add it as an alias.
Test It!¶
- Open Telegram and search for your bot.
- Send the shorthand command
/h. - Send the lowercase word
help. - Send the capital word
HELP.
If the bot responds with the same help message for all of them, your aliases are working perfectly!
What's Next?¶
So far, our commands are "one-way"—the bot sends an answer and immediately stops. What if you need to ask the user a question (like "What is your name?") and wait for their answer before running code?
In the next step, we will use Need Reply to handle user input step-by-step.