Skip to content

Instantly share code, notes, and snippets.

@chrisDFG
Forked from dommmel/invite_to_slack.js
Last active May 13, 2018 11:54
Show Gist options
  • Save chrisDFG/ae258f6f661ab169b74231d8aa64b6bf to your computer and use it in GitHub Desktop.
Save chrisDFG/ae258f6f661ab169b74231d8aa64b6bf to your computer and use it in GitHub Desktop.
Zapier Code to auto invite users to slack
var slackTeam = delaine-for-governor;
var token = xoxp-188373911029-350991811430-362383860257-c2cc2cf19bd44a066efe413cee1a85e1;
// A test token will suffice.
// You can generate one at https://api.slack.com/docs/oauth-test-tokens
// Just make sure that the user issuing the test token is an admin.
var url = 'https://'+ slackTeam + '.slack.com/api/users.admin.invite';
fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: "token="+ token + "&email=" + input.email
})
.then(function(res) {
return res.text();
})
.then(function(body) {
var output = {rawHTML: body};
callback(null, output);
})
.catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment