It a simple web-based WhatsApp bot. It requires starting up a webdriver to control the session.
It also support OpenAI API, just put your token and you can ask ChatGPT, GPT-3, DALL.E,
or any other model.
- Latest version of Python, at least
3.10 - Clone this repo as
git clone https://github.com/petroly-initiative/WhatsBotand change the working director to it,
cd WhatsBot- Run
pip install openai selenium- Set the variable
CHAT_NAME, it'll be used to find the chat you want the bot to interact in. - To use commands of OpenAI you should export the env variable as
export OPENAI_TOKE=right_here_your_token- Open ChromeDriver and download the file according to your version of chrome.
- Place the
chromedriverinPATHenv variable,
Now it's as simple as running
python bot.pyA chrome browser will pop up, wait for the QR to scan, then wait for downloading chats.
After 5s it'll start search for the chat as in the variable CHAT_NAME then enters it.
By default there are four commands, the simplest one is
suitable for testing: /start, bot returns "Hello!".
You can add as many as you want of commands in the dict variable COMMANDS, in the format
of "command": THE_METHOD_TO_EXECuTE