A Flask-based notification service that sends notifications via ntfy and optionally Telegram.
- Always notifies via ntfy using UUID as topic
- Optionally notifies via Telegram if user has registered
- Self-hosted ntfy server (not public ntfy.sh)
- UUID-based topics for security and privacy
- Docker Compose (Recommended)
- Quick Start (Local Development)
- VPS Production Deployment
- Configuration
- API Endpoints
- User Flow
The easiest way to run everything - just one command!
- Docker and Docker Compose installed
# 1. Clone the repository
git clone https://github.com/your-repo/queue-notify-server.git
cd queue-notify-server
# 2. Create config files from examples
cp config.docker.json config.json
# 3. (Optional) For Telegram support:
cp bot.token.example bot.token
# Edit bot.token with your actual Telegram bot token
head -c 32 /dev/urandom > encryption.key
# 4. Start everything!
docker compose up -d
# 5. Test it works
curl -X POST http://localhost:5000/notify \
-H "Content-Type: application/json" \
-d '{"uuid": "test-123", "message": "Hello!"}'- Queue Notify API: http://localhost:5000
- ntfy Web UI: http://localhost:8090
# View logs
docker compose logs -f
# Stop services
docker compose down
# Restart after config changes
docker compose restart
# Rebuild after code changes
docker compose up -d --build# 1. Start ntfy server (in WSL)
wsl -d Ubuntu-24.04 -- ntfy serve --listen-http :8090
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run Flask app
python app.py
# 4. Test notification
curl -X POST http://localhost:5000/notify -H "Content-Type: application/json" -d "{\"uuid\": \"test-123\", \"message\": \"Hello!\"}"- Ubuntu 20.04+ or Debian 11+ VPS
- Root/sudo access
- Domain name (optional, for HTTPS)
ssh root@your-vps-ipapt update && apt upgrade -y
apt install -y python3 python3-pip python3-venv curl wget git nginx# Download ntfy binary
curl -sSL https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_amd64.tar.gz -o /tmp/ntfy.tar.gz
tar -xzf /tmp/ntfy.tar.gz -C /tmp
mv /tmp/ntfy_2.15.0_linux_amd64/ntfy /usr/bin/ntfy
chmod +x /usr/bin/ntfy
# Verify installation
ntfy --help# Create ntfy user and directories
useradd -r -s /bin/false ntfy
mkdir -p /etc/ntfy /var/cache/ntfy /var/log/ntfy
# Create config file
cat > /etc/ntfy/server.yml << 'EOF'
listen-http: "127.0.0.1:8090"
cache-file: "/var/cache/ntfy/cache.db"
cache-duration: "12h"
log-level: "info"
web-root: "app"
EOF
# Set permissions
chown -R ntfy:ntfy /var/cache/ntfy /var/log/ntfycat > /etc/systemd/system/ntfy.service << 'EOF'
[Unit]
Description=ntfy Notification Server
After=network.target
[Service]
Type=simple
User=ntfy
Group=ntfy
ExecStart=/usr/bin/ntfy serve --config /etc/ntfy/server.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable ntfy
systemctl start ntfy
# Verify
systemctl status ntfy# Create app directory
mkdir -p /opt/queue-notify
cd /opt/queue-notify
# Clone or copy your code
git clone https://github.com/your-repo/queue-notify-server.git .
# Or: scp -r your-local-path/* root@your-vps:/opt/queue-notify/
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install gunicorn
deactivate
# Create config file
cp config.production.json config.json
# Create encryption key (for Telegram chat IDs)
head -c 32 /dev/urandom > encryption.key
# Set permissions
chown -R www-data:www-data /opt/queue-notify
mkdir -p /var/log/queue-notify
chown www-data:www-data /var/log/queue-notifycat > /etc/systemd/system/queue-notify.service << 'EOF'
[Unit]
Description=Queue Notify Server
After=network.target ntfy.service
Wants=ntfy.service
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/queue-notify
Environment="PATH=/opt/queue-notify/venv/bin"
ExecStart=/opt/queue-notify/venv/bin/gunicorn --workers 4 --bind 127.0.0.1:5000 app:app
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable queue-notify
systemctl start queue-notify
# Verify
systemctl status queue-notifycat > /etc/nginx/sites-available/queue-notify << 'EOF'
server {
listen 80;
server_name your-domain.com; # Or use IP
# Queue Notify API
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# ntfy Server (optional - expose if users need web UI)
location /ntfy/ {
proxy_pass http://127.0.0.1:8090/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
EOF
ln -sf /etc/nginx/sites-available/queue-notify /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default
nginx -t && systemctl reload nginxapt install -y certbot python3-certbot-nginx
certbot --nginx -d your-domain.comIf you want Telegram notifications:
# Save your Telegram bot token
echo "YOUR_BOT_TOKEN_HERE" > /opt/queue-notify/bot.token
chown www-data:www-data /opt/queue-notify/bot.token
chmod 600 /opt/queue-notify/bot.token
# Restart service
systemctl restart queue-notify# Test ntfy directly
curl -X POST http://localhost:8090/test-topic -d "Test notification"
# Test queue-notify API
curl -X POST http://localhost:5000/notify \
-H "Content-Type: application/json" \
-d '{"uuid": "test-uuid-123", "message": "Hello from production!"}'
# Expected response:
# {"backends": ["ntfy"], "status": "notifications sent"}ufw allow 80/tcp
ufw allow 443/tcp
ufw enableEdit /opt/queue-notify/config.json:
{
"ntfy": {
"server": "http://localhost:8090",
"token": ""
},
"telegram": {
"enabled": true,
"bot_token_file": "/opt/queue-notify/bot.token"
}
}Send a notification.
{
"uuid": "user-unique-id",
"message": "Your notification",
"notifyRetries": 1
}Response:
{
"status": "notifications sent",
"backends": ["ntfy", "telegram"]
}Register Telegram mapping (user must first send UUID to bot).
{
"uuid": "user-unique-id"
}Returns safe configuration (no secrets).
Returns notification statistics.
- Install ntfy app on phone
- Add server:
http://your-domain.com/ntfy/orhttp://your-vps-ip:8090 - Subscribe to your UUID topic
- Done!
- Find the bot and send your UUID
- Your app calls
/registerwith same UUID - Now notifications go to both ntfy AND Telegram
# View ntfy logs
journalctl -u ntfy -f
# View queue-notify logs
journalctl -u queue-notify -f
# Check service status
systemctl status ntfy queue-notify
# Restart services
systemctl restart ntfy queue-notify# Start services
systemctl start ntfy queue-notify
# Stop services
systemctl stop ntfy queue-notify
# Restart after config changes
systemctl restart ntfy queue-notify
# View logs
journalctl -u queue-notify -fThis project is provided "as is" with no warranties.