Summary
Improve the Telegram bot experience in three places:
- Show a typing indicator while the bot is generating a reply.
- Emit clearer startup logs when the FastAPI server boots and Telegram polling begins.
- Add a
/reset slash command that starts a fresh Telegram session.
Background
The current Telegram integration already starts polling during server startup and exposes /start, /help, and /clear. However:
- Long-running replies look idle because the bot does not send a typing indicator.
- Startup logging does not clearly show the full Telegram boot lifecycle in one place.
/clear does not actually create a fresh session. It only tells the user that memory context will be fresh, while persisted memories may still influence future replies.
There is also an implementation detail worth making explicit before coding this: the Telegram transport currently builds prompts manually and calls the model directly instead of routing through the ADK root_agent. Memory is searched and saved by Telegram chat_id, so a true session reset needs explicit session semantics rather than just a new command handler.
Problem
Users currently have no feedback that the bot is working while a reply is being generated, and operators do not get a crisp startup trail showing whether Telegram polling actually came up successfully. On top of that, there is no reliable way for a Telegram user to say "start over" and get behavior that matches that expectation.
Scope
1. Add typing indicator
- Send Telegram's
typing chat action when a message starts processing.
- Keep the typing indicator alive until the bot sends a final reply or an error reply.
- Make sure the typing loop is cleaned up on both success and failure so background tasks do not leak.
- Keep the implementation scoped to Telegram message handling only.
2. Improve startup logs for Telegram polling
- Log whether Telegram integration is enabled and configured during server startup.
- Log the major lifecycle milestones clearly:
- Telegram configuration detected or skipped
- Telegram application created
- Polling start requested
- Polling started successfully
- Polling startup failed, with exception context
- Make the logs easy to scan in normal local startup output from
uv run python -m blacki.server.
- Avoid duplicate or ambiguous log lines between
src/blacki/server.py and src/blacki/telegram/bot.py.
3. Add /reset slash command
- Add a new
/reset command that starts a fresh session for the current Telegram chat.
- Define reset semantics explicitly in code and user-facing copy.
- Do not claim persisted memories were deleted unless they actually were.
- Decide whether
/clear should remain as an alias for /reset or be deprecated with a compatibility message.
- Update
/start and /help text so the command list stays accurate.
- Register the command with Telegram's bot command menu if that fits the current bot initialization flow.
Recommended implementation notes
- Introduce lightweight per-chat session state instead of relying only on
chat_id.
- Rotate the current
session_id for a chat when /reset is called.
- Scope any transient conversation state to that
session_id.
- If mem0 remains long-lived and cannot be hard-cleared, make that explicit in both code comments and user-facing copy.
- Keep the solution readable and explicit. This is a user-facing control path, so hidden behavior or vague wording will be confusing later.
Acceptance Criteria
- Sending a normal Telegram message shows a typing indicator while the reply is being generated.
- The typing indicator stops when the final response or error message is sent.
- Starting the server produces clear logs showing whether Telegram polling was skipped, started, or failed.
- A Telegram user can run
/reset and reliably start a fresh session for that chat.
- The command help text and command menu reflect the final supported command set.
/clear behavior is explicitly defined and tested.
Testing
- Add focused unit tests for command registration and help text updates.
- Add tests for the typing-indicator lifecycle on both success and failure paths.
- Add tests for startup logging around the Telegram polling lifecycle.
- Add tests that prove
/reset changes the active Telegram session behavior for a chat.
Priority
P1
Level of Effort
Medium
Sources
Summary
Improve the Telegram bot experience in three places:
/resetslash command that starts a fresh Telegram session.Background
The current Telegram integration already starts polling during server startup and exposes
/start,/help, and/clear. However:/cleardoes not actually create a fresh session. It only tells the user that memory context will be fresh, while persisted memories may still influence future replies.There is also an implementation detail worth making explicit before coding this: the Telegram transport currently builds prompts manually and calls the model directly instead of routing through the ADK
root_agent. Memory is searched and saved by Telegramchat_id, so a true session reset needs explicit session semantics rather than just a new command handler.Problem
Users currently have no feedback that the bot is working while a reply is being generated, and operators do not get a crisp startup trail showing whether Telegram polling actually came up successfully. On top of that, there is no reliable way for a Telegram user to say "start over" and get behavior that matches that expectation.
Scope
1. Add typing indicator
typingchat action when a message starts processing.2. Improve startup logs for Telegram polling
uv run python -m blacki.server.src/blacki/server.pyandsrc/blacki/telegram/bot.py.3. Add
/resetslash command/resetcommand that starts a fresh session for the current Telegram chat./clearshould remain as an alias for/resetor be deprecated with a compatibility message./startand/helptext so the command list stays accurate.Recommended implementation notes
chat_id.session_idfor a chat when/resetis called.session_id.Acceptance Criteria
/resetand reliably start a fresh session for that chat./clearbehavior is explicitly defined and tested.Testing
/resetchanges the active Telegram session behavior for a chat.Priority
P1
Level of Effort
Medium
Sources
sendChatAction: https://core.telegram.org/bots/api#sendchatactionsetMyCommands: https://core.telegram.org/bots/api#setmycommandsCommandHandlerdocs: https://docs.python-telegram-bot.org/en/stable/telegram.ext.commandhandler.htmlsrc/blacki/server.pysrc/blacki/telegram/bot.pysrc/blacki/telegram/__init__.py