feat(notifications): add custom webhook notification provider
Summary
This PR introduces a new Custom notification provider that allows users to send notifications to any webhook endpoint via HTTP POST requests. This feature enables integration with custom services, internal tools, or any webhook-compatible platform not covered by the existing providers.
Features Added
Core Functionality
- Custom Webhook Provider: Send notifications to any HTTP endpoint
- Flexible Headers: Support for custom headers (Authorization, API keys, etc.)
- Template Variables: Full payload with notification data automatically sent as JSON
- Simple Configuration: Only requires webhook URL and optional headers
User Experience
- Intuitive UI: Clean form with webhook URL and key-value header input
- Test Connection: Built-in test functionality to validate webhook endpoints
- Icon Integration: Custom pen icon to represent the provider
Technical Implementation
- Database Schema: New
customtable with proper foreign key relationships - Backend Services: Full CRUD operations for custom notifications
- Type Safety: Complete TypeScript integration with Zod validation
- Error Handling: Comprehensive error handling and logging
Changes Made
Backend Changes
Database Schema (packages/server/src/db/schema/notification.ts)
- New
customtable withendpointandheadersfields - Updated
notificationTypeenum to include "custom" - Added foreign key relationship to notifications table
API Services (packages/server/src/services/notification.ts)
createCustomNotification()- Create new custom webhooksupdateCustomNotification()- Update existing custom webhooksfindNotificationById()- Updated to include custom relations
Notification Sender (packages/server/src/utils/notifications/utils.ts)
sendCustomNotification()- HTTP POST with JSON payload- Header parsing and template variable support
- Comprehensive error handling
tRPC Router (apps/dokploy/server/api/routers/notification.ts)
createCustom- API endpoint for creating custom notificationsupdateCustom- API endpoint for updating custom notificationstestCustomConnection- API endpoint for testing webhook endpoints
Frontend Changes
Form Integration (apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx)
- Added custom provider to notification schema
- Clean form with webhook URL and headers inputs
- Form validation and submission handling
Key-Value Component (apps/dokploy/components/dashboard/settings/notifications/key-value-input.tsx)
- Enable/disable toggles for each header
- Add/remove functionality with clean UX
UI Integration (apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx)
- Custom provider icon display
- Consistent styling with other providers
Integration Points
Custom notifications integrated into all existing notification types:
- Build success/failure notifications
- Database backup notifications
- Docker cleanup notifications
- Dokploy restart notifications
- Server threshold alerts
Use Cases
This feature enables users to:
- Internal Tools: Send notifications to company Slack alternatives, internal dashboards
- Custom Services: Integrate with proprietary monitoring systems
- Third-party APIs: Connect to services not officially supported
- Development Workflows: Hook into CI/CD pipelines, issue trackers
- Monitoring Integration: Connect to custom alerting systems
Example Payload
When a notification is triggered, the custom webhook receives a POST request with JSON payload:
{
"title": "Build Success",
"message": "Build completed successfully",
"projectName": "my-app",
"applicationName": "frontend",
"applicationType": "docker",
"timestamp": "2024-01-15T10:30:00.000Z",
"date": "1/15/2024, 10:30:00 AM",
"status": "success",
"type": "build"
}
Database Migration
- Migration
0113_keen_wasp.sqladds the custom table and enum value - Backward compatible - existing notifications unaffected
- Proper cascade deletion setup with foreign keys
- Run
dbml.tsscript to update database documentation
Checklist
- [x] Follows Conventional Commits format
- [x] Added comprehensive tests for new functionality
- [x] Updated database schema with proper migrations
- [x] Maintains backward compatibility
- [x] No breaking changes to existing APIs
- [x] TypeScript types properly defined
- [x] Error handling implemented
- [x] Code follows project style guidelines (Biome)
- [x] Integration with all existing notification trigger points
A little bump 👀
Bumping this
We could really use this feature since there is no Google Chat option!