Skip to content
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

Adding SocketModeReceiver to Bolt-js #630

Merged
merged 10 commits into from
Jan 12, 2021
Prev Previous commit
updated based on feedback
  • Loading branch information
stevengill committed Jan 12, 2021
commit ea3b645d1890ead7d71e83a409aa882984b1b5e2
2 changes: 1 addition & 1 deletion docs/_basic/socket_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ order: 16
<div class="section-content">
[Socket Mode](https://api.slack.com/socket-mode) allows your app to connect and receive data from Slack via a WebSocket connection. To handle the connection, Bolt for JavaScript includes a `SocketModeReceiver` (in `@slack/bolt@3.0.0` and higher). Before using Socket Mode, be sure to enable it within your app configuration.

To use the `SocketModeReceiver`, just pass in `socketMode:true` and `appToken:YOUR_APP_TOKEN` when initializing `App`. You can get your App Token in your app configuration under the **Basic Information** section.
To use the `SocketModeReceiver`, just pass in `socketMode:true` and `appToken:YOUR_APP_TOKEN` when initializing `App`. You can get your App Level Token in your app configuration under the **Basic Information** section.
</div>

```javascript
Expand Down
12 changes: 6 additions & 6 deletions examples/socket-mode/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Bolt for JavaScript Socket Mode Test App

This is a quick example app to test [Socket Mode](https://api.slack.com/socket-mode) with bolt-js.
This is a quick example app to test [Socket Mode](https://api.slack.com/socket-mode) with Bolt for JavaScript.

If using OAuth, local development requires a public URL where Slack can send requests. In this guide, we'll be using [`ngrok`](https://ngrok.com/download). Checkout [this guide](https://api.slack.com/tutorials/tunneling-with-ngrok) for setting it up. OAuth installation is only needed for public distribution. For internal apps, we recommend installing via your app config.
If using OAuth, Slack requires a public URL where it can send requests. In this guide, we'll be using [`ngrok`](https://ngrok.com/download). Checkout [this guide](https://api.slack.com/tutorials/tunneling-with-ngrok) for setting it up. OAuth installation is only needed for public distribution. For internal apps, we recommend installing via your app configuration.

Before we get started, make sure you have a development workspace where you have permissions to install apps. If you don’t have one setup, go ahead and [create one](https://slack.com/create). You also need to [create a new app](https://api.slack.com/apps?new_app=1) if you haven’t already. You will need to enable Socket Mode and generate an App Level Token.

Expand All @@ -29,9 +29,9 @@ Lastly, in **Events Subscription**, click **Subscribe to bot events** and add `a
This app requires you setup a few environment variables. You can find these values in your [app configuration](https://api.slack.com/apps).

```
// can get this from OAuth & Permission page in app config
// can get this from OAuth & Permission page in app configuration
export BOT_TOKEN=YOUR_SLACK_BOT_TOKEN
// can generate the app token from basic information page in app config
// can generate the app level token from basic information page in app configuration
export APP_TOKEN=YOUR_SLACK_APP_TOKEN

// if using OAuth, also export the following
Expand All @@ -49,9 +49,9 @@ npm start

### Running with OAuth

Only implement OAuth if you plan to distribute your application publicly. Uncomment out the OAuth specific comments in the code. If you are on dev instance, you will have to uncomment out those options as well.
Only implement OAuth if you plan to distribute your application across multiple workspaces. Uncomment out the OAuth specific comments in the code. If you are on dev instance, you will have to uncomment out those options as well.

Start `ngrok` so we can access the app on an external network and create a `redirect url` for OAuth.
Start `ngrok` so we can access the app on an external network and create a redirect URL for OAuth.

```
ngrok http 3000
Expand Down