Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Zapier Code to auto invite users to slack
var slackTeam = "YOUR_SLACK_TEAM_NAME ";
var token = 'YOUR_ADMIN_TEST_TOKEN';
// A test token will suffice.
// You can generate one at
// Just make sure that the user issuing the test token is an admin.
var url = 'https://'+ slackTeam + '';
fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: "token="+ token + "&email=" +
.then(function(res) {
return res.text();
.then(function(body) {
var output = {rawHTML: body};
callback(null, output);
Copy link

Chupee commented Aug 3, 2016

It perfectly works! Thank you!

Copy link

hashimwarren commented Aug 5, 2016

Wow! It worked! Thanks for sharing your work.

Copy link

dsiles commented Sep 20, 2016

Perfect solution... much better than others I have been trying. Thank you!

Copy link

pluthena commented Jul 14, 2017

Works! Thank you! Suggested tweaks to invite as a single channel guest to a specified channel?

Copy link

skylartaylor commented Dec 20, 2017

This worked perfectly! Thank you so much!

Copy link

Rustonian commented Feb 11, 2018

@pluthena I need the same thing!

Copy link

EvgenSchastnyy commented Mar 24, 2018

How to use this code in Zapier?

Copy link

okrg commented May 25, 2018

@EvgenSchastnyy Add the step named "Code", it is a built-in app by Zapier. Select JS, create the input data variable named email and map it to the email address from your trigger step.

Then paste the above JS code, but it seems the email variable should be named to match how the current version of Zapier Code input data is named.

Copy link

OneKostas commented Dec 18, 2018

Many thanks for the solution!

Copy link

NickEubanks commented Feb 25, 2019

Hey @dommmel any chance you have an updated script since Slack deprecated workspace tokens and now requires OAuth authentication flow?

Copy link

thalesbros commented Jul 24, 2020

Did anyone find out how to do this since the legacy tokens are now disabled?

Copy link

ChintanSavaliya commented Nov 14, 2020

Any update guys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment