Skip to content

Commit c0e93b1

Browse files
committed
docs: add Slack CLI setup instructions to README
1 parent 03d24f2 commit c0e93b1

1 file changed

Lines changed: 84 additions & 20 deletions

File tree

README.md

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,121 @@
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+
#### Creating the Slack app
36+
37+
Use the following command to add your new Slack app to your development workspace. Choose a "local" app environment for upcoming development:
38+
39+
```sh
40+
slack install
41+
```
42+
43+
After the Slack app has been created you're all set to start developing!
44+
45+
</details>
46+
47+
<details><summary><strong>Using Terminal</strong></summary>
48+
49+
#### Create Your Slack App
50+
951
1. Open [https://api.slack.com/apps/new](https://api.slack.com/apps/new) and choose "From an app manifest"
1052
2. Choose the workspace you want to install the application to
1153
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*
1254
4. Review the configuration and click *Create*
1355
5. Click *Install to Workspace* and *Allow* on the screen that follows. You'll then be redirected to the App Configuration dashboard.
1456

1557
#### Environment Variables
58+
1659
Before you can run the app, you'll need to store some environment variables.
1760

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`.
61+
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`.
62+
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`.
2063

2164
```zsh
2265
# Replace with your app token and bot token
2366
export SLACK_BOT_TOKEN=<your-bot-token>
2467
export SLACK_APP_TOKEN=<your-app-token>
2568
```
2669

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
70+
#### Initializing the project
3171

32-
# Change into this project directory
33-
cd bolt-python-starter-template
72+
```sh
73+
git clone https://github.com/slack-samples/bolt-python-starter-template.git my-bolt-python-app
74+
cd my-bolt-python-app
75+
```
3476

35-
# Setup your python virtual environment
77+
#### Setup your python virtual environment
78+
79+
```sh
3680
python3 -m venv .venv
37-
source .venv/bin/activate
81+
source .venv/bin/activate # for Windows OS, .\.venv\Scripts\Activate instead should work
82+
```
3883

39-
# Install the dependencies
84+
#### Install dependencies
85+
86+
```sh
4087
pip install -r requirements.txt
88+
```
4189

42-
# Start your local server
90+
</details>
91+
92+
## Development
93+
94+
### Starting the app
95+
96+
#### Slack CLI
97+
98+
```sh
99+
slack run
100+
```
101+
102+
#### Terminal
103+
104+
```sh
43105
python3 app.py
44106
```
45107

46-
#### Linting
108+
### Linting
109+
47110
```zsh
48111
# Run ruff from root directory for linting
49-
ruff check .
112+
ruff check
50113

51114
# Run ruff from root directory for code formatting
52-
ruff format .
115+
ruff format
53116
```
54117

55-
#### Testing
118+
### Testing
119+
56120
```zsh
57121
# Run pytest from root directory for unit testing
58122
pytest .
@@ -70,15 +134,15 @@ pytest .
70134

71135
### `/listeners`
72136

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.
137+
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.
74138

75139
## App Distribution / OAuth
76140

77141
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.
78142

79143
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.
80144

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

83147
```
84148
ngrok http 3000

0 commit comments

Comments
 (0)