Fully automatic SMS notifications for elderly care ride services
Now with real-time database change detection - zero manual API calls needed!
DispatchBot now uses MongoDB Change Streams to automatically detect every change in your ride request database and send SMS notifications in real-time. No more manual API calls needed!
- β Real-time status changes - Detects every ride status update automatically
- β New ride requests - Automatically sends confirmation SMS when rides are created
- β Driver assignments - Automatically notifies when drivers are assigned
- β Vehicle assignments - Automatically notifies when vehicles are assigned
- β Emergency alerts - Immediate caregiver notification system
- β Pickup reminders - Automatic reminders 15 minutes before pickup
- β Delay notifications - Alerts when rides are running late
- π« Zero Code Changes - Works with your existing ride app immediately
- β‘ Real-time Detection - MongoDB Change Streams watch your database
- π± Automatic SMS - Every status change triggers appropriate notifications
- π¨ Emergency Ready - Immediate caregiver and support team alerts
- π Full Monitoring - Real-time status and queue monitoring
- π Analytics - Track SMS delivery and system performance
Your Ride App Database ββ DispatchBot ββ Twilio SMS
(MongoDB) (Change Streams) (Users)
- π Change Stream Monitor - Watches your database for real-time changes
- π± SMS Manager - Handles Twilio SMS sending and delivery tracking
- βοΈ Preferences Manager - Manages user and driver communication preferences
- π¨ Emergency Handler - Immediate emergency notification system
- π Queue Manager - Prioritized notification queue with retry logic
npm install# Copy the config file
cp dispatchbot-config.env .env
# Edit .env with your actual values:
# - MONGODB_URI (same as your ride app)
# - TWILIO_ACCOUNT_SID (same as your ride app)
# - TWILIO_AUTH_TOKEN (same as your ride app)
# - TWILIO_FROM_NUMBER (same as your ride app)npm run dev# Set user preferences
curl -X PUT http://localhost:3000/api/users/USER_001/preferences \
-H "Content-Type: application/json" \
-d '{"notificationPreferences": {"sms": true}}'
# Set driver preferences
curl -X PUT http://localhost:3000/api/drivers/1001/preferences \
-H "Content-Type: application/json" \
-d '{"availability": {"isAvailable": true}}'# Check if it's running
curl http://localhost:3000/health
# Check status
curl http://localhost:3000/api/dispatchbot/status// Your ride app had to call DispatchBot API
await fetch('/api/rides/1001/status', {
method: 'PUT',
body: JSON.stringify({ status: 300 })
});// Your ride app just updates the database (NO CHANGES NEEDED!)
await RideRequest.updateOne(
{ uuid: 1001 },
{ rideStatus: 300 } // Change to "Rider Picked Up"
);
// DispatchBot automatically detects this and sends SMS!| Your Status Code | DispatchBot Action | SMS Sent | Detection |
|---|---|---|---|
0 (In Progress) |
Creates event | "Ride request received" | β Automatic |
100 (Confirmed) |
Creates event | "Ride confirmed" | β Automatic |
200 (Started) |
Creates event | "Ride started" | β Automatic |
300 (Picked Up) |
Creates event | "You've been picked up!" | β Automatic |
400 (Dropped Off) |
Creates event | "You've been dropped off" | β Automatic |
500 (Complete) |
Creates event | "Ride complete" | β Automatic |
POST /api/notifications/emergency
{
"recipient": "USER_001",
"message": "Medical emergency during ride"
}- Sends urgent SMS to elderly person
- Notifies emergency contacts (caregivers, family)
- Alerts support team
- Updates ride status to interrupted (209)
- Logs everything for follow-up
GET /api/dispatchbot/status
# Shows: Queue status, SMS sent, system health, change streams activeGET /api/notifications/queue/status
# Shows: Pending SMS, failed messages, success rateGET /health
# Shows: System health and uptimeGET /health- Health checkPOST /api/notifications/emergency- Emergency alertsGET /api/notifications/queue/status- Queue monitoringGET /api/dispatchbot/status- System statusGET /api/users/:uuid/preferences- Get user preferencesPUT /api/users/:uuid/preferences- Update user preferencesGET /api/drivers/:uuid/preferences- Get driver preferencesPUT /api/drivers/:uuid/preferences- Update driver preferences
- β
POST /api/rides- Ride creation (automatic detection) - β
PUT /api/rides/:uuid/status- Status updates (automatic detection) - β
POST /api/rides/:uuid/assign- Driver assignment (automatic detection) - β
POST /api/rides/:uuid/vehicle- Vehicle assignment (automatic detection)
// In your ride request app (no changes needed!)
const testRide = await RideRequest.create({
uuid: 9999,
serviceUserUuid: "TEST_USER",
pickupAddress: "123 Test St",
dropOffAddress: "456 Test Ave",
rideStatus: 0,
roundTrip: false,
purpose: "Testing DispatchBot"
});
// DispatchBot automatically detects this and sends SMS!// In your ride request app (no changes needed!)
await RideRequest.updateOne(
{ uuid: 9999 },
{ rideStatus: 300 } // Change to "Rider Picked Up"
);
// DispatchBot automatically detects this and sends SMS!# Check system status
curl http://localhost:3000/api/dispatchbot/status
# Check notification queue
curl http://localhost:3000/api/notifications/queue/status| Variable | Description | Required | Default |
|---|---|---|---|
PORT |
Server port | No | 3000 |
MONGODB_URI |
MongoDB connection string | Yes | - |
TWILIO_ACCOUNT_SID |
Twilio Account SID | Yes | - |
TWILIO_AUTH_TOKEN |
Twilio Auth Token | Yes | - |
TWILIO_FROM_NUMBER |
Twilio phone number | Yes | - |
TWILIO_WEBHOOK_URL |
Webhook base URL | No | - |
- MongoDB 3.6+ (for Change Streams support)
- Same database as your ride request app
- Collections:
users,serviceproviders,riderequests
- Check Twilio credentials in
.env - Verify phone numbers are in correct format (+1234567890)
- Check DispatchBot logs for errors
- Verify change streams are active in console
- Verify MongoDB is running
- Check
MONGODB_URIin.env - Ensure DispatchBot connects to same database as your ride app
- Check if MongoDB supports Change Streams (MongoDB 3.6+)
- Check MongoDB version (needs 3.6+)
- Verify database user has permissions for change streams
- Check console for "
β οΈ Falling back to manual API detection" - DispatchBot will still work with manual API calls
Your DispatchBot is now perfectly integrated and fully automatic! It will:
- Watch your database for ride changes in real-time
- Send automatic SMS for every status update (no API calls needed!)
- Handle emergencies immediately
- Provide real-time monitoring and analytics
No changes to your existing code required! Just start DispatchBot and it will automatically detect every change in your ride request app and send the appropriate SMS notifications.
DispatchBot - Making transportation accessible and safe for everyone
Now with fully automatic database change detection!