#18704: fix(telegram): normalize command names by replacing hyphens with underscores
channel: telegram
stale
size: XS
Cluster:
Signal and Discord Fixes
## Summary
Telegram bot command names must match `/^[a-z0-9_]{1,32}$/` (only lowercase letters, numbers, and underscores). The `export-session` native command (introduced in add3afb7) contains a hyphen, causing `setMyCommands` to fail with `400 Bad Request: BOT_COMMAND_INVALID`.
This PR normalizes all native command names by replacing hyphens with underscores before registering them with Telegram's Bot API, making `export-session` accessible as `/export_session`.
## Context
**This is a regression fix introduced in commit add3afb7 (2026-02-17).**
- **Affected**: Users running from `main` branch (developers using `pnpm dev`)
- **Not affected**: Stable release users (v2026.2.15 and earlier)
- **Impact**: Command registration fails completely, preventing all Telegram commands from appearing in the bot menu
Without this fix, the next stable release would ship with broken Telegram command registration.
## Changes
- **Menu registration**: Convert hyphens to underscores when building `allCommandsFull` for Telegram command menu
- **Handler registration**: Use normalized command name when registering bot command handlers
- **Prompt building**: Use normalized command name in generated prompts for consistency
## Why normalize at registration time?
Instead of renaming `export-session` to `export_session` in the command registry, normalization at registration:
- ✅ Prevents future issues if other hyphenated commands are added
- ✅ Keeps command IDs consistent across providers (other channels may allow hyphens)
- ✅ Maintains backward compatibility with existing command definitions
- ✅ Localizes the fix to Telegram-specific code
## Testing
- [x] Code builds without errors
- [x] All 457 Telegram tests pass
- [ ] Manual test: verify `/export_session` command registers and works in Telegram
## Fixes
Closes #18683
## AI-assisted
Yes - AI-assisted with human review
Most Similar PRs
#18711: fix(telegram): replace hyphens with underscores in export-session c...
by MisterGuy420 · 2026-02-17
82.3%
#19203: telegram: convert hyphens to underscores in command names
by janckerchen · 2026-02-17
81.9%
#9437: fix: normalize accountId in binding matching for consistent routing
by dbottme · 2026-02-05
67.2%
#20170: fix(irc): add configurable commandPrefix to avoid IRC reserved / pr...
by yxshee · 2026-02-18
66.5%
#23062: Fix #22985: Record session meta from native slash commands
by drewdavisfineart · 2026-02-21
66.0%
#21166: fix(agents): sanitize tool names in session transcript repair (#8595)
by dinakars777 · 2026-02-19
65.9%
#20204: fix(sessions): allow negative IDs and colon separators in session IDs
by zerone0x · 2026-02-18
65.5%
#22331: Fix Telegram reaction emoji normalization
by AIflow-Labs · 2026-02-21
65.3%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
65.1%
#17878: Refactor: share allowlist normalization
by iyoda · 2026-02-16
64.9%