- Create a Google Form with a field to collect email addresses. Pro-tip: use Data Validation to validate string is valid email.
- Click View Responses to view form responses in Google Spreadsheets.
- Open menu Tools > Script editor...
- Paste in Google App Script below and make the following changes:
- Create a Slack API token and replace the value of
SLACK_API_TOKEN
. - Replace "YOUR_TEAM_NAME" with your team's name in the value for
SLACK_API_INVITE_URL
. - Make sure
EMAIL_FIELD_NAME
corresponds to the header text of your Google Spreadsheet's email column.
- Create a Slack API token and replace the value of
- Open menu Resources > Current project's triggers and add a new trigger:
onFormSubmit
,From spreadsheet
,On form submit
. Click Save and accept the authorization request to use the script. - You can optionally configure notifications to receive error messages by email.
Last active
June 27, 2022 01:57
-
-
Save furf/174ae7db1fef79468c8f to your computer and use it in GitHub Desktop.
Slack invite integration for Google Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SLACK_API_TOKEN = 'xxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxx'; | |
var SLACK_API_INVITE_URL = 'https://YOUR_TEAM_NAME.slack.com/api/users.admin.invite'; | |
var EMAIL_FIELD_NAME = 'E-mail Address'; | |
function inviteUser(email) { | |
var data = { | |
email: email, | |
token: SLACK_API_TOKEN, | |
set_active: 'true' | |
}; | |
var options = { | |
method: 'POST', | |
payload: data | |
}; | |
UrlFetchApp.fetch(SLACK_API_INVITE_URL, options); | |
} | |
function onFormSubmit(e) { | |
var email = e.namedValues[EMAIL_FIELD_NAME][0]; | |
inviteUser(email); | |
} |
Is this still valid to use after all these years? We are looking to use something for people who want to invite external members to our slack partners channel.
🤷 give it a try? I haven't had need for it since I wrote it.
Relevant links:
https://api.slack.com/authentication/token-types
https://api.slack.com/docs/rate-limits
https://api.slack.com/methods/admin.users.invite
The last one says it's only available for "Enterprise Grid".
The schema has changed a bit so it's definitely not plug-and-play anymore.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this still valid to use after all these years? We are looking to use something for people who want to invite external members to our slack partners channel.