Skip to content

Change how invite app works to work around Slack API limits #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,29 @@ There are two ways to issue the access token.

![](screenshots/oauth2.gif)

1. In "OAuth & Permissions" page, select `admin` scope under "Permission Scopes" menu and save changes.
1. In "OAuth & Permissions" page, select `chat:write` scope under "Permission Scopes" menu and save changes.

![](screenshots/oauth3.gif)

1. Click "Install App to Workspace".

![](screenshots/oauth4.gif)

1. Visit <https://slack.com/oauth/authorize?&client_id=CLIENT_ID&team=TEAM_ID&install_redirect=install-on-team&scope=admin+client> in your browser and authorize your app.
* This form requires the `client` permission. Otherwise, you can see `{"ok":false,"error":"missing_scope","needed":"client","provided":"admin"}` error.
* Your `TEAM_ID` is the subdomain for your slack team, e.g. myteam.slack.com - your TEAM_ID is `myteam`.
* Your `CLIENT_ID` found in "Basic Information" section for your App.
* You will be shown a `Installed App Settings > OAuth Tokens for Your Team` screen.
* You can test auto invites with curl by providing the `OAuth Access Token`.
```sh
curl -X POST 'https://myteam.slack.com/api/users.admin.invite' \
--data '[email protected]&token=OAuthAccessToken&set_active=true' \
--compressed
```

![](screenshots/basic_info-client_id.png)
## Slack Channel Id
Since Slack no longer allows access to the invitation API endpoint unless you are on a enterprise setup the easiest way forward is to message a workspace admin and have them manually invite people. To ease this we let our webapp post a message into a Direct Message to an admin, or to a admin-shared channel.

### Single admin
To find out you channelId for a workspace admin DM. Open the profile of this admin in slack. Press the more button (…), then "Copy member ID". Set this value in your environment variable: `SLACK_CHANNEL`.
If this is no longer up to date, [maybe this help post can help you out:](https://slack.com/help/articles/360003827751-Create-a-link-to-a-members-profile-)


### Admin-invite-channel
***Don't forget to invite your admin-user to the admin-channel***

Create or use an existing admin-channel with relevant workspace admins included. In the slack client, open the channel, click the downfacing chevron next to the channel name. Next scroll all the way down in the about tab, then copy the Channel ID. Set this value in your environment variable: `SLACK_CHANNEL`
If this is no longer up to date, [maybe this help post can help you out:](https://www.wikihow.com/Find-a-Channel-ID-on-Slack-on-PC-or-Mac)


## Badge

Expand Down
4 changes: 4 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"description": "Your team name",
"value": "YOUR TEAM NAME"
},
"SLACK_CHANNEL": {
"description": "Your slack admin channel or admin userId (ex: C8F1JAG61)",
"value": "YOUR-CHANNEL-ID"
},
"SLACK_URL": {
"description": "Your slack url(ex: socketio.slack.com)",
"value": "YOUR-TEAM.slack.com"
Expand Down
2 changes: 2 additions & 0 deletions aws/brick/index.ic
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from . import assets
def brick(
community_name,
slack_url,
slack_channel,
slack_token,
invite_token="",
recaptcha_site_key="",
Expand All @@ -22,6 +23,7 @@ def brick(
timeout=10,
environ=dict(
COMMUNITY_NAME=community_name,
SLACK_CHANNEL=slack_channel,
SLACK_URL=slack_url,
SLACK_TOKEN=slack_token,
INVITE_TOKEN=invite_token,
Expand Down
1 change: 1 addition & 0 deletions aws/brick/params.icp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
community_name = "Your Community Name"
slack_url = "yourcommunity.slack.com"
slack_channel = "ABCD10EFG"
slack_token = "xoxp-xxx-xxx-xxx-xxx"
# invite_token = util.sensitive("")
# recaptcha_site_key = util.sensitive("")
Expand Down
2 changes: 1 addition & 1 deletion aws/config.example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ S3PrefixArtifacts=cloudformation/slack-invite-automation

CommunityName="Your Community Name"
SlackUrl=yourcommunity.slack.com
SlackChannel=ABCD10EFG
SlackToken=xoxp-xxx-xxx-xxx-xxx
InviteToken=
RecaptchaSiteKey=
RecaptchaSecretKey=
Locale=en

1 change: 1 addition & 0 deletions aws/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ aws cloudformation deploy \
--parameter-overrides \
CommunityName="${CommunityName}" \
SlackUrl="${SlackUrl}" \
SlackChannel="${SlackChannel}" \
SlackToken="${SlackToken}" \
InviteToken="${InviteToken}" \
RecaptchaSiteKey="${RecaptchaSiteKey}" \
Expand Down
5 changes: 5 additions & 0 deletions aws/sam-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"Type": "String",
"Description": "URL host for your Slack community (e.g., \"exampleteam.slack.com\")"
},
"SlackChannel": {
"Type": "String",
"Description": "Your slack admin channel or admin userId (e.g., \"C8F1JAG61\")"
},
"SlackToken": {
"Type": "String",
"NoEcho": true,
Expand Down Expand Up @@ -61,6 +65,7 @@
"Variables": {
"COMMUNITY_NAME": { "Ref": "CommunityName" },
"SLACK_URL": { "Ref": "SlackUrl" },
"SLACK_CHANNEL": { "Ref": "SlackChannel" },
"SLACK_TOKEN": { "Ref": "SlackToken" },
"INVITE_TOKEN": { "Ref": "InviteToken" },
"RECAPTCHA_SITE": { "Ref": "RecaptchaSiteKey" },
Expand Down
4 changes: 4 additions & 0 deletions azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"slackUrl": {
"type": "string"
},
"slackChannel": {
"type": "string"
},
"slackToken": {
"type": "string"
},
Expand Down Expand Up @@ -134,6 +137,7 @@
"properties": {
"COMMUNITY_NAME": "[parameters('communityName')]",
"SLACK_URL": "[parameters('slackUrl')]",
"SLACK_CHANNEL": "[parameters('slackChannel')]",
"SLACK_TOKEN": "[parameters('slackToken')]",
"INVITE_TOKEN": "[parameters('inviteToken')]",
"RECAPTCHA_SITE": "[parameters('recaptchaSite')]",
Expand Down
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ module.exports = {
community: process.env.COMMUNITY_NAME || 'YOUR-TEAM-NAME',
// your slack team url (ex: socketio.slack.com)
slackUrl: process.env.SLACK_URL || 'YOUR-TEAM.slack.com',
// This is the member ID of an admin, or a admin-dedicated channel id.
// see https://github.com/outsideris/slack-invite-automation#slack-channel-id
// If you have one single admin, a DM will be created from your non-owner admin user.
// If you have a admin or invite channel, admins should be there and take manual action on these messages.
slackChannel: process.env.SLACK_CHANNEL || 'YOUR-SLACK-CHANNEL-ID',
// access token of slack
// see https://github.com/outsideris/slack-invite-automation#issue-token
//
Expand Down
5 changes: 4 additions & 1 deletion manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ applications:
# your slack team url (ex: socketio.slack.com)
SLACK_URL: socketio.slack.com

# your slack workspace admin user id or admin channel id
SLACK_CHANNEL: '<channelid>'

# access token of slack
# You can generate it in https://api.slack.com/web#auth
# You should generate the token in admin user, not owner.
Expand All @@ -25,5 +28,5 @@ applications:

# an optional security measure - if it is set, then that token will be required to get invited.
# INVITE_TOKEN: <token>

LOCALE: en
Loading