4

I am trying to make a WhatsApp bot inspired by the functioning of Discord bots, the bot will work in WhatsApp groups.

I have looked up the official WhatsApp Business API but I am not sure that they will not approve my number as it is just a hobby project and not a proper "business".

There is an alternative though and that is the Twilio WhatsApp API. However, they provide you with a sandbox. I can interact with it in DMs but as the sandbox number is a business account, I cannot add it to a group like discord.

I intend to write a server in python or node.

Can anyone share a solution or workaround? Only if I could add the Twilio number to a group my problem will be solved. Though I am ready to use any other API/Solutions for this.

ROHAN SINGH
  • 41
  • 1
  • 2
  • You should check out a service called Gupshup. It provides very similar service for creating chatbots like twilio but it is a bit more complicated to get started. – Bibek Mar 31 '20 at 14:26
  • https://developers.facebook.com/docs/whatsapp/api/messages/group/ It is quite easy to get your business approved. They likely won't approve something dumb. Just write something abstract but stay true to what you are doing and it'll get approved. – Tin Nguyen Mar 31 '20 at 15:11
  • https://developers.facebook.com/docs/whatsapp/api/groups#create if Twilio provides the complete set of apis, WhatsApp already provides you (business) a way to create a group and add other numbers. And not the vice-versa, for security reasons. That might solve your creating group issues. – Navjot Singh Apr 10 '20 at 23:16

2 Answers2

3

There is actually a Python solution for this. It is a pain to set it up, but it still works. Check it out:

https://github.com/mukulhase/WebWhatsapp-Wrapper

It uses the webdriver Selenium to send/retrieve messages through Web-WhatsApp.

Be aware that it is against their rules, so your phone number might get banned!

ToTheMax
  • 981
  • 8
  • 18
  • Thanks! Actually I already implemented stuff with this on twitter using selenium and geckodriver (web driver for firefox). It works like a charm. However, this is not what I was looking for. I did not mention in the question, however, I wanted to host the bot on a server. The Whatsapp client sends a GET request to my server and then my server responds back with a message (A WhatsApp request object) . At least this is how its done on Twilio. However, Selenium/Geckodriver may not be the best option for a server of which I have only CLI access. I don't even know if the server can run web browser. – ROHAN SINGH Apr 07 '20 at 07:47
  • You are right, i'm not sure if it will work on a server without GUI. I'll give it a shot this week, will let you know if I can make it work! – ToTheMax Apr 07 '20 at 12:32
  • Sure good luck! In the meantime, I searched a lot, apart from your solution, I found no other solution. So I have pretty much given up on this for now. Looks like I will make a discord bot instead. If you give it a try though, I think you might find phantomJS useful. It uses selenium, but this browser is hidden instead of normal browsers like firefox or chrome. This may (I am not sure) work on CLI. Please let me know of the results. – ROHAN SINGH Apr 08 '20 at 13:09
  • 1
    I managed to get it work on a Linux server (without GUI) using docker! Just follow their `Docker and remote Selenium Installation` instructions – ToTheMax Apr 12 '20 at 21:39
0

You can use this replit template by forking it.

https://replit.com/@AllailQadrillah/Whatsapp-Bot

WhatsApp bot is built using the unofficial api from whatsapp-web.js which can save sessions on mongodb and is active for 24 hours

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34732290) – Chenmunka Jul 26 '23 at 10:11
  • When linking to your own site or content (or content that you are affiliated with), you must [disclose your affiliation in the answer](https://stackoverflow.com/help/promotion) in order for it not to be considered spam. Having the same text in your username as the URL or mentioning it in your profile is not considered sufficient disclosure under Stack Exchange policy. – Tyler2P Jul 26 '23 at 10:23