ChatGPT/Gemini AI for WhatsApp using Google's Gemini API/OAI API and whatsapp-web.js, written in JS using Node.js
NOTE: I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
- npm
npm install npm@latest -g
-
Clone this Repo:
git clone https://github.com/iamkhalid2/WhatsAppGPT.git
-
Install Dependencies:
npm install
-
Create a ".env" file
-
Open file .env in a text editor and insert the following environment variable with your Gemini API key:
OPENAI_API_KEY="INSERT YOUR OPENAI API KEY HERE" GEMINI_API_KEY="INSERT YOUR GEMINI API KEY HERE"
-
Run the program:
npm start
-
Scan the QR code that appears in the terminal with WhatsApp to link your account.
-
The chatbot is now running and listening for messages. Send a message starting with # followed by your question in WhatsApp. The response will be generated by Gemini AI and sent as a reply to your message.
- Uses Google's Gemini AI 2.0 Flash Thinking model
- Maintains conversation history for context (last 10 conversations)
- Quick response time with real-time message processing