Enhanced system prompt:
- Professional cyber security expert role
- Modern HTML/CSS styling instructions
- Responsive design requirements
- Persuasive and urgent tone guidance
- Turkish language grammar emphasis
- Realistic corporate email appearance
Enhanced user prompt:
- Better structured input with emojis (📌)
- Clear field labels (HEDEF ŞİRKET, SENARYO, etc.)
- Detailed HTML example with inline CSS
- Button styling, footer, responsive design
- Max 70 char subject line guidance
- Multiple warnings for quality output
All user inputs are sent to AI:
✅ company_name (Şirket Adı)
✅ scenario (Senaryo)
✅ employee_info (Çalışan Bilgisi) - optional
✅ custom_prompt (Ek Talimatlar) - optional
template_name and template_type are for DB only, NOT sent to AI.
This will produce much higher quality, styled HTML emails.
Database Changes:
- Remove UNIQUE constraint from mail_templates.template_type
- Allow multiple templates with same type (e.g., multiple bank templates)
Ollama Service Improvements:
- Add detailed logging for AI responses (first 500 chars)
- Check multiple field name variations (subject/Subject/konu/title, body/Body/html/content)
- Improve error messages with actual field names
- Better JSON parsing with fallback
- Clearer prompt instructions to AI
This fixes:
- 400 Validation Error when creating templates with existing type
- AI response parsing issues with different field names
✨ New Features:
- 🤖 AI-powered mail template generation with Ollama
- 📧 Test mail sending with preview
- 🔧 Ollama server and model management
- 🎨 Beautiful AI generation dialog in Templates page
- ⚙️ Ollama settings panel with connection test
Backend:
- Add ollama.service.js - Ollama API integration
- Add ollama.controller.js - Template generation endpoint
- Add ollama.routes.js - /api/ollama/* routes
- Support for multiple Ollama models (llama3.2, mistral, gemma)
- JSON-formatted AI responses with subject + HTML body
- Configurable server URL and model selection
Frontend:
- Settings: Ollama configuration panel
- Server URL input
- Model selection
- Connection test with model listing
- Templates: AI generation dialog
- Company name, scenario, employee info inputs
- Custom prompt for AI instructions
- Auto-save to database
- Test mail sending functionality
Documentation:
- OLLAMA_SETUP.md - Comprehensive setup guide
- Installation instructions
- Model recommendations
- Usage examples
- Troubleshooting
Tech Stack:
- Ollama API integration (REST)
- Axios HTTP client
- React dialogs with MUI
- Self-hosted AI (privacy-friendly)
- Zero external API dependencies
Example Usage:
Company: Garanti Bankası
Scenario: Account security warning
→ AI generates professional phishing test mail in seconds!
- testConnection now sends a real test email to the configured Gmail address
- User receives actual email confirmation that setup works
- Email contains success message and system info