webchat-audio-notifications
Browser audio notifications for webchat with 5 intensity levels, custom sounds, and smart tab detection.
Installation
npx clawhub@latest install webchat-audio-notificationsView the full skill documentation and source below.
Documentation
π Webchat Audio Notifications
Browser audio notifications for Moltbot/Clawdbot webchat. Plays a notification sound when new messages arrive - but only when the tab is in the background.
Features
- π Smart notifications - Only plays when tab is hidden
- ποΈ Volume control - Adjustable 0-100%
- π΅ 5 intensity levels - Whisper (1) to impossible-to-miss (5)
- π Custom sounds - Upload your own (MP3, WAV, OGG, WebM)
- π Easy toggle - Enable/disable with one click
- πΎ Persistent settings - Preferences saved in localStorage
- π± Mobile-friendly - Graceful degradation on mobile
- π« Autoplay handling - Respects browser policies
- β±οΈ Cooldown - Prevents spam (3s between alerts)
- π Debug mode - Optional logging
Quick Start
Test the POC
cd examples
python3 -m http.server 8080
# Open
Test steps:
Basic Integration
// Initialize
const notifier = new WebchatNotifications({
soundPath: './sounds',
soundName: 'level3', // Medium intensity (default)
defaultVolume: 0.7
});
await notifier.init();
// Trigger on new message
socket.on('message', () => notifier.notify());
// Use different levels for different events
socket.on('mention', () => {
notifier.setSound('level5'); // Loudest for mentions
notifier.notify();
});
API
Constructor Options
new WebchatNotifications({
soundPath: './sounds', // Path to sounds directory
soundName: 'level3', // level1 (whisper) to level5 (very loud)
defaultVolume: 0.7, // 0.0 to 1.0
cooldownMs: 3000, // Min time between alerts
enableButton: true, // Show enable prompt
debug: false // Console logging
});
Intensity Levels:
level1- Whisper (9.5KB) - Most subtlelevel2- Soft (12KB) - Gentlelevel3- Medium (13KB) - Defaultlevel4- Loud (43KB) - Attention-gettinglevel5- Very Loud (63KB) - Impossible to miss
Methods
init()- Initialize (call after Howler loads)notify(eventType?)- Trigger notification (only if tab hidden)test()- Play sound immediately (ignore tab state)setEnabled(bool)- Enable/disable notificationssetVolume(0-1)- Set volumesetSound(level)- Change intensity ('level1' through 'level5')getSettings()- Get current settings
Browser Compatibility
| Browser | Version | Support |
| Chrome | 92+ | β Full |
| Firefox | 90+ | β Full |
| Safari | 15+ | β Full |
| Mobile | Latest | β οΈ Limited |
File Structure
webchat-audio-notifications/
βββ client/
β βββ notification.js # Main class (10KB)
β βββ howler.min.js # Audio library (36KB)
β βββ sounds/
β βββ level1.mp3 # Whisper (9.5KB)
β βββ level2.mp3 # Soft (12KB)
β βββ level3.mp3 # Medium (13KB, default)
β βββ level4.mp3 # Loud (43KB)
β βββ level5.mp3 # Very Loud (63KB)
βββ examples/
β βββ test.html # Standalone test with all levels
βββ docs/
β βββ integration.md # Integration guide
βββ README.md # Full documentation
Integration Guide
See docs/integration.md for:
- Step-by-step setup
- Moltbot-specific hooks
- React/Vue examples
- Common patterns (@mentions, DND, badges)
- Testing checklist
Configuration Examples
Simple
const notifier = new WebchatNotifications();
await notifier.init();
notifier.notify();
Advanced
const notifier = new WebchatNotifications({
soundPath: '/assets/sounds',
soundName: 'level2', // Start with soft
defaultVolume: 0.8,
cooldownMs: 5000,
debug: true
});
await notifier.init();
// Regular messages = soft
socket.on('message', () => {
notifier.setSound('level2');
notifier.notify();
});
// Mentions = very loud
socket.on('mention', () => {
notifier.setSound('level5');
notifier.notify();
});
// DMs = loud
socket.on('dm', () => {
notifier.setSound('level4');
notifier.notify();
});
With UI Controls
<input type="range" min="0" max="100"
onchange="notifier.setVolume(this.value / 100)">
<button onclick="notifier.test()">Test π</button>
Troubleshooting
No sound?
- Click page first (autoplay restriction)
- Check tab is actually hidden
- Verify volume > 0
- Check console for errors
Sound plays when tab active?
- Enable debug mode
- Check for "Tab is visible, skipping" message
- Report as bug if missing
Mobile not working?
- iOS requires user gesture per play
- Consider visual fallback (flashing favicon)
Performance
- Bundle: ~122KB total (minified)
- Memory: ~2MB during playback
- CPU: Negligible (browser-native)
- Network: One-time download, cached
Security
- β No external requests
- β localStorage only
- β No tracking
- β No special permissions
Credits
- Audio library: [Howler.js]() (MIT)
- Sounds: [Mixkit.co]() (Royalty-free)
- For: [Moltbot/Clawdbot]() community
Contributing
examples/test.htmlRoadmap
- βWebM format (smaller files)
- βPer-event sounds (mention, DM, etc.)
- βVisual fallback (favicon flash)
- βSystem notifications API
- βSettings UI component
- βDo Not Disturb mode
Status: β
v1.1.0 Complete - 5 Intensity Levels
Tested: Chrome, Firefox, Safari
Ready for: Production use & ClawdHub publishing
Links
- π README - Full documentation
- π§ Integration Guide - Setup instructions
- π§ͺ Test Page - Try it yourself
- π¬ [Discord Thread]() - Community discussion