Feature Request: Support Slack User and Group Mentions for Owners/Subscribers
Is your feature request related to a problem? Please describe. Currently, Elementary's Slack integration for alerts and notifications primarily supports mentioning individual Slack users by resolving their user ID from an email address. This limits the ability to effectively notify relevant stakeholders (owners and subscribers) if their preferred notification method involves direct Slack user mentions by name or, more critically, Slack user group mentions (e.g., @data-engineers, @on-call-team). Manually inserting Slack user or group IDs into messages is cumbersome and not scalable.
Describe the solution you'd like
I would like to extend the Slack messaging functionality in Elementary to support direct mentions of both individual Slack users and Slack user groups. This feature should allow configuring owners and subscribers with their Slack user IDs or Slack group IDs (or ideally, even their display names/group names, which Elementary would then resolve). When an alert or notification is sent, Elementary should construct the Slack message to include the appropriate mention format (<@USER_ID> for users and <!subteam^GROUP_ID> for user groups).
Describe alternatives you've considered The primary alternative considered is the current manual process of obtaining Slack user/group IDs and hardcoding them into Elementary configurations or messages. This is not user-friendly, prone to errors, and difficult to maintain as team structures or group names change.
Additional context
Elementary's existing elementary.messages.blocks.MentionBlock and elementary.messages.formats.block_kit.BlockKitBuilder provide a foundation for handling mentions. The _format_inline_block in block_kit.py currently uses a _resolve_mention callback which, in the SlackWebMessagingIntegration, is tied to get_user_id_from_email.
To implement this feature, the _resolve_mention callback, or a similar mechanism, would need to be enhanced. It's important to note that Slack's API does not provide direct methods to look up a user by their display name/username or a user group by its name/handle. Therefore, the solution would likely involve:
- Fetching a list of all users (e.g., using
users.listif user display name lookup is desired) and then performing a client-side lookup to get theUSER_ID. - Fetching a list of all user groups using the
usergroups.listAPI method, and then performing a client-side lookup to get theGROUP_IDfrom the group'snameorhandle. - Constructing the correct Slack mention format for both users (
<@USER_ID>) and user groups (<!subteam^GROUP_ID>).
Would you be willing to contribute this feature? Yes, I would be willing to contribute to this feature if guidance is provided.
According to my research, we can't fetch all Slack users by a single API request if there is a large number of slack users in an organization. Meanwhile, the API to get a list of groups enables us to fetch all groups by a single API request. If we utilize cache of fetched groups, we can avoid unnecessary frequent API request. I think even slack mentions by group(s) would be very useful.
- https://api.slack.com/methods/usergroups.list
This issue is stale because it has been open for too long with no activity. If you would like the issue to remain open, please remove the stale label or leave a comment.