Skip to main content

What is ClawScript?

ClawScript is the JavaScript API exposed to automation scripts running in PhoneClaw. It provides a comprehensive set of functions for controlling Android devices, including:
  • Speech synthesis - Make your device speak text
  • Timing controls - Add delays and schedule recurring tasks
  • UI automation - Click, type, swipe, and interact with screen elements
  • Notifications - Send emails and alerts
  • System utilities - Access device information and settings

Accessing ClawScript

All ClawScript functions are available through the global Android object in your automation scripts:
// Speak text
Android.speakText("Hello, world!");

// Wait 2 seconds
Android.delay(2000);

// Schedule a task
Android.schedule("Android.speakText('Time check')", "0 */5 * * * *");

Core API Categories

Speech

Text-to-speech functionality for voice feedback

Timing

Delays and time-based controls

Scheduling

Cron-based task scheduling

UI Automation

Screen interaction and gesture simulation

Notifications

Email and notification sending

Magic Helpers

AI-powered vision targeting

JavaScript Interface

ClawScript functions are implemented as @JavascriptInterface methods in the Android MainActivity. These functions bridge JavaScript code with native Android capabilities.
All ClawScript functions are synchronous unless otherwise noted. Async operations use blocking calls internally.

Error Handling

Most ClawScript functions include built-in error handling and will log errors to the Android logcat. Failed operations typically speak error messages through TTS.
try {
  Android.sendAgentEmail("user@example.com", "Test", "Message");
} catch (e) {
  Android.speakText("Email failed: " + e.message);
}

Type Safety

ClawScript includes helper functions for safe type conversion:
  • Numeric parameters accept Number types or fall back to defaults
  • String parameters are converted automatically
  • Boolean parameters follow JavaScript truthy/falsy rules

Next Steps

1

Learn the basics

Start with speech and timing functions
2

Build automations

Explore UI automation for screen interactions
3

Schedule tasks

Use scheduling for recurring automations