import requests
import json

WHATSAPP_API_URL = "https://graph.facebook.com/v22.0/675390169001345/messages"
ACCESS_TOKEN = "EAAk7ZADZA6gUMBPGHpApioaJ4abhprfVvJWcpjfXbbtA6gocHIZA4RFNHggj8JqyZAretcsXYxAyms6LtRwXQwXakP40N6qJs0OAxsBiwWIE6ReW2UHjZCUsHHbIGBqPl1g3f45wtT7X7saT7ZBmDxbQuu7VmdNJEoQ84WHpgbMO8TUz0SnKqoco7yDmLZAf8c4Sq9fr5WRusIX76hPVOgovtrjPYsum0AZBb1deTYKJGwZDZD"

def send_whatsapp_message(phone_number: str):
    """
    Send WhatsApp confirmation message using WhatsApp Cloud API
    """
    headers = {
        "Authorization": f"Bearer {ACCESS_TOKEN}",
        "Content-Type": "application/json"
    }

    data = {
        "messaging_product": "whatsapp",
        "to": phone_number,  # must include country code, e.g., "919876543210"
        "type": "template",
        "template": {
            "name": "hello_world",  # ✅ Default template
            "language": {"code": "en_US"}
        }
    }

    response = requests.post(WHATSAPP_API_URL, headers=headers, data=json.dumps(data))
    return response.json()
