Tech Talks

Building a WhatsApp Bot that doesn’t get blocked

By 22/05/2018 No Comments

Today we are in the bot era (a while ago actually) but still there, bots are everywhere and businesses are changing towards micro apps and cognitive bots for B2B and B2C.

Everyone wants a WhatsApp Bot but WhatsApp doesn’t support Bots (officially, for now).

We (users) want this, because is where we are and is cool 🙂

There are a few libraries to make your own WhatsApp Bot, the most popular is https://github.com/tgalal/yowsup/wiki.

It’s an awesome library but it has one little problem…

and the list goes on…

The problem here is a design problem, the library calls directly the WhatsApp APIs and from a static IP addres, your server IP address. This makes it a lot easier for WhatsApp to block the number. We tried this.

We wanted to try another approach. The web.whatsapp app is built using ReactJS (Facebook framework). Check the DOM.

So, if we just open the browser console and write “Store” you get this result

Interesting.. right? if you watch more closely to the “Chat” object

Chat model messages

You get all the messages, if they are already read or not 😉 everything…

Building a BOT from that point is very easy, just insert some javascript into the console and you can have a fully working WhatsApp chatbot. It works and does not get blocked by WhatsApp at all. In my next i will publish the script probably.

Why this kind of bot is harder to block?

Because this is a real Phone and a real web.whatsapp app running, we are simulating the user behavior here and always using the latest version of WhatsApp official client (SKD and stuff)

Also we have developed the audio parsing from WhatsApp to the Bot, its pretty awesome and it makes it even cooler.

Let me know if you have any doubts 🙂

Cheers,

Santiago Cotto

CTO – KONA