Skip to content

Commit 821be94

Browse files
authored
docs: add Slack CLI setup instructions to README.md (#80)
1 parent 03d24f2 commit 821be94

1 file changed

Lines changed: 76 additions & 20 deletions

File tree

README.md

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,113 @@
22

33
This is a generic Bolt for Python template app used to build out Slack apps.
44

5-
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).
5+
## Setup
6+
7+
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).
8+
9+
### Developer Program
10+
11+
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.
12+
613
## Installation
714

8-
#### Create a Slack App
15+
<details><summary><strong>Using Slack CLI</strong></summary>
16+
17+
Install the latest version of the Slack CLI for your operating system:
18+
19+
- [Slack CLI for macOS & Linux](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-mac-and-linux/)
20+
- [Slack CLI for Windows](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-windows/)
21+
22+
You'll also need to log in if this is your first time using the Slack CLI.
23+
24+
```sh
25+
slack login
26+
```
27+
28+
#### Initializing the project
29+
30+
```sh
31+
slack create my-bolt-python-app --template slack-samples/bolt-python-starter-template
32+
cd my-bolt-python-app
33+
```
34+
35+
After cloning, you're all set to start developing!
36+
37+
</details>
38+
39+
<details><summary><strong>Using Terminal</strong></summary>
40+
41+
#### Create Your Slack App
42+
943
1. Open [https://api.slack.com/apps/new](https://api.slack.com/apps/new) and choose "From an app manifest"
1044
2. Choose the workspace you want to install the application to
1145
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*
1246
4. Review the configuration and click *Create*
1347
5. Click *Install to Workspace* and *Allow* on the screen that follows. You'll then be redirected to the App Configuration dashboard.
1448

1549
#### Environment Variables
50+
1651
Before you can run the app, you'll need to store some environment variables.
1752

18-
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`.
19-
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`.
53+
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`.
54+
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`.
2055

2156
```zsh
2257
# Replace with your app token and bot token
2358
export SLACK_BOT_TOKEN=<your-bot-token>
2459
export SLACK_APP_TOKEN=<your-app-token>
2560
```
2661

27-
### Setup Your Local Project
28-
```zsh
29-
# Clone this project onto your machine
30-
git clone https://github.com/slack-samples/bolt-python-starter-template.git
62+
#### Initializing the project
63+
64+
```sh
65+
git clone https://github.com/slack-samples/bolt-python-starter-template.git my-bolt-python-app
66+
cd my-bolt-python-app
67+
```
3168

32-
# Change into this project directory
33-
cd bolt-python-starter-template
69+
#### Setup your python virtual environment
3470

35-
# Setup your python virtual environment
71+
```sh
3672
python3 -m venv .venv
37-
source .venv/bin/activate
73+
source .venv/bin/activate # for Windows OS, .\.venv\Scripts\Activate instead should work
74+
```
75+
76+
#### Install dependencies
3877

39-
# Install the dependencies
78+
```sh
4079
pip install -r requirements.txt
80+
```
81+
82+
</details>
4183

42-
# Start your local server
84+
## Development
85+
86+
### Starting the app
87+
88+
#### Slack CLI
89+
90+
```sh
91+
slack run
92+
```
93+
94+
#### Terminal
95+
96+
```sh
4397
python3 app.py
4498
```
4599

46-
#### Linting
100+
### Linting
101+
47102
```zsh
48103
# Run ruff from root directory for linting
49-
ruff check .
104+
ruff check
50105

51106
# Run ruff from root directory for code formatting
52-
ruff format .
107+
ruff format
53108
```
54109

55-
#### Testing
110+
### Testing
111+
56112
```zsh
57113
# Run pytest from root directory for unit testing
58114
pytest .
@@ -70,15 +126,15 @@ pytest .
70126

71127
### `/listeners`
72128

73-
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.
129+
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.
74130

75131
## App Distribution / OAuth
76132

77133
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.
78134

79135
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.
80136

81-
Start `ngrok` to access the app on an external network and create a redirect URL for OAuth.
137+
Start `ngrok` to access the app on an external network and create a redirect URL for OAuth.
82138

83139
```
84140
ngrok http 3000

0 commit comments

Comments
 (0)