import requests

PHONE_NUMBER = "whatsapp:+918500176938"
WEBHOOK_URL = "http://localhost:3000/whatsapp/webhook"

print("========================================")
print("🤖 CuraFlow Autonomous Appointment Agent")
print("========================================")
print("Type your WhatsApp message below to send it to the agent.")
print("The agent will parse your intent and reply directly to your REAL WhatsApp number via Twilio!")
print("Type 'exit' to quit.\n")

while True:
    message = input(f"[{PHONE_NUMBER}] You: ")
    if message.lower() == 'exit':
        break
    
    # Simulate Twilio Webhook Payload
    data = {
        "From": PHONE_NUMBER,
        "Body": message
    }
    
    try:
        response = requests.post(WEBHOOK_URL, data=data)
        if response.status_code == 200:
            print("✅ Message sent to Webhook! Check your phone for the agent's reply in a few seconds.")
        else:
            print(f"❌ Webhook returned {response.status_code}: {response.text}")
    except Exception as e:
        print(f"❌ Failed to reach webhook: {e}")
