// Send direct test message to obaid via WAHA
async function sendDirectMessage() {
  console.log('📱 SENDING DIRECT MESSAGE TO OBAID');
  console.log('='.repeat(40));
  
  try {
    const testMessage = {
      session: 'default',
      chatId: '+201066544750@c.us',
      text: `🧪 DIRECT TEST MESSAGE FOR OBAID

Hi Obaid! This is a direct test message from Clinera to confirm the WhatsApp integration is working perfectly.

✅ Reminder system: OPERATIONAL
✅ WAHA connection: WORKING  
✅ Message delivery: IMMEDIATE

Your appointment reminder system is now fully functional! 🎉

Time sent: ${new Date().toLocaleString()}`
    };
    
    console.log('📤 Sending direct message via WAHA...');
    
    const response = await fetch('http://localhost:3005/api/sendText', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-Api-Key': '992659f827564646ba3ab95ead50adc9'
      },
      body: JSON.stringify(testMessage)
    });
    
    if (response.ok) {
      const result = await response.json();
      console.log('✅ DIRECT MESSAGE SENT SUCCESSFULLY!');
      console.log('📱 Message details:');
      console.log(`   ID: ${result.key?.id}`);
      console.log(`   Status: ${result.status}`);
      console.log(`   Timestamp: ${result.messageTimestamp}`);
      
      console.log('\n🎯 OBAID SHOULD RECEIVE BOTH MESSAGES:');
      console.log('   1. ✅ Booking confirmation (via Clinera system)');
      console.log('   2. ✅ Direct test message (via WAHA API)');
      console.log('\n📲 CHECK YOUR WHATSAPP NOW OBAID! 📲');
      
    } else {
      console.log('❌ Direct message failed:', response.status, await response.text());
    }
    
  } catch (error) {
    console.error('❌ Direct message error:', error);
  }
}

sendDirectMessage().catch(console.error);