A simple tool that monitors room occupancy via the Density.io API and sends Slack notifications when thresholds are met.
# No dependencies needed - pure Node.js
node server.jsThen open http://localhost:3847 in your browser.
- Log into your Density dashboard
- Go to Settings → API
- Copy your API token
See the Density API documentation for more details.
- Go to Slack API: Incoming Webhooks
- Click Create your Slack app (or use an existing app)
- Enable Incoming Webhooks
- Click Add New Webhook to Workspace
- Select the channel where you want notifications
- Copy the webhook URL (looks like
https://hooks.slack.com/services/...)
- Start the server:
node server.js - Open http://localhost:3847
- Enter your Density API token and Slack webhook URL
- Click Connect & Load Spaces
- Select a space, set your threshold (e.g., "3 or more people")
- Set the duration (e.g., "for 1 minute") and cooldown
- Click Add Rule
- Click Start Monitoring
- The server polls the Density API every 30 seconds
- When a room's occupancy meets or exceeds your threshold for the specified duration, it sends a Slack notification
- A cooldown period prevents notification spam (default: 30 minutes)
- Monitoring runs on the server, so you can close the browser tab
| Setting | Description | Default |
|---|---|---|
| Threshold | Number of people that triggers an alert | 3 |
| Duration | How long threshold must be met before alerting (minutes) | 1 |
| Cooldown | Minimum time between notifications (minutes) | 30 |
| Custom Message | Optional custom notification text | Auto-generated |
🚨 Alert: "Conference Room A" has 5 people (threshold: 3). It's been over 10 minute(s).
For production use, consider:
-
Process Manager: Use PM2 or systemd to keep the server running
npm install -g pm2 pm2 start server.js --name density-monitor
-
Persistence: The current implementation stores state in memory. For persistence across restarts, you could add file-based or database storage.
-
Security: If exposing to the internet, add authentication and use HTTPS.
The server exposes these endpoints for programmatic use:
| Endpoint | Method | Description |
|---|---|---|
/api/config |
POST | Set Density token and Slack webhook |
/api/spaces |
GET | List available Density spaces |
/api/spaces/:id/count |
GET | Get current count for a space |
/api/rules |
GET | List all monitoring rules |
/api/rules |
POST | Add a new rule |
/api/rules/:id |
DELETE | Remove a rule |
/api/monitor/start |
POST | Start monitoring |
/api/monitor/stop |
POST | Stop monitoring |
/api/monitor/status |
GET | Get current monitoring status |
/api/slack/test |
POST | Send a test Slack message |
"No spaces found"
- Check that your Density API token has the correct permissions
- Ensure you have access to at least one space in Density
Slack notifications not working
- Verify the webhook URL is correct
- Use the "Test Slack" button to verify connectivity
- Check the server console for error messages
Monitoring stops when I close the browser
- This is expected if running without a server. Use
node server.jsto keep monitoring running.