FastAPI-based Python api for slack bots. Currently hosted on Heroku using Gunicorn/Uvicorn.
Everything below is done in the root directory of the repo, so
cd bot-api
python3.8 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Install the bot-api Python package
pip install -e .
Fill out the variables below and add to a .env
file, then source .env
.
SLACK_SIGNING_SECRET=<from api.slack.com>
SLACK_BOT_TOKEN=<from api.slack.com>
DATABASE_URL=<from your hosted or local postgresql database>
Start a test server
uvicorn bot_api.main:app --reload
The current edition of the bot-api uses a free-tier PostgreSQL database from Heroku.
Setting up a postgres database is outside the scope of this readme.
The following therefore relies on a database already being set up,
and the DATABASE_URL
environmental variable being set correctly.
The postgres table (schedule of events) can be created with
python scripts/create_table.py
Add additional data using the following command
python yaml_to_db.py /path/to/schedules.yaml
It translates a .yaml
schedule and adds the schedule to the database.
See res/
for an example .yaml
file.
If you want to start with a blank calendar, just add events using the slack bot after it's set up.
Procfile
contains run instructions for a Gunicorn/Uvicorn server (currently hosted on Heroku).runtime.txt
specifies the Python version for Heroku.
After the uvicorn server has been started, visit the automated documentation. It also let's you test out the api endpoints.
From the repository's root directory
pytest
The API and the PostgreSQL database are both hosted on Heroku with a free license. Details on how to set up deployment may or may not be added at a later time.