top of page

I automated my Whatsapp Chats!

Android Accessibility Service to alter the way you use your mobile

I am a big fan of automation. Honestly, in this era of the attention economy, I try creative ways to save my time wherever I can.

So one fine day, when a friend of mine said, "hey can you please remind me to write that essay tomorrow", the inherent spirit kicked in and I ended up coding an Android app that can automatically send messages to her.

And think about that! How interesting the concept is! There is a difference between setting an alarm for yourself and get reminded of stuff and someone texting you to remind you to do something. When a message is sent by a person, it has that special effect! So, I thought, why not use technology to intervene in human lives in a psychologically positive way!

And there it comes: Automate Whatsapp Chats

Yeah, you can use it in A LOT of ways, in fact, once you have learned the technique, you can pretty much automate anything on Android - from automating sending emails, switching songs, clear data, and what not!

This is how the app looks like:

I have used Accessibility Service for it!

What is accessibility service, you may ask?

Accessibility services are a feature of the Android framework designed to provide alternative navigation feedback to the user on behalf of applications installed on Android devices. An accessibility service can communicate to the user on the application's behalf, for example by converting text to speech or providing haptic feedback when a user is hovering on an important area of the screen

I have used the accessibility service to create this automation for myself.

The service enables us to not just view text but also, perform actions on the user's behalf.

So, how can you create similar automation for yourself?

Follow these steps:

1. Define the service and XML config:


<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android=""



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

        <activity android:name=".MainActivity"
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            android:label="Automate Chats WhatsApp"
                <action android:name="android.accessibilityservice.AccessibilityService" />

                android:resource="@xml/accessibility_service_config" />

2. Define the Accessibility Service, extends AccessibilityService


3. Find out the IDs of UI elements that hold the

  1. Name of the person on Whats App

  2. Edit Text (where you type the chat)

  3. ID of the send button. (Note that the send button appears only once the user has typed the text.)

You can use tools like UI Automator to find these IDs.

And there you go!

Once you have the IDs, you can then define the implementation of the method,

public void onAccessibilityEvent (AccessibilityEvent event) { ... }

Get the root from the event nodes, traverse through the tree and find out the nodes having the above IDs acquired in step 3.

Once you have the IDs, you can then use the method performAction to simulate sending the chats:

AccessibilityNodeInfo textBox = getNode(rootNode, chatBoxRefId);
Bundle arguments = new Bundle();
if (convIndex == convs.length -1) {
  arguments.putString(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, "<3");

} else {
  arguments.putString(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, convs[convIndex % (convs.length - 1)]);
    convIndex ++;
textBox.performAction(AccessibilityNodeInfoCompat.ACTION_SET_TEXT, arguments);
AccessibilityNodeInfo sendButton = getNode(rootNode, sendButtonRefId);

So, that is all folks!


Try it out. If you want an already coded app, check out

Have fun

Stay curious and creative, I'll see you in the next post soon!


bottom of page