From f134b55a0870733dabd35c7a73cd276faa8a0d07 Mon Sep 17 00:00:00 2001 From: Ale Mercado Date: Fri, 3 Oct 2025 13:03:34 -0400 Subject: [PATCH 1/6] feat: add .env.sample template for environment configuration --- .env.sample | 5 +++++ .gitignore | 2 +- requirements.txt | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..a34db6b --- /dev/null +++ b/.env.sample @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index abc3d97..e5201c1 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ __pycache__/ env*/ venv/ .venv* -.env* +.env # codecov / coverage .coverage diff --git a/requirements.txt b/requirements.txt index 5cd8a51..c9fdbdb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ openai pytest flake8 black +python-dotenv \ No newline at end of file From cc8c98d1ec66ea9f251ba11490afb19a64dedbde Mon Sep 17 00:00:00 2001 From: Ale Mercado Date: Fri, 3 Oct 2025 13:23:21 -0400 Subject: [PATCH 2/6] docs: highlight .env.sample in readme --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0ff0b3c..bdd3cb5 100644 --- a/README.md +++ b/README.md @@ -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 + 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 = works -export SLACK_BOT_TOKEN= -export SLACK_APP_TOKEN= -# This sample uses OpenAI's API by default, but you can switch to any other solution! -export 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 +``` + ### Setup Your Local Project ```zsh From 0133ca9390b98aaae43515cb95b07db89f9ae9c3 Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Fri, 3 Oct 2025 13:29:23 -0700 Subject: [PATCH 3/6] fix: load env in app.py --- app.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.py b/app.py index fb7bccf..0c3f1e2 100644 --- a/app.py +++ b/app.py @@ -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) + # Initialization logging.basicConfig(level=logging.DEBUG) From a83e9543df86728dcb14d0e2080264150d77298d Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Mon, 6 Oct 2025 12:57:32 -0700 Subject: [PATCH 4/6] refactor: newline at end of file --- .env.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index a34db6b..ce5d7e4 100644 --- a/.env.sample +++ b/.env.sample @@ -2,4 +2,4 @@ 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 \ No newline at end of file +OPENAI_API_KEY=YOUR_OPENAI_API_KEY From 768569a734d32ef904876a6d55528d90731612d4 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Mon, 6 Oct 2025 12:57:52 -0700 Subject: [PATCH 5/6] fix: ignore all but the sample environment file --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e5201c1..a99f209 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,8 @@ __pycache__/ env*/ venv/ .venv* -.env +.env* +!.env.sample # codecov / coverage .coverage From b2e1834bee19e9b027fc848b32cb9f1388c3d4f1 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Mon, 6 Oct 2025 12:58:12 -0700 Subject: [PATCH 6/6] build: install a pinned version of dotenv --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c9fdbdb..76b1703 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ openai pytest flake8 black -python-dotenv \ No newline at end of file +python-dotenv==1.1.1