Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SLACK_APP_TOKEN=YOUR_SLACK_APP_TOKEN
SLACK_BOT_TOKEN=YOUR_SLACK_BOT_TOKEN
# SLACK_API_URL=YOUR_SLACK_API_URL
# This template uses OpenAI, but you can use any other provider!
OPENAI_API_KEY=YOUR_OPENAI_API_KEY
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env*/
venv/
.venv*
.env*
!.env.sample
Comment thread
srtaalej marked this conversation as resolved.

# codecov / coverage
.coverage
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ Join the [Slack Developer Program](https://api.slack.com/developer-program) for
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
Comment thread
srtaalej marked this conversation as resolved.

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

1. Open your app 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. 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
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
# Replace with your app token and bot token
# For Windows OS, env:SLACK_BOT_TOKEN = <your-bot-token> works
export SLACK_BOT_TOKEN=<your-bot-token>
export SLACK_APP_TOKEN=<your-app-token>
# This sample uses OpenAI's API by default, but you can switch to any other solution!
export OPENAI_API_KEY=<your-openai-api-key>
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
```
Comment thread
srtaalej marked this conversation as resolved.


### Setup Your Local Project
```zsh
Expand Down
5 changes: 5 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import os
import logging

from dotenv import load_dotenv

from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
from slack_sdk import WebClient

from listeners import register_listeners

# Load environment variables
load_dotenv(dotenv_path=".env", override=False)

Comment thread
srtaalej marked this conversation as resolved.
# Initialization
logging.basicConfig(level=logging.DEBUG)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ openai
pytest
flake8
black
python-dotenv==1.1.1
Comment thread
srtaalej marked this conversation as resolved.