The most important line is A1. Here we use the installed sqlite to save the time, the sender and the content of the last message stored in the WhatsApp database into a Tasker variable. The values are separated by a "|", the time is in ms and the sender is stored as a phone numer. So there are some conversions needed afterwards.
You may have noticed that there is a call to another task at line A9. WhatsApp saves only the number of the contact who send you the message in its database, so we need to convert the number to a real contact name as saved in your phone book. The task "Number->Name WhatsApp" does it. It searches the address book for contacts associated with a WhatsApp account and returns their name. So after line A10 you should know who texted you by name, you can put in if clauses to react different to different names. Here the description of the "Number->Name WhatsApp" task:

At line A15 of the task "WhatsApp Notification" task I call a Tasker task called "Play Sound". That's because I disabled notification sounds in WhatsApp to handle them myself (They are time and WhatsApp message content depandant). Here an example of how a simple "Play Sound" task could look like:

If headphones are connected or phone is on silent mode no sound is played at all. If the message contains something like "Rrruaaarrrr" a dinosaur roar is played at full volume (even with headphones connected) and the phone vibrates for 4 seconds. If a "Miauuu" is in the message a cats miau is played... I'm sure you can do better :)

You can even make Tasker react on a click on one of the notifications, just add the following profile:

What you want is pretty simple: Take a look at the action "Popup". You can find it under "Alerts". You can even create a custom Scene to make to Popup look more iOS style. Just go to "Scenes", clone the original Popup scenery and modify it to your needs. Hope this helps :)

Few more thing, original whatapp notification is not cancelled. How to deal with that? And the notification doesnt show up when the contact is not linked with any name. How to make it show the number instead of not showing up at all?

For me it is displayed with the number when no contact was found, look at the task corresponding to return the name:A2: If [ %sql_result_name !~R sql_result_name ]A3: Return [ Value:%sql_result_name Stop:On ]A4: ElseA5: Return [ Value:%par1 Stop:On ]A6: End IfIf no name was found (%sql_result_name is set to the value "sql_result_name") then return the passed variable without modifications (return %par1). You can improve the task a little bit by removing the Wait Until line A10 in the WhatsApp Notification Task and set the priority of the task call in A9: Perform Task [ Name:Number->Name WhatsApp ] to the value 9.To display the number make a variable search-replace. Replace the string "@s.whatsapp.net" with nothing "".

I haven't found a way to suppress the WhatsApp notifications yet.... My workaround is to cancel my own notifications as soon as they are showed. So that only the original WhatsApp notifications are displayed in the notification menu. So I have two additional lines before A15 in the WhatsApp notification task:A13: Wait [ MS:50 Seconds:0 Minutes:0 Hours:0 Days:0 ]A14: Notify Cancel [ Title:%WHATSAPP_NOTIFY1 Warn Not Exist:Off ] If [ %DISPLAYON is 1]So I can read the notification and react on it with Tasker, even have it read aloud (see http://technologyworkroom.blogspot.de/2013/06/taskermake-tasker-read-aloud-all.html), but it doesn't block the notification menu place.

Alright, I have changed to the code that u gave me. Thanks. Hopefully it works. My next problem is group messaging. Because it doesnt give the name of the group and its sender. Please help. Sorry for troubling u so much.

The problem with this is that messages from groups are stored as "admin_number-group_number@g.us" or something like that.. So even if you split the sql_result3 you won't be getting the sender's number. I don't think there's a workaround for this, because most probably group names are stored on whatsapp servers.

What you CAN do is manually store the group's number in Global variables so you can add something like this:

Then you create a new task where you have a few comparisons between the param passed and the "numbers@g.us" you already know, as to set the return value to the corresponding name..

Personally I think that's too much work, so I'd just split the variable and add "Set variable $sql_result3 To 'Message in Group' If $sql_result32 is Set" And change the following appearances of $sql_result3 to 31, which works even if the split didn't happen.

That looks very great. I will try it this evening. I assume this could also be adapted for other messenger like Line or Viber. What do you think? Could the SQLite also be used to send messages in Whatsapp?

It is possible! And I'm currently investigating it. I want to make a hands-free voice activated interaction with WhatsApp, so its crucial to be able to send messages trough Tasker. I will post an article about this as soon as it's running satisfactorily.

