├── .github ├── contributing.md ├── dependabot.yml ├── maintainers_guide.md └── pull_request_template.md ├── .gitignore ├── LICENSE ├── README.md ├── app.js ├── manifest.json └── package.json /.github/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributors Guide 2 | 3 | Interested in contributing? Awesome! Before you do though, please read our 4 | [Code of Conduct](https://slackhq.github.io/code-of-conduct). We take it very seriously, and expect that you will as 5 | well. 6 | 7 | There are many ways you can contribute! :heart: 8 | 9 | ### Bug Reports and Fixes :bug: 10 | - If you find a bug, please search for it in the [Issues](https://github.com/slackapi/bolt-js-getting-started-app/issues), and if it isn't already tracked, 11 | [create a new issue](https://github.com/slackapi/bolt-js-getting-started-app/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still 12 | be reviewed. 13 | - Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`. 14 | - Issues that are related to the examples apps will be labelled `area:examples`. 15 | - If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number. 16 | - Include tests that isolate the bug and verifies that it was fixed. 17 | 18 | ### New Features :bulb: 19 | - If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/slackapi/bolt-js-getting-started-app/issues/new). 20 | - Issues that have been identified as a feature request will be labelled `enhancement`. 21 | - Issues that are related to the examples apps will be labelled `area:examples`. 22 | - If you'd like to implement the new feature, please wait for feedback from the project 23 | maintainers before spending too much time writing the code. In some cases, `enhancement`s may 24 | not align well with the project objectives at the time. 25 | 26 | ### Tests :mag:, Documentation :books:, Miscellaneous :sparkles: 27 | - If you'd like to improve the tests, you want to make the documentation clearer, you have an 28 | alternative implementation of something that may have advantages over the way its currently 29 | done, or you have any other change, we would be happy to hear about it! 30 | - If its a trivial change, go ahead and [send a Pull Request](#creating_a_pull_request) with the changes you have in mind. 31 | - If not, [open an Issue](https://github.com/slackapi/bolt-js-getting-started-app/issues/new) to discuss the idea first. 32 | 33 | If you're new to our project and looking for some way to make your first contribution, look for 34 | Issues labelled `good first contribution`. 35 | 36 | ## Requirements 37 | 38 | For your contribution to be accepted: 39 | 40 | - [x] You must have signed the [Contributor License Agreement (CLA)](https://cla.salesforce.com/sign-cla). 41 | - [x] The test suite must be complete and pass. 42 | - [x] The changes must be approved by code review. 43 | - [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number. 44 | 45 | If the contribution doesn't meet the above criteria, you may fail our automated checks or a maintainer will discuss it with you. You can continue to improve a Pull Request by adding commits to the branch from which the PR was created. 46 | 47 | [Interested in knowing more about about pull requests at Slack?](https://slack.engineering/on-empathy-pull-requests-979e4257d158#.awxtvmb2z) 48 | 49 | ## Creating a Pull Request 50 | 51 | 1. :fork_and_knife: Fork the repository on GitHub. 52 | 2. :runner: Clone/fetch your fork to your local development machine. It's a good idea to run the tests just 53 | to make sure everything is in order. 54 | 3. :herb: Create a new branch and check it out. 55 | 4. :crystal_ball: Make your changes and commit them locally. Magic happens here! 56 | 5. :arrow_heading_up: Push your new branch to your fork. (e.g. `git push username fix-issue-16`). 57 | 6. :inbox_tray: Open a Pull Request on github.com from your new branch on your fork to `master` in this 58 | repository. 59 | 60 | ## Maintainers 61 | 62 | There are more details about processes and workflow in the [Maintainer's Guide](./maintainers_guide.md). 63 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/maintainers_guide.md: -------------------------------------------------------------------------------- 1 | # Maintainers Guide 2 | 3 | This document describes tools, tasks and workflow that one needs to be familiar with in order to effectively maintain 4 | this project. If you use this package within your own software as is but don't plan on modifying it, this guide is 5 | **not** for you. 6 | 7 | ## Tools 8 | 9 | All you need to work with this project is a supported version of [Node.js](https://nodejs.org/en/) 10 | (see [slackapi/bolt](https://github.com/slackapi/bolt-js/) `package.json` field "engines") and npm (which is distributed with Node.js). 11 | 12 | ## Tasks 13 | 14 | ### Updating 15 | 16 | This package is a dependency for our guides and other example apps. There are many ways to configure a sample app. We prefer to keep a single version of `app.js` which should be consistent with the instructions and code blocks on the [Bolt JS Getting Started guide](https://tools.slack.dev/bolt-js/getting-started/). This reduces the possibility of drift ocurring between multiple versions. 17 | 18 | When making changes to this repo, it's also important to keep all of our other guides and apps up-to-date. 19 | 20 | When updating this package, please ensure the following are also updated: 21 | 22 | - Guides found at [slackapi/bolt-js/docs/](https://github.com/slackapi/bolt-js/tree/main/docs) 23 | - Example apps at [slackapi/bolt-js/examples/getting-started-*](https://github.com/slackapi/bolt-js/tree/main/examples). 24 | 25 | ### Testing 26 | 27 | This package does not have unit tests but has implemented the command `npm test`. 28 | 29 | ### Releasing 30 | 31 | 1. Create the commit for the release: 32 | * Bump the version number in adherence to [Semantic Versioning](http://semver.org/) in `package.json`. 33 | * Update any dependency versions 34 | * Confirm tests pass by running `npm test` 35 | * Commit with a message including the new version number. For example `v2.2.0`. 36 | * Tag the commit with the version number. For example `git tag 2.2.0`. 37 | 38 | 2. Merge into main repository 39 | * Create a pull request with the commit that was just made. Be certain to include the tag. For 40 | example: `git push username main:rel-v1.0.8 && git push --tags username`. 41 | * Once tests pass and a reviewer has approved, merge the pull request. You will also want to 42 | update your local `main` branch. 43 | * Push the new tag up to origin `git push --tags origin`. 44 | 45 | 3. Distribute the release 46 | * At the moment this package is not distributed on npm. 47 | * It is only downloaded or cloned from GitHub. 48 | 49 | 4. (Slack Internal) Communicate the release internally. Include a link to the GitHub Release. 50 | 51 | 5. Announce on community.slack.com in #slack-api 52 | 53 | ## Workflow 54 | 55 | ### Versioning and Tags 56 | 57 | This project is versioned using [Semantic Versioning](http://semver.org/), particularly in the 58 | [npm flavor](https://docs.npmjs.com/getting-started/semantic-versioning). Each release is tagged 59 | using git. 60 | 61 | ### Fork 62 | 63 | As a maintainer, the development you do will be almost entirely off of your forked version of this package. The exception to this rule pertains to multiple collaborators working on the same feature, which is detailed in the **Branches** section below. 64 | 65 | ### Branches 66 | 67 | `main` is where active development occurs. 68 | 69 | When developing, branches should be created off of your fork and not directly off of this package. If working on a long-running feature and in collaboration with others, a corresponding branch of the same name is permitted. This makes collaboration on a single branch possible, as contributors working on the same feature cannot push commits to others' open Pull Requests. 70 | 71 | After a major version increment, there also may be maintenance branches created specifically for supporting older major versions. 72 | 73 | ### Issue Management 74 | 75 | All issues are managed under https://github.com/slackapi/bolt-js/issues. 76 | 77 | Use the label `area:examples` to organize issues related to this example app repository. 78 | 79 | ## Everything else 80 | 81 | When in doubt, find the other maintainers and ask. -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Summary 2 | 3 | Describe the goal of this pull request. Mention any related issue numbers from [slackapi/bolt-js/issues](https://github.com/slackapi/bolt-js/issues). 4 | 5 | ### Requirements (place an `x` in each `[ ]`) 6 | 7 | * [ ] I've read and understood the [Contributing Guidelines](https://github.com/slackapi/bolt-js-getting-started-app/blob/main/.github/contributing.md) and have done my best effort to follow them. 8 | * [ ] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct). 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node / npm 2 | node_modules/ 3 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Slack Technologies, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started ⚡️ Bolt for JavaScript 2 | 3 | > Slack app example from 📚 [Getting started with Bolt for JavaScript tutorial][1] 4 | 5 | ## Overview 6 | 7 | This is a Slack app built with the [Bolt for JavaScript framework][2] that showcases 8 | responding to events and interactive buttons. 9 | 10 | ## Running locally 11 | 12 | ### 0. Create a new Slack App 13 | 14 | - Go to https://api.slack.com/apps 15 | - Click **Create App** 16 | - Choose a workspace 17 | - Enter App Manifest using contents of `manifest.json` 18 | - Click **Create** 19 | 20 | Once the app is created click **Install to Workspace** 21 | Then scroll down in Basic Info and click **Generate Token and Scopes** with both scopes 22 | 23 | ### 1. Setup environment variables 24 | 25 | ```zsh 26 | # Replace with your bot and app token 27 | export SLACK_BOT_TOKEN= # from the OAuth section 28 | export SLACK_APP_TOKEN= # from the Basic Info App Token Section 29 | ``` 30 | 31 | ### 2. Setup your local project 32 | 33 | ```zsh 34 | # Clone this project onto your machine 35 | git clone https://github.com/slackapi/bolt-js-getting-started-app.git 36 | 37 | # Change into the project 38 | cd bolt-js-getting-started-app/ 39 | 40 | # Install the dependencies 41 | npm install 42 | ``` 43 | 44 | ### 3. Start servers 45 | 46 | ```zsh 47 | npm run start 48 | ``` 49 | 50 | ### 4. Test 51 | 52 | Go to the installed workspace and type **Hello** in a DM to your new bot. You can also type **Hello** in a channel where the bot is present 53 | 54 | ## Contributing 55 | 56 | ### Issues and questions 57 | 58 | Found a bug or have a question about this project? We'd love to hear from you! 59 | 60 | 1. Browse to [slackapi/bolt-js/issues][4] 61 | 1. Create a new issue 62 | 1. Select the `[x] examples` category 63 | 64 | See you there and thanks for helping to improve Bolt for everyone! 65 | 66 | [1]: https://tools.slack.dev/bolt-js/getting-started 67 | [2]: https://tools.slack.dev/bolt-js/ 68 | [3]: https://tools.slack.dev/bolt-js/getting-started/#setting-up-events 69 | [4]: https://github.com/slackapi/bolt-js/issues/new/choose 70 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const { App } = require('@slack/bolt'); 2 | 3 | /** 4 | * This sample slack application uses SocketMode. 5 | * For the companion getting started setup guide, see: 6 | * https://tools.slack.dev/bolt-js/getting-started/ 7 | */ 8 | 9 | // Initializes your app with your bot token and app token 10 | const app = new App({ 11 | token: process.env.SLACK_BOT_TOKEN, 12 | socketMode: true, 13 | appToken: process.env.SLACK_APP_TOKEN 14 | }); 15 | 16 | // Listens to incoming messages that contain "hello" 17 | app.message('hello', async ({ message, say }) => { 18 | // say() sends a message to the channel where the event was triggered 19 | await say({ 20 | blocks: [ 21 | { 22 | "type": "section", 23 | "text": { 24 | "type": "mrkdwn", 25 | "text": `Hey there <@${message.user}>!` 26 | }, 27 | "accessory": { 28 | "type": "button", 29 | "text": { 30 | "type": "plain_text", 31 | "text": "Click Me" 32 | }, 33 | "action_id": "button_click" 34 | } 35 | } 36 | ], 37 | text: `Hey there <@${message.user}>!` 38 | }); 39 | }); 40 | 41 | app.action('button_click', async ({ body, ack, say }) => { 42 | // Acknowledge the action 43 | await ack(); 44 | await say(`<@${body.user.id}> clicked the button`); 45 | }); 46 | 47 | (async () => { 48 | // Start your app 49 | await app.start(process.env.PORT || 3000); 50 | 51 | app.logger.info('⚡️ Bolt app is running!'); 52 | })(); 53 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "display_information": { 3 | "name": "Getting Started Bolt App" 4 | }, 5 | "features": { 6 | "app_home": { 7 | "home_tab_enabled": false, 8 | "messages_tab_enabled": true, 9 | "messages_tab_read_only_enabled": false 10 | }, 11 | "bot_user": { 12 | "display_name": "BoltApp", 13 | "always_online": true 14 | } 15 | }, 16 | "oauth_config": { 17 | "scopes": { 18 | "bot": ["channels:history", "chat:write", "im:history"] 19 | } 20 | }, 21 | "settings": { 22 | "event_subscriptions": { 23 | "bot_events": ["message.channels", "message.im"] 24 | }, 25 | "interactivity": { 26 | "is_enabled": true 27 | }, 28 | "org_deploy_enabled": false, 29 | "socket_mode_enabled": true, 30 | "token_rotation_enabled": false 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bolt-js-getting-started-app", 3 | "version": "2.0.0", 4 | "description": "Getting Started ⚡️ Bolt for JavaScript", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "license": "MIT", 11 | "dependencies": { 12 | "@slack/bolt": "^4.2.0" 13 | } 14 | } 15 | --------------------------------------------------------------------------------