https://github.com/slack-samples/javascript-welcome-bot
Sample Slack app that uses the Events API and interactive messages to send new users a Terms of Service or welcome message
https://github.com/slack-samples/javascript-welcome-bot
slack-blueprint slack-workflow-sample
Last synced: 6 months ago
JSON representation
Sample Slack app that uses the Events API and interactive messages to send new users a Terms of Service or welcome message
- Host: GitHub
- URL: https://github.com/slack-samples/javascript-welcome-bot
- Owner: slackapi
- License: mit
- Created: 2017-06-12T18:42:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T08:15:50.000Z (about 2 years ago)
- Last Synced: 2025-01-30T14:22:36.262Z (12 months ago)
- Topics: slack-blueprint, slack-workflow-sample
- Language: JavaScript
- Size: 242 KB
- Stars: 35
- Watchers: 8
- Forks: 25
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Sending a Welcome Message to a New User
> :sparkles: *Updated December 2019: As we have introduced some new features, this tutorial and the code samples have been updated! All the changes from the previous version of this example, read the [DIFF.md](diff.md)*
Sample Slack app that presents a Terms of Service (or any other message) when a new user joins a team.
The user can accept the Terms of Service using message buttons. If a user has been presented with the Terms before and they haven't accepted, a background job can send them a reminder after a specific period of time. If you are on Plus plan or Slack Enterprise Grid, you may use the [SCIM API](https://api.slack.com/scim) to disable the user's account.

## Setup
#### Create a Slack app
1. [Create an app](https://api.slack.com/apps)
2. Enable Interactive components (See *Enable Interactive Components* below)
3. Navigate to the **OAuth & Permissions** page and add the following bot token scopes:
* `chat:write`, `im:write`, `users:read`
4. Click 'Save Changes' and install the app (You should get an OAuth access token after the installation)
5. Enable the events (See *Enable the Events API* below. It doesn't let you the Request URL until you run the code!)
6. In your Slack workspace, invite the bot to #general, where the new user will join.
#### Run locally or [](https://glitch.com/edit/#!/remix/slack-terms-of-service-blueprint)
1. Get the code
* Either clone this repo and run `npm install`
* Or visit https://glitch.com/edit/#!/remix/slack-terms-of-service-blueprint
2. Set the following environment variables to `.env` (see `.env.sample`):
* `SLACK_ACCESS_TOKEN`: Your app's `xoxb-` token (available on the Install App page, after you install the app to a workspace once.)
* `SLACK_SIGNING_SECRET`: Your app's Signing Secret (available on the **Basic Information** page)
3. If you're running the app locally:
* Start the app (`npm start`)
#### Enable the Events API
1. Go back to the app settings and click on Events Subscriptions
1. Set the Request URL to your server (*e.g.* `https://yourname.ngrok.com`) or Glitch URL + `/events`
1. On the same page, subscribe to the `team_join` team events
#### Enable Interactive Messages
1. In the app settings, click on Interactive Messages
1. Set the Request URL to your server or Glitch URL + `/interactive`