Skip to content

Bot doesn't see messages sent via deliver.sh in topics/chats #91

@fitz123

Description

@fitz123

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:
    1. 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)
    2. Bot-level relay: Bot intercepts its own outgoing messages and feeds them back into the message queue for the relevant session
    3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions