seratch / bolt-starter

A Bolt ⚡️ app template with useful settings for easier development
MIT License
52 stars 11 forks source link
bolt javascript js slack slack-api slack-app

Getting started with Bolt ⚡️

This is a simple Slack's Bolt⚡️ app template. This README covers the following ways to start building your awesome Slack apps.


(Step 1) Slack App Initial Setup

Create a Slack App

Start with creating a new Slack app from https://api.slack.com/apps

Configure Bot Scopes

Access Features > OAuth & Permissions from the left sidebar and set the followings.

https://api.slack.com/apps/{APP_ID}/oauth

Install the app to your workspace

Access Settings > Install App from the left sidebar. You'll configure more later but let's install the app anyway to get a bot token (xoxb-***).

https://api.slack.com/apps/{APP_ID}/install-on-team


(Step 2A) CodeSandbox Setup

Sign in with your GitHub account

https://codesandbox.io/

As of December 2019, CodeSandbox allows logging in with only GitHub accounts. You need to login with your own GitHub account.

Create a new sandbox

It's pretty simple. Create a new sandbox by importing this repostiory. The steps are:

Then, fork the template project to create your own sandbox:

In your own sandbox project, configure secrets as below:

That's all! If your changes are not reflected to the running sandbox, click Restart Sandbox button.

Set Request URLs (Slack App)

You must see https://{random}.sse.codesandbox.io/ URL in the right pane on CodeSandbox.

You can go with https://{random}.sse.codesandbox.io/slack/events for all of the Slack App Request URLs.

You need to configure the following three settings with the URL.

Re-install Slack App to your workspace

https://api.slack.com/apps/{APP_ID}/install-on-team


(Step 2B) Glitch Setup

https://glitch.com/

Create a Glitch project

The steps are similar to CodeSandbox.

After creating a project, duplicate _env file and name it as .env. The file named .env will be automatically marked as a secret file.

After modifying .env file, make sure if the app is running without any problems by checking the logs.

Set Request URLs (Slack App)

You must see https://{some-fancy-name}.glitch.me/ URL in the Live App settings on Glitch.

You can go with https://{some-fancy-name}.glitch.me/slack/events for all of the Slack App Request URLs.

Re-install Slack App to your workspace

https://api.slack.com/apps/{APP_ID}/install-on-team


(Step 2C) Your Local Machine Setup

ngrok Setup

https://ngrok.com/

ngrok http 3000

If you have a paid license, you can configure a fixed subdomain.

ngrok http 3000 --subdomain your-awesome-subdomain

Node Version Manager (nvm) Setup

Linux / macOS

Windows

If you go with WSL, follow the same steps in Linux / macOS.

Start with this template

Or it's also possible to download this project template:

git clone git@github.com:seratch/bolt-starter.git or https://github.com/seratch/bolt-starter/archive/master.zip

Run the app

cd bolt-starter
cp _env .env
# edit .env
npm i
npm run local

Set Request URLs (Slack App)

Set https://{your-awesome-subdomain}.ngrok.io/slack/events to all of the followings:

Slash Commands

Access Features > Slash Commands from the left sidebar. Create a slash command named /open-modal.

https://api.slack.com/apps/{APP_ID}/slash-commands

Configure Event Subscriptions

Access Features > Event Subscriptions from the left sidebar. Add an event subscription for app_mention events and click "Save Changes" button for sure..

https://api.slack.com/apps/{APP_ID}/event-subscriptions

Configure Interactivity

Access Features > Interactivity & Shortcuts from the left sidebar. Set the Request URL for Interactity and click "Save Changes" button for sure.

https://api.slack.com/apps/{APP_ID}/interactive-messages

Global Shortcuts

Access Features > Interactivity & Shortcuts > Shortcuts from the left sidebar. Create a new global shortcut with Callback ID open-modal.

Re-install the app to your workspace

https://api.slack.com/apps/{APP_ID}/install-on-team

License

The MIT License