Skip to content

Feature: Auto-rename Telegram DM topics based on conversation content #51485

@Lukavyi

Description

@Lukavyi

Summary

Automatically rename Telegram DM forum topics when the first message arrives in a new topic/session. Currently users must either manually rename topics or instruct the agent to do it via SOUL.md/system prompt - which is unreliable since the model may ignore the instruction.

Problem

When using Telegram DM topics (forum mode in 1:1 bot chats), new topics get generic names like "Topic #123". Users have to:

  1. Manually rename each topic, OR
  2. Add instructions to SOUL.md/MEMORY.md telling the agent to rename - but this is model-dependent and unreliable (the agent frequently forgets)

This is a gateway-level concern, not something that should depend on model compliance.

Proposed Solution

Add an autoTopicLabel config option to TelegramDirectConfig and/or TelegramAccountConfig:

{
  "telegram": {
    "direct": {
      "63448508": {
        "autoTopicLabel": true
      }
    }
  }
}

Behavior

When autoTopicLabel: true and a message arrives in a DM topic:

  1. Detect if this is the first turn in the session (isFirstTurnInSession already exists in get-reply-run.ts)
  2. After the agent reply is sent, generate a short topic label from the user message (first ~30-50 chars, or a lightweight LLM summary)
  3. Call renameTopic() (API already exists and works)

Implementation Notes

  • isFirstTurnInSession detection already exists in src/auto-reply/reply/get-reply-run.ts:235
  • renameTopic API is fully functional via extensions/telegram/runtime-api.ts
  • editForumTopic action permission exists in TelegramActionConfig
  • Could use a simple heuristic (truncated first message) or a lightweight model call for better labels
  • Should respect actions.editForumTopic permission
  • Should be opt-in (default: false)

Alternatives Considered

  • Agent-level instruction (SOUL.md): Unreliable - model frequently ignores the instruction
  • Internal hook on message:sent: Would work but adds complexity; a config flag is cleaner
  • Manual /set_topic_name command: PR feat: add /set_topic_name for telegram topic labels #46983 adds this, but does not solve the auto-rename case

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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