Overview
This guide walks you through creating your first automation workflow with PhoneClaw. You’ll learn how to use ClawScript’s core functions to click buttons, wait for actions, and chain commands together.What You’ll Build
A simple automation that:- Opens Twitter
- Finds and clicks the compose button
- Types a message
- Posts the tweet
This example uses Twitter, but the same patterns work for any Android app. PhoneClaw uses the Accessibility API to interact with UI elements across all apps.
Understanding ClawScript
ClawScript is a JavaScript-based scripting language that runs inside PhoneCalk using an embedded JS engine. It provides helper functions for automation:magicClicker(description)- Find and tap UI elements by descriptionmagicScraper(question)- Extract text/data from the screendelay(ms)- Pause executionspeakText(text)- Provide audio feedbackschedule(task, cronExpression)- Schedule recurring tasks
Your First Script
Common Patterns
Waiting for Elements to Appear
UsemagicScraper to check if an element exists before clicking:
Looping Actions
Repeat actions with standard JavaScript loops:Extracting Data
Read on-screen text withmagicScraper:
Error Handling
Add try-catch blocks for robust automation:Real-World Example: Instagram Login
Here’s a complete example that automates Instagram account creation:This example demonstrates multi-step workflows with verification codes, similar to the Instagram automation shown in PhoneClaw’s demo videos.
Debugging Your Automation
Use Speaking for Progress Tracking
Test Element Descriptions
IfmagicClicker can’t find an element, try different descriptions:
Check Delays
Adjust timing based on your device speed:Next Steps
Voice Command Generation
Generate scripts by describing what you want
Schedule Recurring Tasks
Run automations on a cron schedule
Multi-App Workflows
Chain actions across multiple apps
ClawScript API
Full reference for all functions