Search code examples
slackslack-api

Tag User group knowing only name with a bot on slack


On slack - I can tag a user directly from my both with the following text syntax :

hello Francois <@francois>

I would like to do the same with a group (unfortunately my app only know the group name not the group ID). Is there a syntax to do so - the following syntax does not work :

hello group <@group>

Solution

  • It depends what you mean by "group".

    1. Private channels are called groups by the Slack API (e.g. groups.list)
    2. Users can be assigned to functional groups called usergroups internally by the Slack api (paid Slack only, e.g. usergroups.list)

    For 1) @mention will not work. Instead you can send a <!channel> into the private channel for the same effect.

    For 2) the syntax is <!subteam^ID|handle>

    See an excerpt of the documentation on how use them:

    For paid account there is an additional command for User Groups that follows the format . (subteam is literal text. ID and handle are replaced with the details of the group.) These indicate a User Group message, and should cause a notification to be displayed by the client. User Group IDs can be determined from the usergroups.list API endpoint. For example, if you have a User Group named happy-peeps with ID of S012345, then you would use the command to mention that user group in a message.

    If you only have the usergroup name and need the ID you can use usergroups.list to get the corresponding ID.