Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active January 10, 2019 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexellis/e8298fb5c625e209496b6bbf624a4c47 to your computer and use it in GitHub Desktop.
Save alexellis/e8298fb5c625e209496b6bbf624a4c47 to your computer and use it in GitHub Desktop.
Bulk invite email addresses to Slack
#!/bin/bash
# Copyright Alex Ellis 2019
# Generate legacy token, then populate here
export TOKEN=""
# You will need to put each email address on a new line in a file named users.txt
cat users.txt | while read line
do
export EMAIL=$line
echo Inviting $EMAIL
curl -X POST 'https://openfaas.slack.com/api/users.admin.invite' \
--data "email=""$EMAIL""&token=""$TOKEN""&set_active=true" \
--compressed
echo
sleep 0.1
done
#!/bin/bash
export TOKEN=""
cat users.txt | while read line
do
export EMAIL=$(echo $line | cut -f1 -d" ")
export FIRST=$(echo $line | cut -f2 -d" ")
export LAST=$(echo $line | cut -f3 -d" ")
#export EMAIL=$line
echo Inviting $EMAIL $FIRST $LAST
curl -X POST 'https://openfaas.slack.com/api/users.admin.invite' \
--data "email=""$EMAIL""&token=""$TOKEN""&set_active=true&first_name=""$FIRST""&last_name=""$LAST""" \
--compressed
echo
sleep 0.1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment