Skip to main content

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:
  1. Opens Twitter
  2. Finds and clicks the compose button
  3. Types a message
  4. 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 description
  • magicScraper(question) - Extract text/data from the screen
  • delay(ms) - Pause execution
  • speakText(text) - Provide audio feedback
  • schedule(task, cronExpression) - Schedule recurring tasks

Your First Script

Common Patterns

Waiting for Elements to Appear

Use magicScraper to check if an element exists before clicking:

Looping Actions

Repeat actions with standard JavaScript loops:

Extracting Data

Read on-screen text with magicScraper:

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

If magicClicker 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