Custom Notification Channels
Learn how to add custom notification channels like WhatsApp, SMS, or Telegram to WooNooW
WooNooW supports custom notification channels through a pluggable architecture. You can extend the notification system to send messages via WhatsApp, SMS, Telegram, or any other service.
Architecture Overview
The multi-channel notification system consists of three core components:
ChannelInterface- Contract that all channels must implementChannelRegistry- Central registry for managing channelsNotificationManager- Sends notifications through registered channels
Creating a Custom Channel
Step 1: Implement ChannelInterface
Create a class that implements WooNooW\Core\Notifications\Channels\ChannelInterface:
Step 2: Register Your Channel
Register your channel with the ChannelRegistry during plugin initialization:
Step 3: Enable in Settings
Once registered, your channel will be available in the notification settings UI, where users can configure which events should use WhatsApp.
Interface Reference
get_id()
Returns a unique identifier for your channel.
Example:
get_label()
Returns a human-readable label for the admin UI.
Example:
is_configured()
Checks if the channel has all required configuration (API keys, credentials, etc.).
Example:
send()
Sends a notification through this channel.
Parameters:
$event_id- Event identifier (e.g.,'order_completed','newsletter_confirm')$recipient- Recipient type ('customer'or'staff')$data- Context data including order, user, custom variables
Returns:
bool- Simple success/failurearray- Detailed result withsuccessandmessagekeys
Example:
get_config_fields()
Returns configuration fields for the admin settings UI (optional).
Field Structure:
Complete Example: WhatsApp Channel
See the reference implementation:
WhatsAppChannel.example.php
This example includes:
- ✅ Twilio API integration
- ✅ Phone number extraction from orders/users
- ✅ Message templates for common events
- ✅ Configuration fields for admin settings
Message Customization
Use filters to customize messages for specific events:
Available Events
Your channel can handle any registered notification event:
See Event Registry for the complete list.
Testing Your Channel
Best Practices
- Validate Configuration: Always check
is_configured()before attempting to send - Handle Errors Gracefully: Return detailed error messages for debugging
- Log Send Attempts: Use
do_action()for tracking/analytics - Support Filtering: Allow message customization via filters
- Rate Limiting: Consider implementing rate limiting for API calls
Hooks
Registration Hook
Custom Hooks in Your Channel
Troubleshooting
Channel not appearing in settings?
- Ensure
ChannelRegistry::register()is called duringinit - Check that
get_id()returns a unique string - Verify
is_configured()returnstrue
Messages not sending?
- Check notification settings: Marketing > Notifications
- Verify the event has your channel enabled
- Enable debug mode and check logs
- Test
is_configured()returns true
API errors?
- Validate API credentials in settings
- Check API provider status/quotas
- Review error logs for API responses
Related Documentation
Last updated Dec 12, 2025
