Skip to content

Self hosting

Christopher Martin edited this page Jul 23, 2021 · 3 revisions

Step 1: Slack and Dialogflow

To set up the necessary API dependencies for Classroom Assistant, refer to the following guides:

  1. Slack Application Setup
  2. Google Cloud Project and Dialogflow Agent Setup

Step 2: Environmental variables

After completing the above guides, you should be able to populate your .env file with the necessary API credentials. It should look something like the following:

DIALOGFLOW_PROJECT_ID=classroom-assistant
GOOGLE_APPLICATION_CREDENTIALS=path/to/credential/file.json

SLACK_CLIENT_ID=#############.#############
SLACK_CLIENT_SECRET=????????????????????????????????
SLACK_SIGNING_SECRET=????????????????????????????????

FLASK_APP=main.py
FLASK_ENV=production
FLASK_RUN_HOST=0.0.0.0
FLASK_RUN_PORT=3000

Step 3: Python virtual environment (Optional)

I recommend utilizing a Python virtual environment with venv to manage library dependencies, however, this step is not required. The various libraries used by Classroom Assistant can be installed globally. To create a project-specific version of Python and pip, run the following command inside the project's root directory.

python -m venv your_venv_name

After creating your virtual environment, you must "activate" it. To do so, run the following command on POSIX:

source your_venv_name/bin/activate

or the following on Windows:

source your_venv_name\Scripts\activate.bat

Your terminals prompt will change to indicate that you are now operating within the virtual environment.

Step 4: Installing dependencies

Classroom Assistant provides a requirements.txt file so installing its dependencies is super simple. You just need to run the following command:

pip install -r requirements.txt

Step 5: Running Classroom Assistant

Currently, Classroom Assistant is built using the Flask micro web framework. You can now start your self-hosted instance of Classroom Assistant by running the following command in the project's root directory:

flask run

Due to the limitations of Flask, the secure HTTPS requirement of Slack's slack/events endpoint may require a more robust setup if you are not using an SSL-certified domain. You could also rely on another host like Heroku. Follow my Hosting on Heroku if that sounds like the best option for you!