Skip to content

Commit efd12d6

Browse files
srtaalejzimeg
andauthored
docs: add cli setup steps (#26)
Co-authored-by: Eden Zimbelman <[email protected]>
1 parent 31ed430 commit efd12d6

File tree

1 file changed

+87
-24
lines changed

1 file changed

+87
-24
lines changed

README.md

Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,126 @@
22

33
This Bolt for Python template demonstrates how to build [AI Apps](https://docs.slack.dev/ai/) in Slack.
44

5+
Models from [OpenAI](https://openai.com) are used and can be customized for prompts of all kinds.
6+
57
## Setup
8+
69
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).
710

811
### Developer Program
12+
913
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.
1014

1115
## Installation
1216

13-
#### Create a Slack App
17+
Add this app to your workspace using either the Slack CLI or other development tooling, then read ahead to configuring LLM responses in the **[Providers](#providers)** section.
18+
19+
### Using Slack CLI
20+
21+
Install the latest version of the Slack CLI for your operating system:
22+
23+
- [Slack CLI for macOS & Linux](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-mac-and-linux/)
24+
- [Slack CLI for Windows](https://docs.slack.dev/tools/slack-cli/guides/installing-the-slack-cli-for-windows/)
25+
26+
You'll also need to log in if this is your first time using the Slack CLI.
27+
28+
```sh
29+
slack login
30+
```
31+
32+
#### Initializing the project
33+
34+
```sh
35+
slack create my-bolt-python-assistant --template slack-samples/bolt-python-assistant-template
36+
cd my-bolt-python-assistant
37+
```
38+
39+
#### Creating the Slack app
40+
41+
Use the following command to add your new Slack app to your development workspace. Choose a "local" app environment for upcoming development:
42+
43+
```sh
44+
slack install
45+
```
46+
47+
After the Slack app has been created you're all set to configure the LLM provider!
48+
49+
### Using Terminal
50+
1451
1. Open [https://api.slack.com/apps/new](https://api.slack.com/apps/new) and choose "From an app manifest"
1552
2. Choose the workspace you want to install the application to
16-
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*
17-
4. Review the configuration and click *Create*
18-
5. Click *Install to Workspace* and *Allow* on the screen that follows. You'll then be redirected to the App Configuration dashboard.
53+
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_
54+
4. Review the configuration and click _Create_
55+
5. Click _Install to Workspace_ and _Allow_ on the screen that follows. You'll then be redirected to the App Configuration dashboard.
1956

20-
### Environment Variables
57+
#### Environment Variables
2158

2259
Before you can run the app, you'll need to store some environment variables.
2360

24-
2561
1. Rename `.env.sample` to `.env`.
2662
2. Open your apps setting page from [this list](https://api.slack.com/apps), click _OAuth & Permissions_ in the left hand menu, then copy the _Bot User OAuth Token_ into your `.env` file under `SLACK_BOT_TOKEN`.
27-
```zsh
63+
64+
```sh
2865
SLACK_BOT_TOKEN=YOUR_SLACK_BOT_TOKEN
2966
```
67+
3068
3. 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 that token into your `.env` as `SLACK_APP_TOKEN`.
31-
```zsh
69+
70+
```sh
3271
SLACK_APP_TOKEN=YOUR_SLACK_APP_TOKEN
3372
```
34-
4. Save your OpenAI key into `.env` under `OPENAI_API_KEY`.
35-
```zsh
36-
OPENAI_API_KEY=YOUR_OPEN_API_KEY
37-
```
3873

74+
#### Initializing the project
3975

40-
### Setup Your Local Project
41-
```zsh
42-
# Clone this project onto your machine
43-
git clone https://github.com/slack-samples/bolt-python-assistant-template.git
76+
```sh
77+
git clone https://github.com/slack-samples/bolt-python-assistant-template.git my-bolt-python-assistant
78+
cd my-bolt-python-assistant
79+
```
4480

45-
# Change into this project directory
46-
cd bolt-python-assistant-template
81+
#### Setup your python virtual environment
4782

48-
# Setup your python virtual environment
83+
```sh
4984
python3 -m venv .venv
5085
source .venv/bin/activate # for Windows OS, .\.venv\Scripts\Activate instead should work
86+
```
5187

52-
# Install the dependencies
88+
#### Install dependencies
89+
90+
```sh
5391
pip install -r requirements.txt
92+
```
93+
94+
## Providers
95+
96+
### OpenAI Setup
97+
98+
Unlock the OpenAI models from your OpenAI account dashboard by clicking [create a new secret key](https://platform.openai.com/api-keys), then save your OpenAI key into the `.env` file as `OPENAI_API_KEY` like so:
99+
100+
```zsh
101+
OPENAI_API_KEY=YOUR_OPEN_API_KEY
102+
```
103+
104+
## Development
105+
106+
### Starting the app
107+
108+
#### Slack CLI
54109

55-
# Start your local server
110+
```sh
111+
slack run
112+
```
113+
114+
#### Terminal
115+
116+
```sh
56117
python3 app.py
57118
```
58119

59120
Start talking to the bot! Start a new DM or thread and click the feedback button when it responds.
60121

61-
#### Linting
62-
```zsh
122+
### Linting
123+
124+
```sh
63125
# Run ruff check from root directory for linting
64126
ruff check
65127

@@ -88,7 +150,8 @@ Configures the new Slack Assistant features, providing a dedicated side panel UI
88150
- The `assistant_thread_started.py` file, which responds to new app threads with a list of suggested prompts.
89151
- The `message.py` file, which responds to user messages sent to app threads or from the **Chat** and **History** tab with an LLM generated response.
90152

91-
### `ai/`
153+
### `/ai`
154+
92155
The `llm_caller.py` file, which handles OpenAI API integration and message formatting. It includes the `call_llm()` function that sends conversation threads to OpenAI's models.
93156

94157
## App Distribution / OAuth

0 commit comments

Comments
 (0)