Giter Club home page Giter Club logo

bot-api's Introduction

bot-api

FastAPI-based Python api for slack bots. Currently hosted on Heroku using Gunicorn/Uvicorn.

Setup

Clone the repo

Everything below is done in the root directory of the repo, so

cd bot-api

Set up a virtualenv and install requirements

python3.8 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Install the bot-api Python package

pip install -e .

Source environmental variables

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>

Test server

Start a test server

uvicorn bot_api.main:app --reload

Database

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.

Aditional information

  • 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.

Testing

From the repository's root directory

pytest

Deployment

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.

bot-api's People

Contributors

alexanfl avatar alexanderfleischer avatar mandus avatar

Watchers

Ola Skavhaug avatar  avatar

bot-api's Issues

Make `next` command display next scheduled event

The next command will only check if the next date in the calendar is scheduled, not find the actual next scheduled event. E.g., if we have the following calendar,

Thu 1 Jun (no event scheduled)
Wed 14 Jun (event scheduled)

/c next will respond with "No upcoming events.", which is a bit confusing. Should return the next scheduled event in this case.

Let the time of day be part of the `when` attribute of an event

As a user of the bot, I would like to be able to see the time of an event, not just the date. Usually, presentations are scheduled for 17:00, but that is not always the case.

This requires some larger changes to the backend, as the database entry for when is a date, not datetime. A user could always also add the date in the description (the what field).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.