# AI Survey Generator Setup Instructions

## Overview
Your AI Survey Generator system is now ready! Here's how it works:

### 🤖 **Automated Weekly Process**
1. **Every Week**: AI scans hot topics and generates a new survey
2. **Survey Runs**: For 7 days, collecting public responses 
3. **Auto-Analysis**: When survey closes, AI analyzes results
4. **Draft Creation**: AI generates a comprehensive article from findings
5. **Admin Review**: You review and publish the AI-generated article

### 📋 **Setup Steps**

#### 1. **Initialize Database Tables**
Run this once to set up the logging system:
```bash
php setup_survey_logs.php
```

#### 2. **Set Up Weekly Automation (Choose One)**

**Option A: For Local Development (XAMPP)**
- Run manually each week: `php weekly_survey_cron.php`
- Or set up Windows Task Scheduler

**Option B: For Production Server**
Add this to your crontab to run every Sunday at 9 AM:
```bash
0 9 * * 0 /usr/bin/php /path/to/your/website/weekly_survey_cron.php
```

#### 3. **Admin Workflow**
1. Visit **Admin Dashboard** → **AI Survey Articles**
2. Review AI-generated draft articles
3. Edit if needed and publish relevant ones
4. Monitor survey performance in **Survey Generator**

### 🔧 **Configuration Files**
- `survey_generator.php` - Manual survey creation interface
- `admin_ai_survey_articles.php` - Review AI drafts
- `weekly_survey_cron.php` - Automated weekly generation
- `src/includes/ai_survey_generator.php` - Core AI logic

### 📊 **What Gets Created**
- **Hot Topics**: AI tracks trending Malaysian issues
- **Weekly Surveys**: Automated public polls on current topics
- **Analysis Articles**: Data-driven insights from survey results
- **Draft Status**: All AI articles require admin approval

### 🎯 **Current Hot Topics Examples**
- AI and Job Market in Malaysia
- Digital Banking Security  
- Remote Work Policies 2025
- Sustainable Transportation

### ✅ **Ready to Use**
Your system is configured with:
- ✅ Maybank account (157148142502) for RM10 registration fees
- ✅ AI survey generation with hot topic tracking
- ✅ Automated article creation from survey results
- ✅ Admin review system for AI-generated content
- ✅ Weekly automation script ready to deploy

### 📝 **Next Steps**
1. Run `setup_survey_logs.php` to initialize
2. Test manual survey generation in `survey_generator.php`
3. Set up weekly automation with `weekly_survey_cron.php`
4. Start reviewing AI articles in admin panel!

---
**Need Help?** Check the generated logs in `/logs/survey_cron.log` for troubleshooting.