Email Routing
Email Routing
Transform emails into agent conversations. Cloudflare Email Routing enables your AI agents to process incoming emails, send automated responses, and integrate email communication seamlessly into your agent workflows. Perfect for customer support, lead processing, and intelligent email automation.
Key Features
- Incoming Email Processing: Automatically route and process incoming emails to your agents
- Intelligent Parsing: Extract structured data from email content, attachments, and headers
- Automated Responses: Send contextual replies based on email content and intent
- Anti-Spam Protection: Built-in spam filtering and security scanning
- Global Delivery: Reliable email delivery through Cloudflare's global network
TypeScript API Reference
Email Processing
onEmailReceived(handler: EmailHandler): void
Registers a handler function that processes incoming emails. The handler receives parsed email data and can trigger agent workflows.
parseEmail(emailData: RawEmail): ParsedEmail
Parses raw email data into structured format including sender, recipients, subject, body, and attachments.
extractIntent(email: ParsedEmail): EmailIntent
Analyzes email content to determine user intent, sentiment, and required actions. Uses AI to understand the purpose of the email.
Email Sending
send(emailOptions: SendEmailOptions): Promise<EmailDeliveryResult>
Sends an email with support for HTML content, attachments, and delivery tracking. Includes anti-spam compliance features.
sendTemplate(templateId: string, data: TemplateData, recipient: string): Promise<EmailDeliveryResult>
Sends an email using a pre-defined template with dynamic data substitution. Useful for consistent branding and automated responses.
reply(originalEmail: ParsedEmail, content: string, options?: ReplyOptions): Promise<EmailDeliveryResult>
Replies to an email maintaining proper threading and context. Automatically handles Reply-To headers and conversation tracking.
Email Management
getConversation(conversationId: string): Promise<EmailConversation>
Retrieves an email conversation thread with all messages, participants, and metadata for context-aware responses.
searchEmails(query: EmailSearchQuery): Promise<EmailSearchResult[]>
Searches through processed emails using content, sender, date, and other criteria for building knowledge bases.
markAsProcessed(emailId: string, result: ProcessingResult): Promise<void>
Marks an email as processed and stores the agent's response or action taken for audit and analytics purposes.
Agent Examples
Customer Support Email Agent
Lead Processing Email Agent
Newsletter and Content Distribution Agent
Best Practices
Email Processing
Response Generation
Anti-Spam Compliance
Configuration
Wrangler Configuration
Email Routing Rules
Security Features
- SPF/DKIM/DMARC: Automatic email authentication
- Spam Filtering: Advanced spam and phishing protection
- Content Scanning: Automatic malware and virus scanning
- Rate Limiting: Protection against email bombing
- Encryption: TLS encryption in transit
Limitations
- Message Size: Maximum 25MB per email (including attachments)
- Recipients: Maximum 50 recipients per email
- Send Rate: 200 emails per minute per worker
- Storage: Email data retained for 30 days
- Attachments: Common file types supported, executables blocked
Related Services
- Memory Store - Store conversation history and customer data
- Analytics Storage - Track email performance metrics
- Workflows - Orchestrate complex email sequences