Whatsapp

2,406 views
Skip to first unread message

Ewald Kleefstra

unread,
Feb 27, 2012, 4:06:02 AM2/27/12
to Tasker
Hi everyone,

I am trying to get a context with whatsapp working. I want that my
profile does something when a specific contact writes something in
whatsapp. Is that possible?

Amer

unread,
Feb 28, 2012, 6:02:31 AM2/28/12
to tas...@googlegroups.com
you can check the spesific contact by checking the notification but I don't have a clue about reading the message
--


Be first, be better, or cheat.™

Dennis

unread,
Feb 29, 2012, 11:33:48 AM2/29/12
to Tasker
In case you're rooted you can get the last message you received via:
sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select data
from messages WHERE key_from_me='0' ORDER BY _id DESC LIMIT 1;"
In the same folder there's a db holding the name to the cryptic
key_remote_jid; somehow figured out how to match those but I can't
find it now.
In case you don't want to match too many people you can obviously do
that manually by just saving their WhatsApp id.
It would be great if anyone could figure out how to send things via
WhatsApp, just like replying to SMSes! Please let me know!

On Feb 28, 12:02 pm, Amer <moamer.khad...@gmail.com> wrote:
> you can check the spesific contact by checking the notification but I don't
> have a clue about reading the message
>
> On Mon, Feb 27, 2012 at 4:06 PM, Ewald Kleefstra
> <ewald.kleefs...@gmail.com>wrote:

Oon-Ee Ng

unread,
Aug 7, 2012, 2:10:09 AM8/7/12
to tas...@googlegroups.com
Decided to play around with this a bit, its actually quite simple.

Get the sender ID from remote_resource in the messages table (if its a
group message) or key_remote_jid (if its not). Then you can take that
key and match it against the wa_contacts table, the display_name
column.

So the sequence of sqlite commands goes something like (still in testing):-
1. sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select
remote_resource from messages WHERE key_from_me='0' ORDER BY _id DESC
LIMIT 1;"
2. if the output is blank, go to 3, otherwise go to 4.
3. sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select
key_remote_jid from messages WHERE key_from_me='0' ORDER BY _id DESC
LIMIT 1;"
4. Save the output of either 1 or 3 to some variable %WHATSAPPID
5. sqlite3 /data/data/com.whatsapp/databases/wa.db "select
display_name from wa_contacts WHERE jid='%WHATSAPPID';"

Quite simple, really, once I read that whatsapp uses an SQL database.
Should be possible to write helper kid apps for whatsapp as well... if
I ever get the time.

On Sat, Jul 28, 2012 at 6:08 PM, Andrea Z. <kro...@gmail.com> wrote:
> Works fine, but how to grab the sender name?

Hussain Ali Nasser

unread,
Aug 9, 2012, 12:15:42 AM8/9/12
to tas...@googlegroups.com
Can you please attach your xml file and share the task? :D

Oon-Ee Ng

unread,
Aug 9, 2012, 1:55:42 AM8/9/12
to tas...@googlegroups.com
Yeah, I guess, not right now, am at work =)

Andrea Z.

unread,
Aug 9, 2012, 2:53:02 AM8/9/12
to tas...@googlegroups.com
me too want the xml :-)

Hussain Ali Nasser

unread,
Aug 9, 2012, 3:05:33 AM8/9/12
to tas...@googlegroups.com
Cheers mate!

Oon-Ee Ng

unread,
Aug 10, 2012, 5:21:08 AM8/10/12
to tas...@googlegroups.com

Here it is =)

