Skip to content

Commit

Permalink
Regression. Remove workspace app mentions.
Browse files Browse the repository at this point in the history
  • Loading branch information
girliemac committed Oct 9, 2018
1 parent c537c41 commit be324e5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 41 deletions.
24 changes: 11 additions & 13 deletions README.md
@@ -1,9 +1,6 @@
# Sending a Welcome Message to a New User

> :sparkles: *Updated August 2018: As we have introduced the workspace app (currently in beta), this tutorial and the code samples have been updated using the new token model! All the changes from the previous version of this example, read the [diff.md](diff.md)*
*Learn more about the workspace app at the [Slack API doc](https://api.slack.com/workspace-apps-preview).*

> :sparkles: *Updated October 2018: 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.

Expand All @@ -15,20 +12,21 @@ The user can accept the Terms of Service using message buttons. If a user has be

#### Create a Slack app

1. Create a *workspace app* at [https://api.slack.com/apps?new_app_token=1]
2. Enable Interactive components (See *Enable Interactive Components* below)
3. Navigate to the **OAuth & Permissions** page and add the following scopes:
* `chat:write`
* `conversations.app_home:create`
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!)
1. [Create an app](https://api.slack.com/apps)
2. Go to **Bot Users** and click "Add a Bot User" to create a, app bot. Save the change.
3. Enable Interactive components (See *Enable Interactive Components* below)
4. Navigate to the **OAuth & Permissions** page and add the following scopes:
* `chat:write:bot`
5. Click 'Save Changes' and install the app (You should get an OAuth access token after the installation)
6. Enable the events (See *Enable the Events API* below. It doesn't let you the Request URL until you run the code!)
7. In your Slack workspace, invite the bot to #general, where the new user will join.

#### Run locally or [![Remix on Glitch](https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button.svg)](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 `xoxa-` token (available on the Install App page after the installation)
* `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`)
Expand All @@ -40,4 +38,4 @@ The user can accept the Terms of Service using message buttons. If a user has be

#### Enable Interactive Messages
1. In the app settings, click on Interactive Messages
1. Set the Request URL to your server or Glitch URL + `/interactive-message`
1. Set the Request URL to your server or Glitch URL + `/interactive`
23 changes: 6 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "slack-tos-example",
"private": true,
"version": "2.0.0",
"version": "1.5.0",
"description": "Sample Slack app that uses the Events API and interactive messages to send new users a Terms of Service or welcome message",
"engines": {
"node": ">= 6.9.0"
Expand Down
14 changes: 4 additions & 10 deletions src/index.js
Expand Up @@ -43,20 +43,14 @@ app.post('/events', (req, res) => {
// Verify the signing secret
if (signature.isVerified(req)) {
const event = req.body.event;
console.log(event)

// TEST - Remove it later
// if (event.type) {
// const { team_id, id } = event.user;
// onboard.initialMessage(team_id, id);
// }
///////

console.log(event);

// `team_join` is fired whenever a new user (incl. a bot) joins the team
if (event.type === 'team_join' && !event.is_bot) {
const { team_id, id } = event.user;
onboard.initialMessage(team_id, id);
}

res.sendStatus(200);
} else { res.sendStatus(500); }
break;
Expand All @@ -69,7 +63,7 @@ app.post('/events', (req, res) => {
* Endpoint to receive events from interactive message on Slack.
* Verify the signing secret before continuing.
*/
app.post('/interactive-message', (req, res) => {
app.post('/interactive', (req, res) => {
const { token, user, team } = JSON.parse(req.body.payload);
if (signature.isVerified(req)) {
// simplest case with only a single button in the application
Expand Down
1 change: 1 addition & 0 deletions src/onboard.js
Expand Up @@ -14,6 +14,7 @@ const message = {
token: process.env.SLACK_ACCESS_TOKEN,
link_names: true,
text: 'Welcome to the team! We\'re glad you\'re here.',
as_user: true,
attachments: JSON.stringify([
{
title: 'What is Slack?',
Expand Down

0 comments on commit be324e5

Please sign in to comment.