Problem
When deliver.sh (or cron output) sends a message to a topic/chat via Bot API, the bot doesn't process it as an incoming message. The message appears in the chat for the user, but the agent session never sees it.
This happens because deliver.sh calls sendMessage on the Bot API directly — Telegram doesn't relay the bot's own outgoing messages back as updates, so grammY never receives them.
Result: In chats/topics with requireMention: false, external deliveries (cron results, cross-agent messages) are invisible to the agent session. Only the human sees them.
Desired Behavior
When requireMention: false is set for a binding, the agent session should receive ALL messages that appear in the chat/topic — including those sent by the bot itself via deliver.sh or cron output.
Research Needed
- Telegram Bot API doesn't deliver the bot's own messages as updates — this is by design
- Possible approaches:
- Inject path: After
deliver.sh sends a message, write it to the session's inject directory so the PreToolUse hook picks it up (similar to how mid-turn user messages work)
- Bot-level relay: Bot intercepts its own outgoing messages and feeds them back into the message queue for the relevant session
- grammY middleware: Use
bot.api.config transformer to capture outgoing messages and route them to session context
- Need to evaluate: dedup (avoid echo loops), format consistency, which approach is simplest
Scope
Only applies when requireMention: false — in mention-required chats, the bot already controls when it speaks, so echoing its own messages is unnecessary.
Problem
When
deliver.sh(or cron output) sends a message to a topic/chat via Bot API, the bot doesn't process it as an incoming message. The message appears in the chat for the user, but the agent session never sees it.This happens because
deliver.shcallssendMessageon the Bot API directly — Telegram doesn't relay the bot's own outgoing messages back as updates, so grammY never receives them.Result: In chats/topics with
requireMention: false, external deliveries (cron results, cross-agent messages) are invisible to the agent session. Only the human sees them.Desired Behavior
When
requireMention: falseis set for a binding, the agent session should receive ALL messages that appear in the chat/topic — including those sent by the bot itself viadeliver.shor cron output.Research Needed
deliver.shsends a message, write it to the session's inject directory so the PreToolUse hook picks it up (similar to how mid-turn user messages work)bot.api.configtransformer to capture outgoing messages and route them to session contextScope
Only applies when
requireMention: false— in mention-required chats, the bot already controls when it speaks, so echoing its own messages is unnecessary.