You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# slack-multi-channel-invite
2
-
Have you ever googled `"slack invite user to multiple channels"`? Yeah, me too. I do this every time a new engineer joins my team, and inevitably end up inviting said engineer to each Slack channel manually. I got tired of this, so I rolled up my sleeves and whipped up this script in a couple of hours.
2
+
Have you ever googled `"slack invite user to multiple channels"`? Yeah, me too. I do this every time a new engineer joins my team, and I inevitably end up inviting said engineer to each Slack channel manually. I got tired of this, so I rolled up my sleeves and whipped up this script.
3
3
4
-
I assume Slack will eventually add this ability. Until then, hopefully you can save some time by using this script.
4
+
I assume Slack will eventually add this ability. Until then, hopefully you can save some time by using this.
5
5
6
6
Enjoy!
7
7
@@ -20,16 +20,16 @@ Enjoy!
20
20
- Else download the binary directly: https://github.com/jamietsao/slack-multi-channel-invite/releases
The user with email`steph@curry.com` should be invited to channels `foo`, `bar`, and `baz`!
25
+
The users with emails`steph@warriors.com`and `klay@warriors.com`should be invited to channels `dubnation`, `splashbrothers`, and `thetown`!
26
26
27
27
_* Set `private` flag to `true` if you want to invite users to private channels. As noted above, this will require the additional permission scopes of `groups:read` and `groups:write`_
28
28
29
29
## Implementation
30
-
Initially, I figured this script would be a simple loop that invoked some API to invite a user to a channel. It turns out this API endpoint ([`conversations.invite`](https://api.slack.com/methods/conversations.invite)) expects the user ID (instead of username) and channel ID (instead of channel name). Problem is, it's not very straightforward to get user and channel IDs. There isn't a way to lookup a user by username (only by email). And there's no way to look up a single channel, unless you have the channel ID already (chicken and egg).
30
+
Initially, I figured this script would be a simple loop that invoked some API to invite users to a channel. It turns out this API endpoint ([`conversations.invite`](https://api.slack.com/methods/conversations.invite)) expects the user ID (instead of username) and channel ID (instead of channel name). Problem is, it's not very straightforward to get user and channel IDs. There isn't a way to lookup a user by username (only by email). And there's no way to look up a single channel, unless you have the channel ID already (chicken and egg).
31
31
32
32
For these reasons, I wrote the script like so:
33
-
1.[Look up](https://api.slack.com/methods/users.lookupByEmail)the Slack user ID by email.
33
+
1.[Look up](https://api.slack.com/methods/users.lookupByEmail) Slack user IDs for all given emails.
34
34
2.[Query](https://api.slack.com/methods/conversations.list) all public (or private) channels in the workspace and create a name -> ID mapping.
35
-
3. For each of the given channels, [invite](https://api.slack.com/methods/conversations.invite) the user to the channel using the user ID and channel ID from steps 1 & 2.
35
+
3. For each of the given channels, [invite](https://api.slack.com/methods/conversations.invite) the users to the channel using the user IDs and channel ID from steps 1 & 2.
0 commit comments