-
Notifications
You must be signed in to change notification settings - Fork 25
docs: add Slack CLI setup instructions to README.md #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c0e93b1
docs: add Slack CLI setup instructions to README
srtaalej 4a4e63e
chore: add project dependencies to pyproject.toml and remove requirem…
srtaalej 6baf485
fix: update README install command now that requirements.txt is removed
srtaalej b3a0352
chore: restore requirements.txt for CI compatibility
srtaalej cf2e5c2
chore: pin all dependencies and remove slack install step
srtaalej e05577f
chore: revert pyproject.toml to tool config only, keep requirements.t…
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,57 +2,121 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| This is a generic Bolt for Python template app used to build out Slack apps. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Before getting 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](https://slack.com/create). | ||||||||||||||||||||
| ## Setup | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Before getting 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](https://slack.com/create). | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Developer Program | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Join the [Slack Developer Program](https://api.slack.com/developer-program) for exclusive access to sandbox environments for building and testing your apps, tooling, and resources created to help you build and grow. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Installation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Create a Slack App | ||||||||||||||||||||
| <details><summary><strong>Using Slack CLI</strong></summary> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Install the latest version of the Slack CLI for your operating system: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - [Slack CLI for macOS & Linux](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-mac-and-linux/) | ||||||||||||||||||||
| - [Slack CLI for Windows](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-windows/) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| You'll also need to log in if this is your first time using the Slack CLI. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| slack login | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Initializing the project | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| slack create my-bolt-python-app --template slack-samples/bolt-python-starter-template | ||||||||||||||||||||
| cd my-bolt-python-app | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Creating the Slack app | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Use the following command to add your new Slack app to your development workspace. Choose a "local" app environment for upcoming development: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| slack install | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| After the Slack app has been created you're all set to start developing! | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🪓 question: Might we remove this in favor of the |
||||||||||||||||||||
| </details> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <details><summary><strong>Using Terminal</strong></summary> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Create Your Slack App | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 1. Open [https://api.slack.com/apps/new](https://api.slack.com/apps/new) and choose "From an app manifest" | ||||||||||||||||||||
| 2. Choose the workspace you want to install the application to | ||||||||||||||||||||
| 3. Copy the contents of [manifest.json](./manifest.json) into the text box that says `*Paste your manifest code here*` (within the JSON tab) and click *Next* | ||||||||||||||||||||
| 4. Review the configuration and click *Create* | ||||||||||||||||||||
| 5. Click *Install to Workspace* and *Allow* on the screen that follows. You'll then be redirected to the App Configuration dashboard. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Environment Variables | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Before you can run the app, you'll need to store some environment variables. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 1. Open your apps configuration page from this list, click **OAuth & Permissions** in the left hand menu, then copy the Bot User OAuth Token. You will store this in your environment as `SLACK_BOT_TOKEN`. | ||||||||||||||||||||
| 2. Click ***Basic Information** from the left hand menu and follow the steps in the App-Level Tokens section to create an app-level token with the `connections:write` scope. Copy this token. You will store this in your environment as `SLACK_APP_TOKEN`. | ||||||||||||||||||||
| 1. Open your apps configuration page from [this list](https://api.slack.com/apps), click **OAuth & Permissions** in the left hand menu, then copy the Bot User OAuth Token. You will store this in your environment as `SLACK_BOT_TOKEN`. | ||||||||||||||||||||
| 2. Click **Basic Information** from the left hand menu and follow the steps in the App-Level Tokens section to create an app-level token with the `connections:write` scope. Copy this token. You will store this in your environment as `SLACK_APP_TOKEN`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```zsh | ||||||||||||||||||||
| # Replace with your app token and bot token | ||||||||||||||||||||
| export SLACK_BOT_TOKEN=<your-bot-token> | ||||||||||||||||||||
| export SLACK_APP_TOKEN=<your-app-token> | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Setup Your Local Project | ||||||||||||||||||||
| ```zsh | ||||||||||||||||||||
| # Clone this project onto your machine | ||||||||||||||||||||
| git clone https://github.com/slack-samples/bolt-python-starter-template.git | ||||||||||||||||||||
| #### Initializing the project | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Change into this project directory | ||||||||||||||||||||
| cd bolt-python-starter-template | ||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| git clone https://github.com/slack-samples/bolt-python-starter-template.git my-bolt-python-app | ||||||||||||||||||||
| cd my-bolt-python-app | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Setup your python virtual environment | ||||||||||||||||||||
| #### Setup your python virtual environment | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| python3 -m venv .venv | ||||||||||||||||||||
| source .venv/bin/activate | ||||||||||||||||||||
| source .venv/bin/activate # for Windows OS, .\.venv\Scripts\Activate instead should work | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Install the dependencies | ||||||||||||||||||||
| #### Install dependencies | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| pip install -r requirements.txt | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Start your local server | ||||||||||||||||||||
| </details> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Development | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Starting the app | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Slack CLI | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| slack run | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Terminal | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```sh | ||||||||||||||||||||
| python3 app.py | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Linting | ||||||||||||||||||||
| ### Linting | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```zsh | ||||||||||||||||||||
| # Run ruff from root directory for linting | ||||||||||||||||||||
| ruff check . | ||||||||||||||||||||
| ruff check | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Run ruff from root directory for code formatting | ||||||||||||||||||||
| ruff format . | ||||||||||||||||||||
| ruff format | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Testing | ||||||||||||||||||||
| ### Testing | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```zsh | ||||||||||||||||||||
| # Run pytest from root directory for unit testing | ||||||||||||||||||||
| pytest . | ||||||||||||||||||||
|
|
@@ -70,15 +134,15 @@ pytest . | |||||||||||||||||||
|
|
||||||||||||||||||||
| ### `/listeners` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Every incoming request is routed to a "listener". Inside this directory, we group each listener based on the Slack Platform feature used, so `/listeners/shortcuts` handles incoming [Shortcuts](https://api.slack.com/interactivity/shortcuts) requests, `/listeners/views` handles [View submissions](https://api.slack.com/reference/interaction-payloads/views#view_submission) and so on. | ||||||||||||||||||||
| Every incoming request is routed to a "listener". Inside this directory, we group each listener based on the Slack Platform feature used, so `/listeners/shortcuts` handles incoming [Shortcuts](https://docs.slack.dev/interactivity/implementing-shortcuts/) requests, `/listeners/views` handles [View submissions](https://api.slack.com/reference/interaction-payloads/views#view_submission) and so on. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## App Distribution / OAuth | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Only implement OAuth if you plan to distribute your application across multiple workspaces. A separate `app_oauth.py` file can be found with relevant OAuth settings. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| When using OAuth, Slack requires a public URL where it can send requests. In this template app, we've used [`ngrok`](https://ngrok.com/download). Checkout [this guide](https://ngrok.com/docs#getting-started-expose) for setting it up. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Start `ngrok` to access the app on an external network and create a redirect URL for OAuth. | ||||||||||||||||||||
| Start `ngrok` to access the app on an external network and create a redirect URL for OAuth. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| ngrok http 3000 | ||||||||||||||||||||
|
|
||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪓 suggestion: We can perhaps remove this too! I found it confusing when searching for the first step to use this template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm i think we should keep for now.
loginis important for new user setup 💭