3.4 KiB
3.4 KiB
Email Alerts System - Flask Deployment Guide
Overview
This Flask web application provides a user-friendly interface for the Email Alerts System with configurable settings for time frames, email monitoring, and alert levels.
Features
✅ Configurable Settings
- Email Address: Set which email to monitor for responses
- Time Frames: Add unlimited custom time frames for alerts (e.g., 1-24 hours, 24-48 hours, 48+ hours)
- Email Range: Configure how many days back to check emails (1-365 days)
- Agency Domains: Set which email domains indicate agency responses
✅ Web Interface
- Dashboard: View system status and process emails
- Settings: Configure all system parameters
- Real-time Updates: See processing results and thread status
Installation
1. Install Dependencies
pip install -r requirements.txt
2. Environment Setup
Copy the example environment file and configure your settings:
cp env.example .env
Edit .env with your credentials:
ZOHO_EMAIL=your-email@domain.com
ZOHO_APP_PASSWORD=your-app-password
GROQ_API_KEY=your-groq-api-key
TWILIO_ACCOUNT_SID=your-twilio-sid
TWILIO_AUTH_TOKEN=your-twilio-token
TWILIO_PHONE_NUMBER=your-twilio-phone
SECRET_KEY=your-secret-key-here
3. Run the Application
python run.py
The web interface will be available at: http://localhost:5000
Usage
Dashboard
- Test Connection: Verify email connectivity
- Process Emails: Run the email processing pipeline
- Refresh Threads: Update the list of threads needing alerts
Settings
-
Email Configuration:
- Set the email address to monitor
- Configure how many days back to check emails
- Add agency domains (comma-separated)
-
Time Frames:
- Add unlimited custom time frames
- Set hours and alert levels for each frame
- Remove unwanted time frames
-
Save Configuration: All settings are automatically saved
Configuration Examples
Time Frames
1-24 hours: 24 hours, Level 1 (Normal)
24-48 hours: 48 hours, Level 2 (Urgent)
48+ hours: 72 hours, Level 3 (Critical)
Custom: 12 hours, Level 1 (Early warning)
Email Range
- 7 days: Standard monitoring
- 30 days: Monthly monitoring
- 90 days: Quarterly monitoring
Agency Domains
projects@manaknightdigital.com
support@company.com
help@agency.com
API Endpoints
GET /- DashboardGET /settings- Settings pagePOST /update_settings- Update configurationPOST /process_emails- Process emails and send alertsGET /get_threads- Get threads needing alertsGET /test_connection- Test email connection
Production Deployment
Using Gunicorn
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app
Using Docker
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
Troubleshooting
Common Issues
- Connection Failed: Check Zoho IMAP settings and app password
- No Alerts Sent: Verify Twilio credentials and phone numbers
- AI Analysis Errors: Check Groq API key and quota
Logs
Check the console output for detailed error messages and processing results.
Security Notes
- Use strong SECRET_KEY for production
- Enable HTTPS in production
- Restrict access to authorized users
- Regularly rotate API keys and passwords