Get Whatsapp Details (134)
A1: Variable Clear [ Name:%WHATSAPP_MSG Pattern Matching:Off ]
A2: Variable Clear [ Name:%WHATSAPP_NAME Pattern Matching:Off ]
A3: Variable Clear [ Name:%WHATSAPP_ID Pattern Matching:Off ]
<Get whatsapp message>
A4: Run Shell [ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select data from messages WHERE key_from_me='0' ORDER BY _id DESC LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Result In:%WHATSAPP_MSG ]
<Get whatsapp sender id part 1>
A5: Run Shell [ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select remote_resource from messages WHERE key_from_me='0' ORDER BY _id DESC LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Result In:%WHATSAPP_ID ]
A6: If [ %WHATSAPP_ID ~ +WHATSAPP_ID ]
A7: Variable Clear [ Name:%WHATSAPP_ID Pattern Matching:Off ]
<Get whatsapp sender id part 2>
A8: Run Shell [ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "select key_remote_jid from messages WHERE key_from_me='0' ORDER BY _id DESC LIMIT 1;" Timeout (Seconds):0 Use Root:On Store Result In:%WHATSAPP_ID ]
A9: End If
<Get whatsapp sender name>
A10: Secure Settings [ Configuration:Get Whatsapp Name (Root) Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A11: Wait Until [ MS:50 Seconds:0 Minutes:0 Hours:0 Days:0 ] If [ %WHATSAPP_NAME Is Set ]
A12: Variable Set [ Name:%WHATSAPP_NAME To:Unknown number Do Maths:Off Append:Off ] If [ %WHATSAPP_NAME ~ +WHATSAPP_NAME ]
A13: Flash [ Text:%WHATSAPP_NAME said %WHATSAPP_MSG Long:Off ]

Get_Whatsapp_Details.tsk.xml

Oon-Ee Ng

unread,
Aug 10, 2012, 5:21:44 AM8/10/12
to tas...@googlegroups.com

Please note, you'll need root and secure settings

Andrea Z.

unread,
Aug 10, 2012, 5:29:39 AM8/10/12
to tas...@googlegroups.com
thanks, it works good and it's really nice to study... i will surely learn something more on tasker.
What conditions you use to launch the profile? Notify from whatsapp? I also see there is some encoding issue, italian letters like à è ì are transformed in some wrong way

Andrea Z.

unread,
Aug 10, 2012, 6:20:25 AM8/10/12
to tas...@googlegroups.com
There is another problem, %WHATSAPP_NAME at the end of the task contains 2 times the same name. For example: "Andrea Andrea"

Oon-Ee Ng

unread,
Aug 10, 2012, 11:35:28 AM8/10/12
to tas...@googlegroups.com

That's the display name whatsapp uses, there's other fields in the SQL for first name and last name as I recall.

And I don't use it, yet. You'd just call it as an external task, maybe in response to a file change event?

Andrea Z.

unread,
Aug 10, 2012, 11:50:14 AM8/10/12
to tas...@googlegroups.com
Maybe I did not explained well... for a contact called "john doe" on whatsapp, with your task %WHATSAPP_NAME became "john doe john doe". Maybe i can do some variable split if there is a problem fixing this, but maybe you are able to find a better way.

For the profile to call this task, i was thinking to use event-->notification (and specify whatsapp as the app).
Did you also have some idea on how to change the encoding to UTF-8? italian words like "perchè" becomes "perchA (and some weird character)... it really seems a caracter encoding problem

Oon-Ee Ng

unread,
Aug 10, 2012, 11:53:33 AM8/10/12
to tas...@googlegroups.com

Works for me. Check your whatsapp SQL database, the query just extracts what's in there.

And I don't know anything about encoding, sorry

Andrea Z.

unread,
Aug 10, 2012, 11:56:12 AM8/10/12
to tas...@googlegroups.com
Can you please explain to me this line:


A6: If [ %WHATSAPP_ID ~ +WHATSAPP_ID ]

It's the only thing in don't understand in the task

Oon-Ee Ng

unread,
Aug 10, 2012, 11:58:51 AM8/10/12
to tas...@googlegroups.com

Read the user guide on pattern matching. That's one hack for checking for blank variables

Andrea Z.

unread,
Aug 10, 2012, 12:04:08 PM8/10/12
to tas...@googlegroups.com
ok thanks... and:

A12: Variable Set [ Name:%WHATSAPP_NAME To:Unknown number Do Maths:Off Append:Off ] If [ %WHATSAPP_NAME ~ +WHATSAPP_NAME ]
what's the purpose? %WHATSAPP_NAME was not already set by A10/A11?

sorry to ask so much questions

Oon-Ee Ng

unread,
Aug 10, 2012, 7:15:14 PM8/10/12
to tas...@googlegroups.com

It does exactly what it says...

Andrea Z.

unread,
Aug 22, 2012, 11:41:10 AM8/22/12
to tas...@googlegroups.com, ewald.k...@gmail.com
did somebody knows how to do the same with google talk? :-)

Matt R

unread,
Aug 22, 2012, 12:24:54 PM8/22/12
to tas...@googlegroups.com, ewald.k...@gmail.com
You can trigger off UI -> Notification event with GTalk as the owner app.  You may need to manually change the GTalk package name in the XML (search this forum for google talk package notification or something).  You can then get the GTalk message from %NTITLE.  Works for me.
 
