Skip to content

feat(telegram): fallback to main chat when topic delivery fails #2122

@Lukavyi

Description

@Lukavyi

Problem

When a cron job (or any delivery) is configured to send to a specific Telegram topic via to: "chatId:topic:123", and that topic is deleted, the message fails with:

400: Bad Request: message thread not found

The message is lost with no fallback.

Proposed Solution

Add optional fallback behavior when topic delivery fails:

  1. Detect topic-related errors: message thread not found, THREAD_ID_INVALID
  2. Fallback to main chat: Retry without message_thread_id
  3. Log warning: Notify that fallback was used so user can update config

Configuration

{
  channels: {
    telegram: {
      topicFallback: true  // default: false (preserve current behavior)
    }
  }
}

Or per-cron:

{
  cron: {
    jobs: [{
      to: "123:topic:456",
      fallbackTo: "123"  // explicit fallback target
    }]
  }
}

Use Cases

  • Cron jobs for news digests to specific topics
  • Automated notifications to forum topics
  • Any scheduled delivery to topics that might be reorganized

Current Workaround

Manually update cron --to after deleting/recreating topics.

Environment

  • Clawdbot: 2026.1.21
  • Telegram Bot API with forum topics

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions