PauseAI / ProjectBot

A python bot that does project tracking from a discord server to a notion database
2 stars 3 forks source link

ProjectBot

This repository contains a python script running a Discord bot that fetches information from messages in forum channels and creates corresponding entries in a Notion database. It's designed to help with project management, allowing users to quickly transfer and track project details from Discord discussions to a structured Notion database.

Prerequisites

Before you begin, ensure you have the following:

Setup

  1. Clone the Repository

Clone this repository to your local machine using:

git clone <repository-url>
cd <repository-directory>
  1. Set up Linter

If you're using VSCode, you should see a popup the first time you open the workspace asking you to install recommended workspace extensions. If not, install the equivalent extensions for your IDE.

The extension is all you'll need to see yellow warning squiggles in your editor, but if you'd like to run the linter from the command line as well, instructions to install it are here: https://docs.astral.sh/ruff/installation/.

Currently, lint violations are not enforced on pull requests, but that may change in the future. Please try to avoid introducing new violations.

The configuration for Ruff can be found in ruff.toml.

  1. Create Conda Environment

Create a new Conda environment using the environment.yml file included in the project:

conda env create -f environment.yml

This will create a new environment named projectbot with all the necessary Python dependencies installed.

  1. Activate the Environment

Activate the newly created Conda environment:

conda activate projectbot
  1. Configure Secrets

Create a secrets.yml file in the project directory with your Discord bot token and Notion integration details:

DISCORD_BOT_SECRET:
  staging: "YOUR_DISCORD_BOT_TOKEN_FOR_TESTING"
  prod: "YOUR_DISCORD_BOT_TOKEN_FOR_PRODUCTION"
AIRTABLE_TOKEN:
  staging: "YOUR_AIRTABLE_TOKEN_FOR_TESTING"
  prod: "YOUR_AIRTABLE_TOKEN_FOR_PRODUCTION"
OPENAI_API_KEY:
  staging: "YOUR_OPENAI_API_KEY_FOR_TESTING"
  prod: "YOUR_OPENAI_API_KEY_FOR_PRODUCTION"

Make sure to replace the placeholders with your actual tokens and IDs.

Running the Bot Locally

  1. Start the Bot

With the Conda environment activated and the secrets configured, start the bot by running:

python main.py
  1. Using the Bot

Deployment

To deploy the bot on Heroku, follow these steps:

  1. Install the Heroku CLI by following the instructions here.
  2. Log in to your Heroku account using the CLI:
heroku login
  1. Create a new Heroku app:
heroku create <app-name>
  1. Set the environment variables on Heroku using the secrets from your secrets.yml file:
heroku config:set DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN
heroku config:set NOTION_INTEGRATION_TOKEN=YOUR_NOTION_INTEGRATION_TOKEN
heroku config:set NOTION_DATABASE_ID=YOUR_NOTION_DATABASE_ID
heroku config:set AIRTABLE_API_KEY=YOUR_AIRTABLE_API_KEY
heroku config:set AIRTABLE_BASE_ID=YOUR_AIRTABLE_BASE_ID
  1. Push the code to Heroku:
git push heroku main
  1. Start the bot on Heroku:
heroku ps:scale worker=1

Your bot should now be running on Heroku.

Notes