Skip to content

Feature: Resolve Slack @mentions by display name (not just user ID) #46

Description

@adamrtalbot

Problem

Users can @mention people in nf-slack messages using Slack's native <@U1234567890> syntax with internal user IDs, and this works correctly. However, most users don't know Slack user IDs off the top of their head.

Writing <@Jane> (by display name) does not work — Slack only resolves mentions by internal user ID, so the text is rendered literally rather than as a clickable mention that notifies the person.

slack {
    onStart {
        // ❌ Does NOT work — display name is not resolved by Slack
        message = [text: ':wave: Hi <@Jane>!']

        // ✅ Works — but requires knowing the internal user ID
        message = [text: ':wave: Hi <@U1234567890>!']
    }
}

Proposed Solution

The plugin should resolve display names to Slack user IDs before sending the message. When the plugin encounters <@DisplayName> in message text, it should:

  1. Call the Slack users.list or users.lookupByEmail API to find the matching user
  2. Replace <@DisplayName> with <@U1234567890> (the resolved user ID)
  3. Send the message with the corrected mention syntax

Similarly for team/group mentions, resolve <!subteam^TeamName> to <!subteam^S1234567890>.

Matching strategy

Display names in Slack are not guaranteed unique, so the plugin should match against multiple fields in priority order:

  1. Username (name field) — e.g. jane.doe
  2. Display name (profile.display_name) — e.g. Jane
  3. Real name (profile.real_name) — e.g. Jane Doe

If multiple users match, the plugin should warn and skip resolution (rather than guessing wrong).

Considerations

  • Bot token scope: Requires the users:read OAuth scope to call users.list.
  • Webhook limitation: This feature would only work with bot token mode, not incoming webhooks (which can't call users.list). Should fail gracefully or warn if using webhook mode.
  • Performance: User list could be cached for the lifetime of the pipeline run to avoid repeated API calls.
  • Ambiguity handling: If a display name matches multiple users, log a warning with the matches and leave the mention unresolved rather than mentioning the wrong person.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions