A Knative function that receives CloudEvents and sends them to Slack. Built with FastAPI and uvicorn.
# Clone and setup
uv sync
# Optional: Configure Slack (function works without it)
cp .env.example .env
# Edit .env with your Slack webhook URL
# Run locally
uv run python func.pycurl -X POST http://localhost:8080/ \
-H "Content-Type: application/json" \
-H "ce-specversion: 1.0" \
-H "ce-type: com.example.test" \
-H "ce-source: test/source" \
-H "ce-id: 123" \
-d '{"message": "Hello CloudEvents!"}'# Build and run
docker build -t send-notification-to-slack .
docker run -p 8080:8080 send-notification-to-slack
# Or use pre-built image from GHCR
docker run -p 8080:8080 ghcr.io/mneagul/send-notification-to-slack:latest- Create a Slack app at https://api.slack.com/apps
- Enable "Incoming Webhooks"
- Set environment variables:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
SLACK_CHANNEL=#your-channel
SLACK_DATA_LIMIT=256 # Character limit for event data| Variable | Default | Description |
|---|---|---|
SLACK_WEBHOOK_URL |
None | Slack webhook URL (optional) |
SLACK_CHANNEL |
None | Override webhook default channel |
SLACK_USERNAME |
"CloudEvent Bot" | Bot username |
SLACK_ICON_EMOJI |
":cloud:" | Bot icon |
SLACK_DATA_LIMIT |
256 | Max characters for event data |
GET /health- Health checkGET /ready- Readiness checkPOST /- CloudEvent handler
# Update func.yaml with your registry
func deploy- Receives any CloudEvent type
- Optional Slack notifications with data truncation
- Health/readiness endpoints for Kubernetes
- Comprehensive logging
- Multi-platform Docker builds via GitHub Actions