Make a new directory and put the run.js
script into it.
Run npm in that same directory to install the slack web-api module:
npm install @slack/web-api
This script will run as a bot user on your server.
To begin using this bot you will need to add an App on your slack workspace.
I'm not sure exactly what roles you'll need to add, but these worked for me:
- channels:join Join public channels in the workspace
- channels:manage Manage public channels that inviter has been added to and create new ones
- channels:read View basic information about public channels in the workspace
- users:read View people in the workspace
Then once added to your workspace, copy the bot token and replace it in the token
script variable.
You'll also need to invite your bot to the channel you wish to have it invite people to. The easiest way to do it is @ mention it in the channel.
Then simply replace the from_name
and to_name
variables with the names of your channels to copy from and to respectively.
From the directory you installed run.js in and installed the slack web-api module in, and after having replaced the values of the token
, from_name
and to_name
variables in, run the script:
node run
You will see output like:
Inviting users from channel #my-existing-channel (C9A79B5K2) to #my-new-channel (C015RC2D62J)
Getting member list from #my-existing-channel...
Found 1530 members
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 100 members...
Inviting 30 members...
Done!
How could I just invite a list of people not everyone all at once?