Lyra - Email Messenger Agent
Overview
Lyra is the Email Messenger agent in the TKM AI Agency Platform, responsible for handling all email-related communications. It manages email composition, sending, and tracking, ensuring reliable email delivery and proper formatting of messages for email communication.
Directory Structure
Backend/CRM/Lyra/
├── data/ # Email logs and templates
├── lyra.py # Main agent implementation
├── api_lyra.py # FastAPI endpoints
├── tools.py # Email handling utilities
├── tools_schema.py # Data models and schemas
├── tools_definitions.py # Constants and definitions
└── test_lyra.py # Unit tests
Main Components
LyraAgent Class
The core component that handles email messaging operations:
- Email composition and formatting
- SMTP integration and email sending
- Template management
- Email tracking and logging
Processing Pipeline
-
Message Reception
- Receives email requests through API endpoints
- Validates email format and content
-
Email Processing
- Formats messages according to templates
- Handles attachments and rich content
- Applies email styling and branding
-
Delivery Management
- Manages SMTP connections
- Handles email queuing
- Tracks delivery status
API Operations
Send Email
- Endpoint:
/send_email
- Method: POST
- Purpose: Sends formatted emails to specified recipients
- Request Format:
{ "to": "recipient@example.com", "subject": "Email Subject", "content": "Email content", "template_id": "template_identifier", "metadata": { "priority": "normal", "category": "notification" } }
- Response Format:
{ "status": "success", "message_id": "email_identifier", "timestamp": "2024-01-15T12:00:00Z" }
Key Features
-
Email Management
- Template-based email composition
- HTML and plain text support
- Attachment handling
- Email queuing and scheduling
-
Template System
- Customizable email templates
- Dynamic content insertion
- Brand consistency maintenance
- Multi-language support
-
Delivery Tracking
- Delivery status monitoring
- Bounce handling
- Retry mechanisms
- Delivery analytics
Integration
Email Service Providers
- SMTP server integration
- Email service provider APIs
- Delivery optimization
- Security compliance
Platform Integration
- Interfaces with other CRM agents
- Event-based notifications
- Status reporting
- Analytics integration
Error Handling
-
Email Validation
- Address format verification
- Content validation
- Attachment checking
- Size limit enforcement
-
Delivery Issues
- Bounce handling
- Retry logic
- Error notification
- Fallback mechanisms
Performance Features
-
Optimization
- Email queuing
- Batch processing
- Connection pooling
- Resource management
-
Monitoring
- Delivery rates
- Success metrics
- Performance analytics
- Resource usage
Data Models
Email Message
{
"message_id": str,
"to": str,
"from": str,
"subject": str,
"content": str,
"template_id": str,
"attachments": list,
"metadata": dict
}
Email Template
{
"template_id": str,
"name": str,
"subject_template": str,
"body_template": str,
"variables": list,
"metadata": dict
}