A simple app for sending notifications to multiple adapters.
High level view of the current implementation:
- python3 is installed
- nats server is installed and running
AUTH_TOKEN_URL="/api/auth/token"
AUTH_SECRET_KEY="secret_key"
AUTH_ALGORITHM="HS256"
AUTH_TOKEN_EXPIRY_MINUTES=30
SLACK_TOKEN=
TELEGRAM_BOT_TOKEN=
DATABASE_HOST="localhost"
DATABASE_PORT=3306
DATABASE_USER=
DATABASE_PASSWORD=
EMAIL_SMTP_HOST=
EMAIL_SMTP_PORT=
EMAIL_SMTP_USER=
EMAIL_SMTP_PASS=
EMAIL_USE_TLS=
EMAIL_USE_SES=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
python3 -m venv .venv
source .venv/bin/activate
PYTHONPATH=app uvicorn main:app
Send an HTTP Post request to http://<hostname>:<port>/api/notififcations/send like this example:
curl -X 'POST' \
'http://localhost:8000/api/notifications/send' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiaWQiOiIxIiwiZXhwIjoxNzUxNjMzMTM0fQ.T7s6hSGZvqYsVEBmbh5EvjGTjQ4LpuuPd9UpX-lW0jA' \
-H 'Content-Type: multipart/form-data' \
-F 'message={
"message": {
"title": "Title",
"body": "Body",
"footer": "Footer",
"fields": [
{
"label": "Label",
"value": "Value"
}
]
},
"targets": [
{
"channel": "slack",
"recipients": [
"C08TSGGFQM8"
],
"options": {}
}
]
}'
Note: Need to install nats cli tool first (brew install nats-io/nats-tools/nats)
nats pub notifications '{
"message": {
"title": "Hello",
"body": "This is a test message"
},
"targets": [
{
"channel": "email",
"recipients": ["user@example.com"]
},
{
"channel": "slack",
"recipients": [C08TSGGFQM8]
}
]
}'
