-
Notifications
You must be signed in to change notification settings - Fork 17
docs: add cli setup steps #26
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 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,64 +2,112 @@ | |
|
|
||
| This Bolt for Python template demonstrates how to build [AI Apps](https://docs.slack.dev/ai/) in Slack. | ||
|
|
||
| Models from [OpenAI](https://openai.com) are used and can be customized for prompts of all kinds. | ||
|
|
||
| ## 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 | ||
| 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. | ||
|
|
||
| ### Using Slack CLI | ||
|
|
||
| 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-assistant --template slack-samples/bolt-python-assistant-template | ||
| cd my-bolt-python-assistant | ||
| ``` | ||
|
|
||
| #### 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 configure the LLM provider! | ||
|
|
||
| ### Using Terminal | ||
|
|
||
| 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. | ||
| 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 | ||
| #### Environment Variables | ||
|
|
||
| Before you can run the app, you'll need to store some environment variables. | ||
|
|
||
|
|
||
| 1. Rename `.env.sample` to `.env`. | ||
| 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`. | ||
| ```zsh | ||
| ```sh | ||
| SLACK_BOT_TOKEN=YOUR_SLACK_BOT_TOKEN | ||
| ``` | ||
| 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`. | ||
| ```zsh | ||
| ```sh | ||
| SLACK_APP_TOKEN=YOUR_SLACK_APP_TOKEN | ||
| ``` | ||
| 4. Save your OpenAI key into `.env` under `OPENAI_API_KEY`. | ||
| ```zsh | ||
| OPENAI_API_KEY=YOUR_OPEN_API_KEY | ||
| ``` | ||
|
|
||
| #### Initializing the project | ||
|
|
||
| ### Setup Your Local Project | ||
| ```zsh | ||
| # Clone this project onto your machine | ||
| git clone https://github.com/slack-samples/bolt-python-assistant-template.git | ||
|
|
||
| # Change into this project directory | ||
| cd bolt-python-assistant-template | ||
| ```sh | ||
| git clone https://github.com/slack-samples/bolt-python-assistant-template.git my-bolt-python-assistant | ||
| cd my-bolt-python-assistant | ||
| ``` | ||
|
|
||
| # Setup your python virtual environment | ||
| #### Setup your python virtual environment | ||
| ```sh | ||
| python3 -m venv .venv | ||
| source .venv/bin/activate # for Windows OS, .\.venv\Scripts\Activate instead should work | ||
| ``` | ||
|
|
||
| # Install the dependencies | ||
| #### Install dependencies | ||
| ```sh | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| ## Providers | ||
| #### OpenAI Setup | ||
|
|
||
| # Start your local server | ||
| 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: | ||
| ```zsh | ||
| OPENAI_API_KEY=YOUR_OPEN_API_KEY | ||
| ``` | ||
| ### Development | ||
| #### Starting the app | ||
| ##### Slack CLI | ||
| ```sh | ||
| slack run | ||
| ``` | ||
| ##### Terminal | ||
| ```sh | ||
| python3 app.py | ||
| ``` | ||
|
|
||
| Start talking to the bot! Start a new DM or thread and click the feedback button when it responds. | ||
|
|
||
| #### Linting | ||
| ```zsh | ||
|
|
||
| ```sh | ||
| # Run ruff check from root directory for linting | ||
| ruff check | ||
|
|
||
|
|
@@ -85,11 +133,11 @@ Every incoming request is routed to a "listener". This directory groups each lis | |
|
|
||
| Configures the new Slack Assistant features, providing a dedicated side panel UI for users to interact with the AI chatbot. This module includes: | ||
|
|
||
| `assistant.py`, which contains two listeners: | ||
| * The `@assistant.thread_started` listener receives an event when users start new app thread. | ||
| * The `@assistant.user_message` listener processes user messages in app threads or from the app **Chat** and **History** tab. | ||
|
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. 📚 praise: Thanks for bringing improvement alongside these changes! |
||
| - The `assistant_thread_started.py` file, which responds to new app threads with a list of suggested prompts. | ||
| - 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. | ||
|
|
||
| `ai/llm_caller.py`, which handles OpenAI API integration and message formatting. It includes the `call_llm()` function that sends conversation threads to OpenAI's models. | ||
| ### `ai/` | ||
| 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. | ||
|
|
||
| ## App Distribution / OAuth | ||
|
|
||
|
|
||
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.
🐍 note: Additional steps are output related to setting up a virtual environment with the current version of this command. I think it's alright to not include these steps here with plans of enhancement upstream!