Skip to content

feat(telegram): handle /start natively instead of forwarding to agent#798

Open
lezama wants to merge 1 commit intochenhg5:mainfrom
lezama:fix/telegram-start-handler
Open

feat(telegram): handle /start natively instead of forwarding to agent#798
lezama wants to merge 1 commit intochenhg5:mainfrom
lezama:fix/telegram-start-handler

Conversation

@lezama
Copy link
Copy Markdown

@lezama lezama commented Apr 27, 2026

Closes #797.

What

Add a native handler for the /start slash command. Previously cc-connect fell through to the agent for any unrecognized slash command, including Telegram's /start protocol convention — and Claude Code's CLI then rejected the literal /start text with an autocomplete prompt.

Changes

  • core/i18n.go — new MsgWelcome key + EN/zh/zh-TW/ja/es translations.
  • core/engine.go — new cmdStart method (mirrors cmdHelp shape) and a case "start" branch in handleSlashCommand's switch.

Total diff: +26 lines, 2 files.

Behavior before

User: /start
cc-connect: /start is not a cc-connect command, forwarding to agent…
Claude Code: Unknown command: /start. Did you mean /stats?

Behavior after

User: /start
cc-connect: 👋 Hi! I'm cc-connect, bridging you to **<project>**.

Just send a message to chat with the agent. Type /help to see built-in commands.

The welcome names the project (e.name) so the user knows which agent they're connected to. Tone matches the existing English copy elsewhere in core/i18n.go.

Why /start specifically

/start is a Telegram protocol convention — Telegram clients send it automatically when a user first opens a bot, taps the Start button, or /start@bot in a group. Every Telegram bot framework I'm aware of (telegraf, python-telegram-bot, aiogram, etc.) reserves /start for a native welcome handler. cc-connect already auto-registers a Telegram bot menu on startup, so this completes the convention.

/help is in a similar spot — but cc-connect already had a native /help, so it's unaffected. /start was the gap.

On platforms where /start has no protocol meaning (Slack, Discord, Feishu, etc.) this is a no-op improvement: instead of "Unknown command. Forwarding to agent." → "Unknown command: /start. Did you mean /stats?", the user gets a proper welcome.

Tests

go test ./core/... -count=1 — three pre-existing failures (TestProcessInteractiveEvents_AppendsReplyFooterWhenEnabled, TestProcessInteractiveEvents_ReplyFooterPrefersSessionRuntimeState, TestResolveLocalDirPath_AcceptsSubdir) reproduce on main without my changes; everything else passes. Build is clean.

Repro / verification

  1. Configure [[projects]] with [projects.agent].type = "claudecode" and a [[projects.platforms]] of type telegram.
  2. Open the bot in Telegram and tap Start (or send /start).
  3. Before this change → "Unknown command: /start. Did you mean /stats?"
  4. After this change → welcome message naming the project.

Discovered while testing https://github.com/Automattic/intelligence end-to-end (cc-connect bridges its Claude Code runtime to Telegram).

`/start` is a Telegram protocol convention — clients send it automatically
when a user first opens a bot or taps the Start button. Without a native
handler the message fell through to the default branch in
`handleSlashCommand` and got forwarded verbatim to the agent.

For Claude Code agents specifically this breaks first contact: the CLI
interprets a leading `/` as a slash-command request and replies
"Unknown command: /start. Did you mean /stats?" instead of greeting
the user. End user sees the bot welcome them with autocomplete suggestions
on every fresh chat.

Add a `cmdStart` handler (alongside cmdHelp / cmdVersion / etc.) and a
`MsgWelcome` i18n entry covering the same five locales as the rest of the
file. The handler names the project (`e.name`) and points users to /help —
behavior consistent with telegraf, python-telegram-bot, aiogram, etc.
No-op improvement on platforms where /start has no protocol meaning.

Closes chenhg5#797
Copy link
Copy Markdown
Owner

@chenhg5 chenhg5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Clean, minimal fix for Telegram's /start protocol convention. Closes #797.


Good:

  1. Root cause: /start was falling through to the agent, and Claude Code's CLI rejected it as "Unknown command: /start. Did you mean /stats?"

  2. Fix: New cmdStart method mirrors cmdHelp shape. Returns a localized welcome message with the project name.

  3. i18n: MsgWelcome with all 5 languages (EN, zh-CN, zh-TW, ja, es).

  4. Minimal diff: +26 lines, 2 files. No unnecessary changes.

  5. Comment: Clear docstring explaining the Telegram /start protocol and why this is needed.


LGTM. CI green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: /start is forwarded verbatim to claudecode agent and trips Claude Code's slash-command parser

2 participants