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.
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.
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 description
magicScraper(question) - Extract text/data from the screen
You’ll see the main interface with tabs for “Scheduled Tasks” and “Generation History”
Tap the microphone button at the bottom to start creating a script
3
Write the Automation
4
Here’s a complete script that automates posting on Twitter:
5
// Open Twitter appspeakText("Opening Twitter")delay(2000)// Click the compose button (blue button with pen icon)magicClicker("Compose tweet button in bottom right")delay(1500)// Wait for compose screen to openspeakText("Compose screen opened")delay(1000)// Click the text input fieldmagicClicker("Tweet text input field")delay(500)// Type the tweet contentspeakText("Typing tweet")// Note: Text input requires accessibility service// You'll need to manually type or use system input// Click the post buttondelay(1000)magicClicker("Post button in top right")// Confirm completiondelay(2000)speakText("Tweet posted successfully")
6
magicClicker uses vision AI to find elements by natural language description. Be specific but natural: “blue post button” works better than “button”.
7
Understanding the Flow
8
Let’s break down what each part does:
9
Speak and Delay Pattern
10
speakText("Opening Twitter")delay(2000)
11
Provides audio feedback and waits for actions to complete. Always add delays after clicks to let the UI respond.
12
Vision-Based Clicking
13
magicClicker("Compose tweet button in bottom right")
14
Describes the element you want to click. Include location hints (“bottom right”) and visual characteristics (“blue button”).
15
Chaining Actions
16
magicClicker("Tweet text input field")delay(500)magicClicker("Post button in top right")
17
Sequence multiple clicks with delays between them.
18
Test Your Script
19
Before running the full automation:
20
Make sure Twitter is installed and you’re logged in
Test individual commands first:
Copy
magicClicker("Compose tweet button")
Check the PhoneClaw logs to verify elements were found
Adjust delays if actions are happening too fast/slow
21
Run the Automation
22
Save your script in PhoneClaw
Navigate to your device’s home screen
Open Twitter manually (or add app launch logic)
Tap Run in PhoneClaw
Watch PhoneClaw execute each step
23
PhoneClaw requires screen access during automation. Don’t lock your screen or switch apps while the script is running.
Use magicScraper to check if an element exists before clicking:
Copy
magicClicker("Settings button")delay(2000)// Verify settings screen openedconst screenTitle = magicScraper("What is the title text at the top of the screen?")if (screenTitle.includes("Settings")) { speakText("Settings opened successfully")} else { speakText("Error: Settings did not open")}
// Like the first 5 postsfor (let i = 0; i < 5; i++) { magicClicker("Heart icon to like the post") delay(1000) // Scroll to next post magicClicker("Next post below") delay(1500)}speakText("Liked 5 posts")
magicClicker("Open first notification")delay(2000)// Extract the notification messageconst message = magicScraper("What is the notification message text?")speakText("Notification says: " + message)// Use the data in branching logicif (message.includes("mentioned you")) { magicClicker("Reply button") delay(1000) speakText("Opening reply")}
Here’s a complete example that automates Instagram account creation:
Copy
// Navigate to create accountmagicClicker("Create account button")delay(2000)// Fill in emailmagicClicker("Email address field")delay(500)// Type email via accessibility service// Continue to next stepmagicClicker("Next button")delay(2000)// Wait for verification codespeakText("Waiting for verification code")delay(5000)// Extract the 2FA code from screenconst otpCode = magicScraper("What is the 6-digit verification code shown?")speakText("Code received: " + otpCode)// Enter the codemagicClicker("Verification code input field")delay(500)// Type OTP code// Complete setupmagicClicker("Confirm button")delay(3000)speakText("Account created successfully")
This example demonstrates multi-step workflows with verification codes, similar to the Instagram automation shown in PhoneClaw’s demo videos.
If magicClicker can’t find an element, try different descriptions:
Copy
// Try these variations:magicClicker("Blue send button") // color + typemagicClicker("Send button in bottom right") // type + positionmagicClicker("Arrow icon to send") // icon + action