48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Email Alerts System - Main Entry Point
|
|
"""
|
|
from email_processor import EmailProcessor
|
|
from dotenv import load_dotenv
|
|
import sys
|
|
|
|
def main():
|
|
"""Main function to run the email alerts system"""
|
|
print("🚀 Email Alerts System")
|
|
print("=" * 40)
|
|
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
try:
|
|
# Initialize processor
|
|
processor = EmailProcessor()
|
|
|
|
# Process emails with alerts enabled - no limit
|
|
result = processor.process_emails(max_results=None, send_alerts=True)
|
|
|
|
if result.get('status') == 'success':
|
|
print("✅ Processing complete!")
|
|
print(f"📧 Total emails: {result.get('total_emails', 0)}")
|
|
print(f"🔍 Actionable emails: {result.get('actionable_emails', 0)}")
|
|
print(f"📱 Alerts sent: {len(result.get('sent_alerts', []))}")
|
|
|
|
# Show alert details
|
|
sent_alerts = result.get('sent_alerts', [])
|
|
if sent_alerts:
|
|
print(f"\n📱 Sent {len(sent_alerts)} WhatsApp alerts:")
|
|
for i, alert in enumerate(sent_alerts, 1):
|
|
status = "✅ Success" if alert.get('status') == 'success' else "❌ Failed"
|
|
print(f" {i}. {status} - Thread: {alert.get('thread_id', 'N/A')}")
|
|
if alert.get('message_sid'):
|
|
print(f" Message SID: {alert['message_sid']}")
|
|
else:
|
|
print(f"❌ Processing failed: {result.get('error', 'Unknown error')}")
|
|
sys.exit(1)
|
|
|
|
except Exception as e:
|
|
print(f"❌ System error: {e}")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main() |