Usage π
Learn how to make the most of the Dynamic Notification System by adding new notification channels and scheduling notifications.
Adding New Notification Channels π
The system supports a plugin-based architecture for notification channels. Hereβs how to add a new channel:
-
Create a Go Plugin:
-
Develop a Go plugin that implements the
Notifier
interface: -
Example:
-
-
Compile the Plugin:
- Use the following command to compile your Go plugin:
-
Add the Plugin to the Directory:
- Place the compiled
.so
file into theplugins/
directory.
- Place the compiled
-
Update
config.yaml
:- Add the new channel configuration to
config.yaml
. Example:
- Add the new channel configuration to
-
Restart the Application:
- Restart the application to load the new plugin:
Scheduling Notifications ποΈ
The scheduler enables you to define and automate notification jobs.
Using the /jobs
API Endpoint
You can define and schedule jobs directly via the HTTP API.
-
POST /jobs:
- Use the
/jobs
endpoint to create a new job. Example request:
- Use the
-
Verify the Job:
- Check the response to confirm the job is created:
-
Scheduler Execution:
- The scheduler will execute the job at the defined time based on the cron expression.
Advanced Usage βοΈ
Editing Jobs:
- Modify job details directly via the database or through future API endpoints:
Deleting Jobs:
- Remove a job from the schedule:
Examples β¨
Example: Adding a Slack Notification Job
-
Add a Slack plugin using the steps above.
-
Use the
/jobs
API endpoint to add a Slack notification job:curl -X POST http://localhost:8080/jobs \ -H "Content-Type: application/json" \ -d '{ "name": "Team Standup Reminder", "notification_type": "slack", "recipient": "#general", "message": { "title": "Standup Reminder", "message": "Daily standup in 10 minutes!" }, "schedule_expression": "30 8 * * 1-5" }'
-
Verify execution:
- The message will be sent to the
#general
Slack channel at 8:30 AM, Monday to Friday.
- The message will be sent to the
Enjoy using the Dynamic Notification System to streamline your notifications! π