Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rohanarun/phoneclaw/llms.txt
Use this file to discover all available pages before exploring further.
Overview
PhoneClaw provides powerful email automation capabilities through the sendAgentEmail function and can read emails for extracting verification codes, processing notifications, and more.
Sending Automated Emails
Use the sendAgentEmail function to send notifications or reports:
Compose Email Content
Define your email recipient, subject, and message.const recipient = "user@example.com"
const subject = "Daily Automation Report"
const message = "Your automation completed successfully."
Send Email
Use sendAgentEmail to send the email.sendAgentEmail(recipient, subject, message)
speakText("Email sent successfully")
Complete Email Notification Script
// Send automation completion notification
const sendCompletionEmail = () => {
const to = "admin@example.com"
const subject = "PhoneClaw Automation Complete"
const message = `
Your scheduled automation has completed successfully.
Timestamp: ${new Date().toISOString()}
Status: Success
`
sendAgentEmail(to, subject, message)
speakText("Notification email sent")
}
sendCompletionEmail()
Reading Emails for 2FA Codes
Extract verification codes from emails using magicScraper:
Open Email App
Navigate to your email application.magicClicker("Email app")
delay(2000)
magicClicker("Inbox")
delay(1500)
Find Verification Email
Open the most recent verification email.magicClicker("Most recent email from verification")
delay(2000)
Extract Code
Use magicScraper to read the verification code.const code = magicScraper("The 6-digit verification code in the email")
speakText(`Code extracted: ${code}`)
// Extract 2FA code from email
const get2FACode = () => {
magicClicker("Email app")
delay(2000)
magicClicker("Inbox")
delay(1500)
magicClicker("Most recent email")
delay(2000)
const code = magicScraper("The verification code shown in the email body")
speakText(`Retrieved code: ${code}`)
return code
}
const verificationCode = get2FACode()
Scheduled Email Reports
Automate daily or weekly email reports:
// Daily automation report
const dailyReport = `
const stats = magicScraper("Current app statistics on screen")
const reportMessage = \`
Daily PhoneClaw Report
=====================
Date: \${new Date().toLocaleDateString()}
Status: \${stats}
\`
sendAgentEmail(
"reports@example.com",
"Daily PhoneClaw Report",
reportMessage
)
speakText("Daily report sent")
`
// Schedule for 9 AM every day
schedule(dailyReport, "0 9 * * *")
speakText("Scheduled daily email reports")
Email-Based Workflow Triggers
Monitor emails to trigger automated actions:
// Check for specific emails and trigger actions
const checkEmailTriggers = () => {
magicClicker("Email app")
delay(2000)
const subject = magicScraper("Subject of the most recent email")
if (subject.includes("URGENT")) {
// Trigger urgent workflow
sendAgentEmail(
"admin@example.com",
"Alert: Urgent Email Detected",
`An urgent email was detected: ${subject}`
)
speakText("Urgent email detected, notification sent")
}
}
// Run every 15 minutes
schedule(checkEmailTriggers, "*/15 * * * *")
Error Notification System
Send email alerts when automations encounter errors:
const runWithErrorHandling = (taskName, taskFunction) => {
try {
taskFunction()
speakText(`${taskName} completed successfully`)
} catch (error) {
sendAgentEmail(
"admin@example.com",
`PhoneClaw Error: ${taskName}`,
`
An error occurred during automation:
Task: ${taskName}
Error: ${error.message}
Time: ${new Date().toISOString()}
`
)
speakText(`Error in ${taskName}, notification sent`)
}
}
// Example usage
runWithErrorHandling("Social Media Post", () => {
magicClicker("Twitter app")
delay(2000)
magicClicker("Compose button")
// ... rest of workflow
})
Best Practices
- Test email extraction with your specific email app layout
- Use clear, descriptive subjects for automated emails
- Implement error handling to catch failed email operations
- Respect email provider rate limits when sending automated emails
- Use appropriate delays when navigating email interfaces
See Also