Skip to content

Latest commit

 

History

History
103 lines (62 loc) · 5.79 KB

SETUP.md

File metadata and controls

103 lines (62 loc) · 5.79 KB

Getting Started With Bolt for JavaScript

The CHAOSS Slack Bot is built on the Bolt for JavaScript framework. You can get started by following the guide below to set up a new Slack app using socket mode.

Create an App

  • First, we recommend creating a new workspace where you won’t disrupt real work getting done.

  • To create a Slack app and install it in your workspace, click here.

  • You should see a modal with two options for configuration. Choose the From scratch option. image

  • Click on the Create App button to go to the Basic Information page.

Tokens and installing app

  • Navigate to the OAuth & Permissions on the left sidebar. image

  • Scroll down to the Bot Token Scopes section. Click Add an OAuth Scope. image image

The bot currently has these OAuth Scopes enabled, so enable those for full functionality of the bot. If you're adding a new function, you might need more permissions. See the set up for adding new functions below.

A comprehensive list of permission scopes is available at api.slack.com/scopes.

  • Scroll up to the top of the OAuth & Permissions page and click Install App to Workspace. image You’ll be led through Slack’s OAuth UI, where you should allow your app to be installed to your development workspace. See sample below. image

    Click on 'Allow' to confirm that the intallation was successful done on the Slack platform.

    image

    The slack bot will appear on the side bar of your slack app image

  • Once you authorize the installation, you will be led to OAuth & Permissions page and see a Bot User OAuth Access Token.

Treat your token like a password and keep it safe. Your app uses it to post and retrieve information from Slack workspaces.

Setting up your project

  • Navigate to your project folder

$ cd chaoss-slack-bot

  • Copy your Signing Secret from the Basic Information page and then store it in a new environment variable.
  • Copy your bot (xoxb) token from the OAuth & Permissions page and store it in another environment variable.

For Linux and macOS:

    $ export SLACK_SIGNING_SECRET=<your-signing-secret>

    $ export SLACK_BOT_TOKEN=xoxb-<your-bot-token>

For Windows:

  • Create a new .env file in the root of your project.
  • Copy the content of the .env.example file and paste in the new .env file you created.
  • Insert your tokens into the quotes. Make sure you include the .env file in your .gitignore file, to avoid exposing your secret keys.

Setting up events

To listen for events happening in a Slack workspace (like when a message is posted or when a reaction is posted to a message) you’ll use the Events API to subscribe to event types. CHAOSS Slack Bot uses Socket Mode.

  • Head to your app’s configuration page (click on the app from your app management page). Navigate to Socket Mode on the left side menu and toggle to enable.

image

  • Go to Basic Information and scroll down under the App Token section and click Generate Token and Scopes to generate an app token. Add the connections:write scope to this token and save the generated xapp token. image

  • Scroll down to Subscribe to Bot Events and select the events you want your bot to listen to. CHAOSS Slack Bot currently subcribes to these events. The other available events are documented at api.slack.com/events.

  • Follow the rest of the instructions in the CONTRIBUTING.md.

Adding New Function

After creating your app, you will see the options to add new function to your app.

image

  • Select from the function you want to add from the list of feature provided and follow the prompt.
  • Example: image

Attribution

Adapted from Getting started with Bolt for JavaScript.