Automate WhatsApp completely in background with whatsmeow library.

sampleuserhere

Active member
Recently, a redditor in r/tasker shared a project to automate whatsapp with whatsmeow library. The library and the project itself work great in Tasker. I could send and receive the messages just fine.



Now, This is where it gets interesting. Upon inspecting the project, I got to know that the project uses a local server to communicate with the library. The workflow is simple, It posts JSON data to the server to send the messages. What does this mean?

We can send the message as well with Macrodroid using HTTP Request!


To be precise, the JSON data contains the accepted arguments for mdtest. They must be stored under "args" key as an array. Example, here's what I should write if I were to send a message via terminal.

Code:
cd "dir for mdtest"
./mdtest send number text

Then, If I were to do the same stuff, the JSON data needs to be constructed like this.

Code:
{"args":["send","number","text"]}

Now, here's the query in action.

It was sent successfully!

Unfortunately, this is the only part I could interact directly with the local server. Receiving message and initiating the server ( It gets killed often ) requires Tasker to interact directly with the server. Technically it's running as tasker's process so that's to be expected.

However I can always forward every incoming messages via intent broadcast and I can also open up another port so Macrodroid can interact directly with Tasker via HTTP Request.

Now what's else can we do with this library besides sending and receiving message?

  • Mark as read
  • Revoke messages
  • Download Media Messages (New!)
    Now includes downloading media like:-
    • Images
    • Videos
    • Audio
    • Documents
    • Status
    • Contacts
    • Link previews
    • Location previews
  • Mute/Unmute chats (New!)
  • Pin/Unpin chats (New!)
  • Archive/Unarchive chats (New!)
I personally use this to forward the messages to Telegram.


Tasker is not a must

You can always interact with mdtest via Termux. The redditor also shared the basic guide in the github page above, you can check them out. I haven't tried that yet though.


Closure

I personally find the project a good news in a way, so I'd like to share it to the community. Hopefully this post could shed some lights to those who seeks a way to automate WhatsApp fully in background. Cheers!

https://www.reddit.com/r/tasker/comments/15ydqa1
 

Abdullah89

New member
However, if "whatsmeow" is a library that allows automation of WhatsApp, you can typically use it in Python to interact with WhatsApp programmatically. Here's a generic outline of what you might do using a hypothetical library:

pythonCopy code
# Import the necessary modules from the whatsmeow library
from whatsmeow import WhatsApp

# Initialize the WhatsApp object
whatsapp = WhatsApp()

# Log in to your WhatsApp account (assuming you've set up the necessary credentials)
whatsapp.login()

# Find a contact or group
contact = whatsapp.find_contact('John Doe')

# Send a message
whatsapp.send_message(contact, 'Hello, John!')

# Receive messages (you may run this in a loop for continuous listening)
messages = whatsapp.get_messages()

# Process received messages
for message in messages:
print(f'{message.sender}: {message.content}')

# Log out when you're done
whatsapp.logout()

Please note that this is a generic example and may not work with the actual "whatsmeow" library if it exists, as I don't have specific information about it.
 

Endercraft

Moderator (& bug finder :D)
Now that seems like an AI generated response.
Yeah, pretty much every AI generated post here has some link hidden in a dot or other small character on straight up having a link inserted inside. Instead of banning them we have a little fight where I'll remove the link, they add it back and I remove it again :)
 

sampleuserhere

Active member
Yeah, pretty much every AI generated post here has some link hidden in a dot or other small character on straight up having a link inserted inside. Instead of banning them we have a little fight where I'll remove the link, they add it back and I remove it again :)

I thought it was automod or something, so the mods have been doing this manually. I saw a couple of them recently. That's some fights you guys have there 👍
 
Top