Matt

Pascal Reid

unread,
Sep 20, 2012, 3:11:51 AM9/20/12
to tas...@googlegroups.com
I imported this directly and it just won't do anything when I try to run the task. I'm rooted, I installed the secure settings app and whatsapp obviously. I can see the database when I navigate through it in rootexplorer but tasker won't return anything from the shell command. Am I missing something or what could cause this to not work properly?

Hussain

unread,
Sep 20, 2012, 4:44:31 AM9/20/12
to tas...@googlegroups.com
Maybe you don't have SQLite, like me.

I have a SGS2 and have no clue about how I can install it. :(

Pascal Reid

unread,
Sep 20, 2012, 10:10:34 AM9/20/12
to tas...@googlegroups.com
from what i was reading, sqlite functions are built in android directly. I also installed sqlite editor and made no difference. I'm running jelly bean on a galaxy nexus. I have a few other phones that i can run different version on, I'll give that a shot. Anyone else has any idea what could be the issue ? I tried inserting a pop up after the first run shell command and nothing comes up. Seems to break at that point. I see that tasker is granted root but that's about all that it does.

Oon-Ee Ng

unread,
Sep 20, 2012, 7:58:18 PM9/20/12
to tas...@googlegroups.com

Run the commands via adb or a terminal emulator.

Pascal Reid

unread,
Sep 20, 2012, 8:37:25 PM9/20/12
to tas...@googlegroups.com
That's what I was doing and it wasn't working. I tried on my nexus s running ICS and it's working fine there. No idea why it's not working on JB. I'll be running my queries from ICS from now on. Thanks for the help

Oon-Ee Ng

unread,
Sep 20, 2012, 8:55:15 PM9/20/12
to tas...@googlegroups.com
On Fri, Sep 21, 2012 at 8:37 AM, Pascal Reid <pasca...@gmail.com> wrote:
> That's what I was doing and it wasn't working. I tried on my nexus s running ICS and it's working fine there. No idea why it's not working on JB. I'll be running my queries from ICS from now on. Thanks for the help

It's your ROM (maybe something to do with the busybox, not sure if sql
is included in the standard busybox). My CM10-based SGS2 works fine.

Hussain

unread,
Sep 20, 2012, 11:42:22 PM9/20/12
to tas...@googlegroups.com
I have a stock + rooted ICS ROM for my SGS2. Don't know why it isn't installed, and for the life of me, can't figure out how to install it either.

Hussain

unread,
Sep 21, 2012, 3:15:11 AM9/21/12
to tas...@googlegroups.com

stefano galletti

unread,
Oct 13, 2012, 6:07:44 AM10/13/12
to tas...@googlegroups.com
I'm with JB and Galaxy s3, no way to work,,,i've tried with tasker "run script", with secure setting , run command in android terminal emulator, same result....NOTHING, i've installed sqlite for root, like hussain , but no difference, any help?

Ron Nissim

unread,
Nov 8, 2013, 2:17:37 AM11/8/13
to tas...@googlegroups.com
hey! This looks like exactly what Ive been looking for, but could someone please tell me what things I need to change in the task if there are things and what the xml does exactly? sorry for being the newbie...

Julio García Muñoz

unread,
Dec 4, 2013, 5:16:36 PM12/4/13
to tas...@googlegroups.com, ewald.k...@gmail.com
Just in case somebody stumbles upon this old thread...I made a free plugin to automate intercepting WhatsApp notifications and sending messages. Feel free to give it a try:

פיצה אילת

unread,
Mar 3, 2016, 4:03:35 PM3/3/16
to Tasker
Hallo I downloaded and installed this xml file but it's not working for me i don't know why.
The run shell comand is giving me red spot and i get no resolts .
Somebody know why?

Leo Edwards

unread,
May 22, 2016, 11:08:38 PM5/22/16
to Tasker
Okay, I only have a basic understanding of Tasker but have installed it along with Python for Android and SL4A. Nowhere in Tasker does it mention Whatsapp in any context, so how can I create and event of whatsapp message being received to be able to forward it?

I have a UK phone I want to auto forward Whatsapp messages on to my US number automatically but have no idea where to start?

Richard Kemp

unread,
May 24, 2016, 12:39:11 PM5/24/16
to Tasker
"Touchless chat" app includes a Tasker plugin with whatsapp conditions and actions. Also works with a few other messenger apps.
Reply all
Reply to author
Forward
0 new messages