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 globalAndroid object in your automation scripts:
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.Type Safety
ClawScript includes helper functions for safe type conversion:- Numeric parameters accept
Numbertypes or fall back to defaults - String parameters are converted automatically
- Boolean parameters follow JavaScript truthy/falsy rules
Next Steps
Build automations
Explore UI automation for screen interactions
Schedule tasks
Use scheduling for recurring automations