Skip to content

Turn your phone into a remote control for Python functions! Interactive notifications with executable buttons via ntfy.sh and ngrok webhooks.

License

Notifications You must be signed in to change notification settings

BonifacioCalindoro/ntfy-client

Repository files navigation

License: MIT Python 3.7+

🚀 Ntfy Webhook System

Turn your phone into a remote control for Python functions!

Send interactive notifications with buttons that execute Python functions on your computer from anywhere in the world. Perfect for home automation, server management, or any remote control needs.

✨ Features

  • 📱 Interactive Notifications - Send Yes/No buttons that execute functions
  • 🌐 Global Access - Works from anywhere using ngrok tunnels
  • 🔧 Easy Setup - Simple decorator syntax and .env configuration
  • 🛡️ Secure - HTTPS tunnels and unique webhook URLs
  • Real-time - Instant execution and result feedback
  • 🎯 Zero Config - Works out of the box with sensible defaults

🚀 Quick Start

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure (optional):
# Copy the example config
cp env.example .env

# Edit .env with your settings
NTFY_TOPIC=my-remote-control
NGROK_TOKEN=your_ngrok_token_here  # Get from https://ngrok.com
  1. Create your remote functions:
# example.py
from ngrok_webhook import NgrokWebhookManager

manager = NgrokWebhookManager("my-topic")

@manager.webhook_function(description="Say hello")
def hello():
    print("🎉 Hello from your phone!")
    return "Hello executed successfully!"

@manager.webhook_function(description="Check system status")  
def system_status():
    import platform
    return f"System: {platform.system()} - All OK!"

# Start everything
manager.run_server()
  1. Run and use:
python example.py
# Check your phone for notifications with buttons!

🎯 How It Works

  1. 📱 You get a notification on your phone with action buttons
  2. 👆 You tap a button (like "Yes, execute")
  3. 🌐 Webhook triggers via secure ngrok tunnel
  4. 🔥 Function executes on your computer
  5. 📲 You get results back as another notification

Perfect for:

  • 🏠 Home automation - Control lights, temperature, security
  • 🖥️ Server management - Restart services, check status
  • 📊 Monitoring - Get system stats, disk usage, uptime
  • 🔧 Remote tasks - Backups, updates, maintenance

🛠️ Configuration

The system uses .env files for easy configuration:

# .env file
NTFY_TOPIC=my-remote-control
NGROK_TOKEN=your_token_here
WEBHOOK_PORT=8000
USE_NGROK=true

# For private ntfy servers
NTFY_BASE_URL=https://your-ntfy-server.com
NTFY_ACCESS_TOKEN=your_access_token

📂 Examples

Quick Start

# Main example (recommended)
python example.py

# Setup wizard for first-time users  
python setup_ngrok.py

🎯 Specialized Examples

Explore the /examples folder for specific use cases:

# Basic concepts
python examples/basic_hello_world.py

# Home automation & IoT
python examples/home_automation.py

# Server management & DevOps  
python examples/server_management.py

# Development workflow
python examples/development_tools.py

# Personal productivity
python examples/personal_assistant.py

See examples/README.md for detailed descriptions.

🚀 What You Get

  • 📱 Interactive notifications with executable buttons
  • 🌐 Global access via secure ngrok tunnels
  • 🔧 Easy setup with .env configuration
  • Real-time execution and result feedback
  • 🛡️ Secure webhooks with unique URLs per function

Perfect for turning your phone into a remote control for any Python script! 🎮

📚 Learn More