// Send another test message to obaid's correct number async function sendAnotherTest() { console.log('๐Ÿ“ฑ SENDING ANOTHER TEST MESSAGE TO OBAID'); console.log('='.repeat(50)); try { const currentTime = new Date(); const testMessage = { session: 'default', chatId: '201066544750@c.us', // obaid's correct WhatsApp text: `๐Ÿงช ANOTHER TEST MESSAGE #2 Hi Obaid! This is test message #2 to confirm the system is still working perfectly. ๐Ÿ“ฑ Your correct WhatsApp: +201066544750 โฐ Time: ${currentTime.toLocaleString()} ๐ŸŽฏ Message purpose: System confirmation test Previous messages sent to your number: โœ… Message 1: Wrong number explanation + booking confirmation โœ… Message 2: This message If you receive this, the reminder system is 100% operational and ready for real appointments! ๐Ÿš€ Status: READY FOR APPOINTMENT CREATION Next step: Create appointment in Clinera UI and you'll get booking confirmation instantly! From: Clinera Test System ๐Ÿ“ฒ` }; console.log('๐Ÿ“ค Sending test message...'); console.log(` To: +201066544750 (obaid's WhatsApp)`); console.log(` Time: ${currentTime.toLocaleString()}`); const sendResponse = await fetch('http://localhost:3005/api/sendText', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Api-Key': '992659f827564646ba3ab95ead50adc9' }, body: JSON.stringify(testMessage) }); if (sendResponse.ok) { const result = await sendResponse.json(); console.log('โœ… ANOTHER TEST MESSAGE SENT SUCCESSFULLY!'); console.log(`๐Ÿ“จ Message ID: ${result.key?.id}`); console.log(`๐Ÿ“ž To: +201066544750`); console.log(`โฐ Timestamp: ${result.messageTimestamp}`); console.log(`๐Ÿ”„ Status: ${result.status}`); console.log('\n๐ŸŽฏ OBAID - CHECK YOUR WHATSAPP NOW!'); console.log(' Phone: +201066544750'); console.log(' Look for: "ANOTHER TEST MESSAGE #2"'); console.log(' Content: System confirmation + status'); console.log(''); console.log('โœ… If you see this message:'); console.log(' - Reminder system is working'); console.log(' - Correct phone number confirmed'); console.log(' - Ready for real appointments'); console.log(''); console.log('๐Ÿ“‹ Next: Create appointment in UI and get instant booking confirmation!'); // Also log this in database for tracking const { PrismaClient } = require('@prisma/client'); const prisma = new PrismaClient(); try { await prisma.messageLog.create({ data: { clinicId: (await prisma.clinic.findFirst()).id, phone: '+201066544750', direction: 'outgoing', message: testMessage.text, status: 'sent', wahaMessageId: result.key?.id || null, sentAt: new Date(), }, }); console.log('โœ… Message logged in database'); await prisma.$disconnect(); } catch (dbError) { console.log('โš ๏ธ Database logging failed (message still sent)'); } } else { const error = await sendResponse.text(); console.log(`โŒ Message send failed:`); console.log(` Status: ${sendResponse.status}`); console.log(` Error: ${error}`); console.log('\n๐Ÿ”ง If send failed:'); console.log(' - WAHA might need restart: docker restart waha'); console.log(' - WhatsApp Web might be disconnected'); console.log(' - Check: http://localhost:3005/api/default/auth/qr'); } } catch (error) { console.error('โŒ Test failed:', error); } } sendAnotherTest().catch(console.error);