This webhook provides APIs mostly related to SeaTalk group notification based on SeaTalk Open Platform and Python FastAPI.
FastAPI is faster compare to Flask, and it automatically generates 2 interactive API documentation user interfaces(Swagger UI and Redoc).
- Send markdown message to SeaTalk group chat
- Prometheus/Grafana alert send to SeaTalk group chat
- Prometheus/Grafana alert sent to both SeaTalk group chat and outbound voice call based on Vonage, this is a on-all duty feature
- Send pure outbound voice call based on Vonage, this is not related to SeaTalk
- Voice call is based on Vonage, you need to provide credentials as environment variables
- Prometheus/Grafana alert send to voice call is based on Google calendar API, oncall schedule is managed in Google calendar as event
Support both Virtualenv
and Docker
Suggest using Virtualenv for local debugging.
- Install Python 3.9.6
- Install virtualenv
$ cd seatalk-webhook
# activate virtualenv
$ source venv/bin/activate
$ (venv) % pip install -r requirements.txt
$ (venv) % python -m uvicorn app.main:app --reload --host 0.0.0.0
INFO: Will watch for changes in these directories:['xxxxxxxxxxxxxxxxxxxxx']
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started reloader process [19201] using WatchFiles
INFO: Started server process [19203]
INFO: Waiting for application startup.
INFO: Application startup complete.
1.Build docker image
cd seatalk-webhook
docker build -t seatalk-webhook:1.0 .
2.Prepare credential files for Google Calendar API, please follow the Google Developer Guide
ls /etc/webhook/oncall/
credentials.json private.key token.pickle
3.Other configurations please modify the docker-compose.yml
, an example as below.
version: "2.2"
services:
webhook:
image: seatalk-webhook:1.0
hostname: seatalk-webhook
container_name: seatalk-webhook
restart: always
ports:
- "8000:80"
environment:
- agents={"Sherry":{"mobile":"6512345678","email":"[email protected]"}, "Andy":{"mobile":"6523456789","email":"[email protected]"}}
- dba_duty_cal=garena.com_xxxxxxxxxxxxxxxxx@group.calendar.google.com
- vonage_application_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- vonage_number=120xxxxx532
volumes:
- /etc/webhook/oncall:/etc/app:rw
- agents: agent name must match the event name in Google Calendar
- email: used for SeaTalk group mention
- mobile: used for voice call alert, must start with country code, eg: 65xxxxxxxx
- dba_duty_cal: google calender ID for oncall schedule
- vonage_application_id: vonage voice call application id
- vonage_number: vonage voice call number
4.Start webhook
./start.sh
or
docker-compose up -d
You can use test_main.http