Geeks With Blogs
$håùrÿá @ñäñd "Imagination is more important than knowledge."

So, I finally gave up on all my previous the Microsoft Mobile/Phone OS devices and made my switch to Android this year. I am using my Samsung Galaxy Note GT-N7000 with CyanogenMod 9.1.0 ( and ClockworkMod ( since August this year and I am so happy with the performance and the flexibility it offers me. As a software developer by profession, I would expect most of my gadget to be highly customizable and programmable (one time or at intervals) to suit my needs as close as it can.

I was introduced to Automation for Android – Tasker ( via reddit ( and the word ‘automation’ was enough for me to dive right into this app. Only automation that I did earlier was switching profiles depending on location on there phones. And now, just imagine a complete set of possibilities that can be automate on the phone or via the phone. I did my research and found a couple of other tools that do the same/as close as what Tasker can do and few of them are even free. There’s one even by Microsoft called on{X} ( Microsoft’s on{X} really caught my eye. You can write code for your phone on the web application by them, deploy it on your phone and even trace the flow all using your PC. Really brilliant, I love the fact that it’s all JavaScript. Here comes the but, it is still very very young and it’s policy of accessing my News Feed on Facebook is not something that I can not digest.


On{X} is good, but as I said earlier, the API is not very mature and hence, I gave up on it. I bought Tasker, the best 5,00 € I spent in ages and I want to talk about it in this post. I am still a “noob” while operating this tool, but I tried my shot at automating WhatsApp (, a popular messenger for various platform.

The requirement for the automation is that, if I send a WhatsApp ‘wru’ message to the phone, it should respond back giving the location and battery level of my phone. It could be useful, if you like to locate your misplaced phone or automatically reply to your partner/friend, honestly, I don’t know what you will use it - through this post, I am just introducing automating WhatsApp using Tasker.

Before we begin, the following script only works when your phone is rooted as we will be accessing the WhatsApp database and type some special characters like ‘:’.

Let’s follow the code line by line:

        Location request from XYZ. (12) // Name of your profile.

        Notification [ Owner Application:WhatsApp Title:* ] // When a new notification comes from WhatsApp, this event is fired.
Read the end note, if you face problems with Chrome app after enabling Tasker accessibility.

        A1: Run Shell [ Command:sqlite3 // We will access the WhatsApp database and check if the message comes from designated phone number or not. We mustn’t reply to every message.
                /data/data/com.whatsapp/databases/msgstore.db "SELECT _id, data FROM 
                messages WHERE key_from_me='0' AND key_remote_jid LIKE '%XXXXXXXXXXX%' // Replace XXXXXXXXXXX with the phone number of your message sender.
                ORDER BY _id DESC LIMIT 1;" Timeout (Seconds):10 Use Root:On Store // I made a timeout for 10 seconds, if in case WhatsApp is busy accessing the database.
                Result In:%WHATSAPP_CURRREQ ] // Store the read Id and the last message on to the variable %WHATSAPP_CURRREQ

        A2: If [ %WHATSAPP_CURRREQ ~R .*[wW][rR][uU].* ] // Check if the pattern of the message is correct and we are all set to send the location.

                A3: If [ %WHATSAPP_CURRREQ !~ %WHATSAPP_LASTREQ ] // Verify that the message is different from the last request. Remember every message has a unique Id.

                        A4: Notify [ Title:WhatsApp location request... Text:Sending location // Just a notification that the location message is being prepared.
                                to Kavita Gupta... Icon:<icon> Number:0 Permanent:On Priority:3 ] // Make a note it is a permanent notification, we will clear it later.

                        A5: Secure Settings [ Configuration:Pattern Lock Disabled // I am disabling the pattern lock, that I use using the plugin Secure Settings.
                                Package:com.intangibleobject.securesettings.plugin Name:Secure // You can download the plugin from here:
                                Settings ]
                        A6: Secure Settings [ Configuration:Keyguard Disabled // Disable the keygaurd, it is useful, when your phone is on lock and you want to automate everything, even the typing.
                                Package:com.intangibleobject.securesettings.plugin Name:Secure
                                Settings ]
                        A7: Secure Settings [ Configuration:GPS Enabled // Pretty clear, turn on the GPS and get location at A8
                                Package:com.intangibleobject.securesettings.plugin Name:Secure
                                Settings ]
                        A8: AutoShortcut [ Configuration:WhatsApp: Some One // I am using AutoShortcut plugin ( to start WhatsApp with the indented recipient.
                                Package:com.joaomgcd.autoshortcut Name:AutoShortcut ] // Replace Some One, actually choose it from the plugin, the right recipient.

                        A9: Get Location [ Source:Any Timeout (Seconds):30 Continue Task // I am getting the location, timeout is 30 seconds, adjust it accordingly.
                                Immediately:Off Keep Tracking:Off ]

                        A10: Secure Settings [ Configuration:Screen Dim // Now, this extension of the plugin Secure Settings, wakes your device so that you can type out the string on the WhatsApp app.
                                5 Seconds Package:com.intangibleobject.securesettings.plugin
                                Name:Secure Settings ]

                        A11: Run Shell [ Command:input text // Now, I am using the shell script to type the text to the window, because the ‘:’ while not be typed from the Type task in Tasker.
                       Timeout (Seconds):0 Use Root:On // And also, this is way faster, but remember you need root for this, not for the other way of typing.
                                Store Result In: ]
                        A12: Dpad [ Button:Right Repeat Times:1 ] // Focus the Send button
                        A13: Dpad [ Button:Press Repeat Times:1 ] // And press it.
                        A14: Dpad [ Button:Left Repeat Times:1 ] // Get back to the typing box.

                        A15: Run Shell [ Command:input text LOCATION_ACCURACY:%LOCACC Timeout
                                (Seconds):0 Use Root:On Store Result In: ]
                        A16: Dpad [ Button:Right Repeat Times:1 ]
                        A17: Dpad [ Button:Press Repeat Times:1 ]
                        A18: Dpad [ Button:Left Repeat Times:1 ]

                        A19: Run Shell [ Command:input text BATTERY_LEVEL:%BATT% Timeout // I am adding Battery level in my case as well.
                                (Seconds):0 Use Root:On Store Result In: ]
                        A20: Dpad [ Button:Right Repeat Times:1 ]
                        A21: Dpad [ Button:Press Repeat Times:1 ]

                        A22: Variable Set [ Name:%WHATSAPP_LASTREQ To:%WHATSAPP_CURRREQ Do // And now, we say, request is done.
                                Maths:Off Append:Off ]

                        A23: Button [ Button:Back ] // I am exiting the WhatsApp nicely and not killing it. If you are the murderer kind, kill it, just know, you don’t have any place in the heaven.
                        A24: Button [ Button:Back ]

                        A25: Notify Cancel [ Title: Warn Not Exist:Off ] // Remove the permanent notification.
                        A26: Notify [ Title:WhatsApp location request Text:Location sent // Make a temporary notification, and say, location is sent.
                                successfully. Icon:<icon> Number:0 Permanent:Off Priority:3 ]
                        A27: Secure Settings [ Configuration:GPS Disabled // Disable all the horrible things we turned on earlier.
                                Package:com.intangibleobject.securesettings.plugin Name:Secure
                                Settings ]
                        A28: Secure Settings [ Configuration:Pattern Lock Enabled
                                Package:com.intangibleobject.securesettings.plugin Name:Secure
                                Settings ]
                        A29: Secure Settings [ Configuration:Keyguard Enabled
                                Package:com.intangibleobject.securesettings.plugin Name:Secure
                                Settings ]
                A30: End If
        A31: End If


Download this Task from here:

That’s it in the above small example – you can read/write messages from/to WhatsApp app. I am using n7000-cm9.1-cwr6. Oh yea, and if you are having the Talkback auto enabled for Chrome browser, you need to turn Off the Web scripts to run.

Tasker is amazing, I have automated a lot of tasks using this tool. I will share a few none generic ones with you in my coming post here.

Posted on Friday, November 9, 2012 5:18 PM | Back to top

Comments on this post: WhatsApp & Tasker for Android – Read & Write messages

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Thanks a loot. Just the one i was looking for :D Tasker is the best !!!!
Left by Oasa on Nov 17, 2012 8:06 AM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
amazing!!! realy cool!
Left by re on Jan 30, 2013 7:31 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
does this need the phone to be rooted?
Will i be able to run sqlite3 without being rooted?
Left by Soli on Feb 12, 2013 6:38 AM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Oops sorry just read that it needs to be rooted.
Is there any way to run sqlite3 without being rooted? i'd be gr8ful to know
Left by Soli on Feb 12, 2013 6:40 AM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Hello Sir
can u kindly help me with an issue related to whatsapp, i am trying to configure whatsapp to send a broadcast for over “25 contacts” which is the current limit set by the whatsapp owners, or some script to tweak whatsapp, like send 25 contacts then another 25…
you feedback is appreciated
Thank you in Advance
Left by Ghassan on Feb 24, 2013 11:38 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
I want to receive and respond to my girlfriend's whatsapp messages from my tablet. So far I'm able to receive and respond to messages from tablet, but:

- when the messages are coming at a very high speed, one after another, I don't receive on my tablet all of the messages, only some of them. let's say if she sends the following messages: A, B, C, D, E, i will receive notifications only for A and E. Is there anyway to receive all of these messages?


Left by MikeSP on Mar 17, 2013 2:14 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Nice, I'll be using this to make some "I'm driving my car/sleeping/working/..." automatic messages as a response to someone calling me when certain conditions are true (something like a navigation app is running + average speed over the last minute was larger than 15 km/h = I'm driving)
Left by Jelle on Apr 24, 2013 9:57 AM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
i'm using note 2 (GT-N7100) and i tried to use autoshortcut to send whatsapp message using time conditions. it's not opening whatsapp but Google Search (Google Now) and the text type there...can somebody help me? My phone is rooted

AutoShortcut [ Configuration:WhatsApp: Some One]
Type [Text: test , Repeat Times:1]
Dpad [Button: Right, Repeat Times:1]
Dpad [Button: Press, Repeat Times:1]

Left by najsss on Apr 26, 2013 3:41 AM

# Problems with my WhatsApp – What do I do?
Requesting Gravatar...
Some details if you have problem with whatsapp
nice link hope you like it..
Left by Julia Jackson on Sep 09, 2013 7:20 AM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
u don't need autoshortcut to select contact from whatsapp, secure setting can do that to from execute shortcut
Left by JOKERz on Sep 23, 2013 7:06 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Very nice, but my WhatsApp stores stuff in a file called msgstore.db.crypt. I guess a sql query in this files would not work =/ Any solution in mind? Thanks.
Left by Marcelo on Sep 25, 2013 6:35 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...

I am not a computer programmer, but I thought I could pick on your brains to see how I can solve one problem.

I currently have an automatic service that sends daily SMSes to some of my customers. These daily SMSes contain some business information. There is a chronjob on a server that triggers these SMSes.

Instead of sending SMSes, I want to send these messages to business owners using Whatsapp. Here is what I am hoping for:

- Use a dedicated Android phone as a standalone automation machine
- SMS will generate from our server
- An automation script will read the SMS and the sender number, locate the same sender number in Whatsapp and send the same message there

Is this possible? Thanks!
Left by Sanjay on Apr 04, 2014 12:57 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
Nobody received a mistake like mine "only position independent executables (PIE) are supported" ?
I knew this problem is referred to Android L and successive...
Left by Francesco on Jul 25, 2016 4:32 PM

# re: WhatsApp & Tasker for Android – Read & Write messages
Requesting Gravatar...
This Lineage OS For Samsung is an open-source Operating system for smartphones which are using Android Operating System.
Left by Khan Saab on Apr 16, 2017 1:35 PM

Your comment:
 (will show your gravatar)

Copyright © Shaurya Anand | Powered by: