A Slack bot that allows you to create and use group mentions. When a user types "@groupname" in a message, the bot will reply in the thread with mentions of all users in that group.
- Create and manage groups of users
- Automatically detect @group mentions in messages
- Reply in thread with all users in the mentioned group
- Add as many groups as you want
- Go to https://api.slack.com/apps and click "Create New App"
- Choose "From scratch" and give your app a name and select your workspace
- Under "Basic Information", note your "Signing Secret" for later
- Go to "OAuth & Permissions" in the sidebar
- Under "Scopes", add the following Bot Token Scopes:
chat:write
- To send messagescommands
- To create slash commandsusers:read
- To get user informationchannels:history
- To read messages in channelsgroups:history
- To read messages in private channelsim:history
- To read messages in DMsmpim:history
- To read messages in group DMs
- Click "Install to Workspace" and authorize the app
- Note your "Bot User OAuth Token" (starts with
xoxb-
) for later
- Go to "Socket Mode" in the sidebar and enable it
- Generate an app-level token with the
connections:write
scope - Note your App Token (starts with
xapp-
) for later
Create the following slash commands under "Slash Commands" in the sidebar:
-
/group-create
- Create a new group- Description: Create or update a group with specified users
- Usage hint: groupname @user1 @user2 ...
-
/group-list
- List all available groups- Description: Show all available groups
-
/group-show
- Show members of a group- Description: Show all members of the specified group
- Usage hint: groupname
-
/group-delete
- Delete a group- Description: Delete the specified group
- Usage hint: groupname
- Go to "Event Subscriptions" in the sidebar and enable it
- Subscribe to the
message.channels
bot event - Save changes
- Clone this repository
- Run
npm install
to install dependencies - Create a
.env
file with the following:SLACK_BOT_TOKEN=xoxb-your-bot-token SLACK_SIGNING_SECRET=your-signing-secret SLACK_APP_TOKEN=xapp-your-app-token
- Run
npm start
to start the bot
/group-create dev @john @sarah @mike
This creates a group named "dev" with the mentioned users.
Simply type @groupname
in any message:
Hey @dev, can we discuss the new feature?
The bot will reply in a thread with:
Group @dev mentions: @john @sarah @mike
/group-list
/group-show dev
/group-delete dev
Groups are stored in a local groups.json
file. For production use, you might want to replace this with a database.