Sounds good. Thanks for your reply. :) I just googled a little bit, and there is another way suggested here: http://geekswithblogs.net/shauryaanand/archive/2012/11/09/151216.aspx I thought maybe you are interested in reading it.

Currently I get thousand ideas what to do with it... :) I could imagine to use this technique along with others to improve my networking and relationships by sending out messages and responding automatically based on

- different occasions that are defined in Google Calendar entries (like birthdays),

- different contexts, locations and times (at work, in the city, at home, holiday, weekend, workday, day, night, etc.)

It is more complicated then I thought... WhatsApp has an restriction to only one account per phone number and the sended messages got signed by their servers which only accept messages from one client. So if I would find a way to send messages from my number without the WhatsApp program the WhatsApp app would stop working. Only one client allowed... I'm still looking into this... but I don't have an Android phone any more, because my S3 died from Sudden Death.. I hope it will be repaired soon and I can continue to work on this... :(

Really thinking about getting one of this chinese android phones.. iOcean X7 Elite or something similar....

i basically want my phone to say "Meow" when i get a whatsapp message from a specific person. how do i do that? do i need to Root and install SQLite and Ipack for that? which of the import files do i download from this article?

Thank you so much for this awesome Piece! Im quite close to be able to use it in my profiles - but there's a problem with resolving the phonenumber to the plain name. It doesnt store the output. For debugging, i let tasker show the errors. In return, i get:Error: near "491234567890": syntax errorI tried it with playing around with sync1 to sync4. the variable that needs to get is resolved is all fine, its in the format "491234567890@s.whatsapp.net"

:-/ Maybe you can provide me a hint, what is going wrong there? That'd be awesome! Thanks in advance!

Uhm - i was blind! Note to myself: '" may look like ", but aint the same at all :-) While altering the code to fit my needings i was a bit too fast.Its workin like a charm. Thank you for the great piece of Taskercode!

Hello..I am trying the commands listed above..one thing I noticed is that the msgstore.db is actually encrypted and in full it's actually msgstore.db.crypt. I am rooted but also noticed no one else here got this problem. What am I doing wrong? How we I get access to the db file?

Hi Benny, thank you for your awesome script. It works perfectly and I used it as a basis to get Hangout notifications working as well.

For the people who wish to resolve group hangout names, in the WhatsApp statusbar script, a simple change will give the user the data they need. Change the command to the following and ensure that you have single quotes when checking remote_resource:

sqlite3 /data/data/com.whatsapp/databases/msgstore.db "SELECT timestamp,data, case WHEN remote_resource is '' THEN key_remote_jid ELSE remote_resource END FROM messages WHERE key_from_me='0' ORDER BY timestamp DESC LIMIT 1;"

Hi sorry I'm a bit confused, This is for whatsapp and not just for Hangouts right? So I just replace A1: Run Shell [ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "SELECT timestamp,data,key_remote_jid FROM messages WHERE key_from_me='0' ORDER BY timestamp DESC LIMIT 1;"with the above lines? Thanks a lot for all your great work!

Hello again. Found a way to it. Changed the call line to "A9: Perform Task [ Name:NameWhatsApp Stop:" and changed the Task name accordingly to "NameWhatsApp" with no extra chars and no spaces and it works fine now. My device is a Galaxy S2 rooted.Thanks for this great code.JF - Venezuela

I have modified this tasker profile to work better with groups. It recognizes if the msg is from a group or person by analysing the number of elements of sql_result. If it's from a group it's put in the format NAME @ GROUP : MESSAGE. If it's from a person it's just NAME : MESSAGE.

With 0 experience with any databases, sql and not too much exerience with tasker either it took me quite some time, but got it done. If there is anyone that wants it post here and i'll upload the project.

About done with my WhatsApp project which was started by this post. Took it a little further, for more information see: http://www.reddit.com/r/tasker/comments/1q7okn/readingsending_whatsapp_messages_from_the/

You may have noticed that there is a call to another task at line A9. WhatsApp saves only the number of the contact who send you the message in its database, so we need to convert the number to a real contact name as saved in your phone book. The task "Number->Name WhatsApp" does it. It searches the address book for contacts associated with a WhatsApp account and returns their name.