diff --git a/README.md b/README.md index 48acdfd..c726123 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,44 @@ 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 +
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-app --template slack-samples/bolt-python-starter-template +cd my-bolt-python-app +``` + +After cloning, you're all set to start developing! + +
+ +
Using Terminal + +#### 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* @@ -13,10 +47,11 @@ Before getting started, make sure you have a development workspace where you hav 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 @@ -24,35 +59,56 @@ export SLACK_BOT_TOKEN= export SLACK_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 + +```sh +git clone https://github.com/slack-samples/bolt-python-starter-template.git my-bolt-python-app +cd my-bolt-python-app +``` -# Change into this project directory -cd bolt-python-starter-template +#### 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 dependencies -# Install the dependencies +```sh pip install -r requirements.txt +``` + +
-# Start your local server +## 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,7 +126,7 @@ 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 @@ -78,7 +134,7 @@ Only implement OAuth if you plan to distribute your application across multiple 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