A simple WhatsApp bot that uses Google's Gemini AI to answer user questions.
- Responds to messages starting with
!ask
- Uses Google Gemini AI for intelligent responses
- Built with Baileys WhatsApp library
- Simple and lightweight
- Node.js (version 16 or higher)
- A Google Gemini API key
- WhatsApp account
-
Clone or download this repository
-
Install dependencies:
npm install @whiskeysockets/baileys axios dotenv
-
Create a
.env
file in the project root:GEMINI_API_KEY=your_gemini_api_key_here
-
Replace
your_gemini_api_key_here
with your actual Gemini API key
- Go to Google AI Studio: https://makersuite.google.com/app/apikey
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated API key
-
Start the bot:
node bot.js
-
Scan the QR code with your WhatsApp mobile app:
- Open WhatsApp on your phone
- Go to Settings > Linked Devices
- Tap "Link a Device"
- Scan the QR code displayed in your terminal
-
Send messages to the bot:
- Send a message starting with
!ask
followed by your question - Example:
!ask What is the weather like?
- The bot will reply using Gemini AI
- Send a message starting with
User: !ask What is JavaScript?
Bot: JavaScript is a high-level, interpreted programming language that is widely used for web development...
gemini-wp-bot/
├── bot.js # Main bot script
├── .env # Environment variables (create this)
├── .gitignore # Git ignore file
├── package.json # Node.js dependencies
└── README.md # This file
- If you get authentication errors, delete the
baileys_auth_info
folder and scan the QR code again - Make sure your Gemini API key is valid and has sufficient quota
- Ensure you have a stable internet connection
- Check that Node.js version is 16 or higher
- The bot only responds to messages starting with
!ask
- Authentication data is stored in the
baileys_auth_info
folder - The bot will automatically reconnect if the connection is lost
- Keep your API key secure and never commit it to version control