--- description: globs: alwaysApply: false --- # SnappyMail LLM Email Writing Prompts Plugin with Grok 3 API Support ## Overview This plugin enhances SnappyMail, a lightweight web-based email client, by integrating AI-driven email writing prompts powered by xAI's Grok 3 API as the primary Large Language Model (LLM) provider, with fallbacks to other LLMs. The purpose is to assist users in drafting professional, concise, or creative emails through context-aware prompt suggestions, leveraging Grok 3's advanced reasoning capabilities. ## Purpose and Goals - **Primary Goal**: Enable SnappyMail users to access Grok 3-generated prompts for drafting emails with high-quality, reasoning-focused outputs. - **Secondary Goals**: - Ensure compatibility with SnappyMail's lightweight and privacy-focused design. - Provide a user-friendly interface for selecting and customizing prompts. - Maintain performance and security standards for self-hosted environments. - Allow fallback to other LLM APIs (e.g., OpenAI, Hugging Face) for flexibility. ## Target Audience - **Primary Users**: Individuals and small businesses using SnappyMail for personal or professional email communication, especially those seeking AI-assisted writing with Grok 3's logical outputs. - **Secondary Users**: System administrators managing SnappyMail instances who want to enhance functionality with Grok 3 integration. - **Use Cases**: - Professionals drafting formal emails (e.g., business proposals). - Casual users writing personal emails with creative tones. - Non-native speakers needing assistance with grammar and phrasing. ## Functional Requirements ### Core Features - **Prompt Library**: A set of predefined prompts in categories like Professional, Creative, Assistance, and Quick Replies, optimized for Grok 3's reasoning capabilities. - **Context-Aware Suggestions**: Analyzes email subject and body to suggest relevant prompts using Grok 3's chain-of-thought reasoning. - **LLM Integration**: Primary provider is xAI Grok 3 API ([https://api.x.ai/v1/chat/completions](mdc:https:/api.x.ai/v1/chat/completions)), with configurable fallbacks to OpenAI, Hugging Face, or local LLMs. - **Draft Generation**: Generates email drafts based on prompts and context, supporting multiple iterations (e.g., tone adjustments). - **Custom Prompts**: Users can create and save custom prompts, stored securely as JSON files. - **Privacy and Security**: No email data stored beyond API calls, with optional opt-in for context analysis and secure API key storage. ### User Interface - **Compose Window Integration**: A "Smart Prompts" button or sidebar in the email composition interface for Grok 3-powered suggestions. - **Settings Panel**: Options to configure Grok 3 API key, select model, manage custom prompts, and toggle context analysis. - **Visual Design**: Matches SnappyMail's minimalist UI with dark mode and mobile responsiveness. ## Technical Requirements - **Platform**: Compatible with SnappyMail v2.12+, PHP 7.4+, and JavaScript ES2018. - **Plugin Architecture**: Located in `/plugins/llm-prompts/` with files like `index.php`, `js/`, `templates/`, and `config.json`. - **LLM Integration**: Uses Grok 3 API with OpenAI SDK compatibility, secure API key storage, and fallback logic for other providers. - **Security**: Encrypts API keys and prompts, sanitizes outputs to prevent XSS, and complies with GDPR. ## Implementation Plan - **Phase 1**: Research and setup Grok 3 API access (2 weeks). - **Phase 2**: Core development of prompt library and API integration (4 weeks). - **Phase 3**: UI and settings development (3 weeks). - **Phase 4**: Testing and security audits (3 weeks). - **Phase 5**: Release and documentation (2 weeks). ## References - SnappyMail Official Site: [https://snappymail.eu](mdc:https:/snappymail.eu) - SnappyMail GitHub: [https://github.com/the-djmaze/snappymail](mdc:https:/github.com/the-djmaze/snappymail) - xAI Grok 3 API: [https://x.ai/api](mdc:https:/x.ai/api)