Giter Club home page Giter Club logo

bolt-starter's Introduction

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.

  • CodeSandbox: Step 1 -> Step 2A
  • Glitch: Step 1 -> Step 2B
  • On your local machine (Linux/macOS/Windows): Step 1 -> Step 2C

(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

  • app_mentions:read
  • chat:write
  • commands

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:

  • Click Create Sandbox
  • Go to Import tab
  • Put https://github.com/seratch/bolt-starter in the textbox
  • Click Open Sandbox

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

In your own sandbox project, configure secrets as below:

  • SLACK_SIGNING_SECRET: Use the value you can find at Basic Information > App Credentials > Signing Secret
  • SLACK_BOT_TOKEN: Use the Bot User OAuth Access Token (starting with xoxb-) you can find at Settings > Install App

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.

  • Interactive Components: Turn on first, set the Request URL, and then click "Save Changes" button
  • Slash Commands: Add /open-modal command with the above URL for Reequest URL
  • Event Subscriptions: Turn on first, set the Request URL, add app_mention in Bot Events, and then click "Save Changes" button

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.

  • https://api.slack.com/apps/{APP_ID}/event-subscriptions
  • https://api.slack.com/apps/{APP_ID}/slash-commands
  • https://api.slack.com/apps/{APP_ID}/interactive-messages

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

  • Install nvm-windows from here
  • mvn list available to check the available versions
  • nvm install {latest LTS} (installing latest LTS version)

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 [email protected]: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:

  • https://api.slack.com/apps/{APP_ID}/slash-commands
  • https://api.slack.com/apps/{APP_ID}/event-subscriptions
  • https://api.slack.com/apps/{APP_ID}/interactive-messages

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

  • Command: /open-modal
  • request URL: https://{your-awesome-subdomain}.ngrok.io/slack/events
  • Short Description: whatever you like
  • Click "Save" for sure

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

  • app_mention

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.

  • Name: whatever you like
  • Short Description: whatever you like
  • Callback ID: open-modal
  • Click "Create"

Re-install the app to your workspace

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

License

The MIT License

bolt-starter's People

Contributors

dependabot[bot] avatar preshetin avatar seratch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bolt-starter's Issues

Would this work in Google Cloud Run

Hey @seratch, thank you for your Bolt templates! I had success with your GCF template, but unfortunately it bottlenecked because of so many API calls in my code. I think I would benefit from Cloud Run. Do you happen to have an example? Any help would greatly be appreciated. Thank you!

How to run socketmode in Google Cloud Run

Hey Seratch!
Thank you for your very helpful docker page. The docker image built beautifully, and runs locally like a dream. I have just have one question, how may I deploy this to Google Cloud Run in socket mode. Is this possible? It runs locally, but not when I try to deploy it. Do I have to create a reverse proxy to get around the PORT issue that the service tries to listen to? Any answers or insight into this would be very much be appreciated.

Thank you very much for your time and patience.

Have a wonderful day!

AppInitializationError: You must provide an appToken when socketMode is set to true

I set APP_TOKEN, BOT_TOKEN and SIGNING_SECRET in the env file. Getting this error.

AppInitializationError: You must provide an appToken when socketMode is set to true. To generate an appToken see: https://api.slack.com/apis/connections/socket#token
    at App.initReceiver (/project/slack_app/node_modules/@slack/bolt/dist/App.js:606:23)
    at new App (/project/slack_app/node_modules/@slack/bolt/dist/App.js:141:30)
    at Object.<anonymous> (/project/slack_app/socket-mode.js:26:13)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'slack_bolt_app_initialization_error'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.