Free, open-source WhatsApp Personal automation bot with auto-replies and chatbot.
β
Auto-replies - Respond automatically to incoming messages
β
Chatbot - Intelligent response patterns for common questions
β
24/7 Operation - Runs continuously on your computer
β
Customizable - Easy to modify responses and add new patterns
β
Conversation History - Keeps track of chat history
β
Message Logging - All conversations saved to file
β
Completely Free - No subscriptions or API costs
-
Node.js (v14 or higher)
- Download from https://nodejs.org/
- Verify installation:
node -v
-
npm (usually comes with Node.js)
- Verify:
npm -v
- Verify:
-
WhatsApp Account (Personal, not Business)
-
Computer/Server to keep running 24/7 (or run when needed)
Place all 4 files in a folder:
bot.jschatbot.jspackage.json.env.example
Open terminal/command prompt in your project folder and run:
npm installThis will download all required packages (~200MB). Takes 2-5 minutes.
# On Windows (Command Prompt):
ren .env.example .env
# On Mac/Linux:
mv .env.example .envnpm startYou'll see:
π Starting WhatsApp Bot...
========================================
π± Scan this QR code with WhatsApp:
========================================
- Open WhatsApp on your phone
- Go to Settings β Linked Devices
- Tap Link a device
- Scan the QR code shown in terminal
Once scanned, you'll see:
β
Bot is ready and listening for messages!
π¨ Send a message to this WhatsApp account to test
Send a message to the WhatsApp account running the bot:
- "hello" β Bot replies with greeting
- "help" β Bot shows available options
- "what's your name?" β Bot identifies itself
- "thanks" β Bot says you're welcome
- Random text β Bot asks for clarification
Edit chatbot.js to add new response patterns:
// Example: Add FAQ responses
const responses = {
faq: {
patterns: ['price', 'cost', 'how much', 'pricing'],
responses: [
'Our pricing starts at $9.99/month. Visit our website for details.',
'Check our pricing page: www.example.com/pricing'
]
},
// ... rest of responses
};Find the greetings section in chatbot.js:
greetings: {
patterns: ['hi', 'hello', 'hey'],
responses: [
'Hey! Your custom message here!',
'Another greeting variant!'
]
}order_status: {
patterns: ['order', 'tracking', 'status', 'where is my'],
responses: [
'To check your order, reply with your order number.',
'You can also track at: www.example.com/track'
]
}In bot.js, find this line:
if (msg.isGroupMsg) return; // Remove or comment outRemove it to allow bot to work in group chats.
For sending data to external services:
- Set
WEBHOOK_URLin.env - Modify
bot.jsto call your webhook
Example:
const axios = require('axios');
// In message handler:
await axios.post(process.env.WEBHOOK_URL, {
from: msg.from,
message: messageText,
timestamp: new Date()
});To save conversations to a database instead of text file:
- Install database (e.g.,
npm install sqlite3) - Modify the
logMessage()function inbot.js - Save to database instead of file
project-folder/
βββ bot.js # Main bot file
βββ chatbot.js # Chatbot logic & responses
βββ package.json # Dependencies
βββ .env # Configuration (create from .env.example)
βββ README.md # This file
βββ logs/ # Created automatically, stores chat logs
βββ bot_logs.txt
The bot only works while this script is running. If you close terminal/restart PC, bot stops.
Solution: Run on a cheap server/VPS (AWS, DigitalOcean, Heroku) for 24/7 operation.
WhatsApp might:
- Temporarily restrict your account
- Ask for unusual activity verification
- Throttle messages
To minimize risk:
- Don't spam messages
- Keep realistic delays between responses
- Use natural response patterns
This uses WhatsApp Web (browser automation), not official API:
- β Free & flexible
- β Might break if WhatsApp changes UI
- β Against WhatsApp ToS (personal use only)
Your WhatsApp session is stored locally in .wwebjs_auth folder:
β οΈ Don't share this folderβ οΈ Don't commit to GitHub- β
Add to
.gitignore
npm install- Try restarting:
npm start - Make sure terminal window is large enough
- Try scanning again
- Check bot is still running (look for β Ready message)
- Send a simple message like "hello"
- Check console for error messages
- Too many messages sent
- Solution: Wait 24-48 hours for WhatsApp to unlock
- Use more realistic response timing
rm -rf .wwebjs_auth/ # Mac/Linux
rmdir .wwebjs_auth /s # Windows
npm start # Start fresh- DigitalOcean - $4-6/month
- AWS Free Tier - 12 months free
- Google Cloud - $300 free credits
- Heroku - Free tier (limited)
Installation on server:
ssh user@your-server.com
git clone your-repo.git
cd your-repo
npm install
nohup npm start &Keep laptop running 24/7 with:
- Disable sleep/hibernation
- Keep WiFi connected
- Use task scheduler to auto-restart on reboot
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm install
CMD ["npm", "start"]support_keyword: {
patterns: ['issue', 'problem', 'bug', 'error'],
responses: [
'Sorry to hear that! π\n\nPlease describe the issue and I\'ll help.',
'I\'ll connect you with our support team shortly.'
]
}faq: {
patterns: ['return', 'refund', 'warranty'],
responses: [
'Our return policy: Within 30 days for full refund.\nSee: example.com/returns'
]
}Modify bot to send reminders at specific times (combine with node-schedule package)
Auto-collect info: "What's your budget?" β "How many users?"
- WhatsApp-web.js Docs: https://github.com/pedroslopez/whatsapp-web.js
- Node.js Docs: https://nodejs.org/docs/
- Common Issues: Check GitHub issues in whatsapp-web.js repo
- Terms of Service: This bot operates on WhatsApp Personal, which may violate WhatsApp's Terms of Service
- Use Responsibly: For personal/business use only, not for spam
- No Liability: Creator not responsible for account restrictions
MIT - Feel free to modify and share
Happy automating with Obraims bot! π
Questions? Check the troubleshooting section or GitHub issues.