Giter Site home page Giter Site logo

zoom-python-webhook's Introduction

Fast API Zoom Webhook handler

Python tests pre-commit codecov Deploy

This is a simple FastAPI app that handles Zoom Webhooks.

The goal of this app is to handle Zoom Webhooks and to provide a simple way to extend the app with custom handlers.


If you want to know more about the architecture of this app, you can read the architecture.md file.


Installation

$ git clone https://github.com/SamuelGuillemet/zoom-python-webhook.git

Requirements

  • Python >= 3.11
  • Poetry

How to configure the environment variables

The .env.sample file contains the list of all the environment variables that you can define.

Production

If your are in production mode, you can define the following variables in your .env.production file or directly in your environment variables:

  • ZOOM_WEBHOOK_SECRET_TOKEN : The secret token that you have defined in your Zoom App.

Development

If your are in development mode, you can define the following variables in your .env.development file:

  • ZOOM_WEBHOOK_SECRET_TOKEN : The secret token that you have defined in your Zoom App.

Usage

Production

There is a Dockerfile that you can use to build the image and run the app.

$ docker compose up -d --build

Development

Install dependencies and run the project

Poetry will take all the information on the pyproject.toml file and will install all its dependencoies.

You can install Poetry using the following command:

Linux or Mac:

$ curl -sSL https://install.python-poetry.org | python3 -

Windows:

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

Source: https://python-poetry.org/docs/#installing-with-the-official-installer

Then, you can install the dependencies with the following command:

Virtual environment if you use Conda

  1. Start the conda environment.
  2. Create a virtual environment under the .venv folder.
  3. Deactivate the conda environment.
$ conda activate your_env
$ python -m venv .venv
$ conda deactivate

Install the dependencies :

$ poetry install
$ source .venv/bin/activate # or poetry shell

Install the pre-commit Git hook

$ pre-commit install

Run the app

Then, you can run the app with the following command from the root folder:

$ uvicorn src.app.main:app --reload --reload-dir=./src/app

Supported events

  • endpoint.url_verification
  • zoomroom.checked_in
  • zoomroom.checked_out
  • zoomroom.sensor_data

How to add a new handler

  1. Create a new component in the src/app/components folder.
  2. The structure of the component should be the following:
└── your_component
         ├── __init__.py
         ├── handler.py
         └── schema.py
  1. In the handler.py file, you should create a new function that will handle the event. The function should be take the following arguments:
    • body (dict): The body of the request
  2. In the schema.py file, you should create 2 new Pydantic models:
    • The first model should be used to validate the body of the request.
    • The second model should be used to validate the response of the handler function.
  3. In the __init__.py file, you must put the following code:
from .handler import your_handler_function
from .schema import YourResponseSchema

event_name = "your.event.name"
handler_function = your_handler_function
response_model = YourResponseSchema
  1. All the components arle loaded dynamically in the src/app/api/v1/endpoints/webhook.py file.

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.