stevengill / bolt-js-webinar-july-2020

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bolt-js Webinar July 2020 Example

This is a quick example app showing off some of the functionality available in bolt-js.

Local development requires a public URL where Slack can send requests. In this guide, we'll be using ngrok. Checkout this guide for setting it up.

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. You also need to create a new app if you haven’t already.

Install Dependencies

npm install

Install app to workspace

In your App Config Page, go to OAuth & Permissions and add the channels:read, app_mentions:read, and chat:write permissions. Click install App to install the app to your workspace and generate a bot token.

Setup Environment Variables

This app requires you setup a few environment variables. You can get these values by navigating to your App Config Page.

export SLACK_BOT_TOKEN=YOUR_SLACK_CLIENT_SECRET
export SLACK_SIGNING_SECRET=YOUR_SLACK_SIGNING_SECRET

Run the App

Start the app with the following command:

npm start

This will start the app on port 3000.

Now lets start ngrok so we can access the app on an external network and create a redirect url for OAuth.

ngrok http 3000

This should output a forwarding address for http and https. Take note of the https one. It should look something like the following:

Forwarding   https://3cb89939.ngrok.io -> http://localhost:3000

Navigate to the App Home page in your app config and enable it. Then navigate to Event Subscriptions to enable it. The request URL should be set to your ngrok forwarding address with the slack/events path appended. ex:

https://3cb89939.ngrok.io/slack/events

Lastly, in the Events Subscription page, click Subscribe to bot events and add app_home_opened, app_mentioned, and message.channels.

About


Languages

Language:JavaScript 100.0%