feat(telegram): add support for topics in groups - #1536
Open
Matin-B wants to merge 1 commit into
Open
Conversation
This commit introduces the optional 'messageThreadIds' configuration parameter to the reportTelegram module. It allows users to route specific alert channels (e.g., 'noc', 'default') to specific topic threads within Telegram Forum Supergroups by injecting the 'message_thread_id' key into the HTTP POST payload. Strict non-zero integer validation is included to ensure absolute backwards compatibility with standard groups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the Telegram report module only supports sending alerts to standard chats, channels or groups. With Telegram's "Topics" feature for groups, it makes much more sense to route different alerts into specific topic threads rather than scattering them across multiple chats.
This approach is highly practical for maintaining a single, unified monitoring group. For example, you can have one central NOC group where BGPalerter, Uptime Kuma, and other infrastructure tools each get their own dedicated topic.
This PR adds an optional
messageThreadIdsparameter to thereportTelegramconfiguration to support this workflow.Changes made:
messageThreadIdsblock inconfig.yml.example(structurally mirroringchatIds).reportTelegram.jsto parse this new configuration and inject themessage_thread_idkey into the HTTP payload sent to the Telegram API.docs/reports.md.Backwards Compatibility:
I ensured this does not break existing configurations. The script strictly parses the ID as an integer. If
messageThreadIdsis omitted entirely, undefined, or explicitly set to0, themessage_thread_idkey is completely excluded from the payload object. It will safely fall back to standard group chat routing without throwing API errors.I compiled and tested this locally and the alerts successfully route into the designated topics. Let me know if any adjustments are needed.