whatsapp-bot.js
v1.0.0
Published
A high-level, `discord.py`-inspired framework for building WhatsApp bots easily and quickly. Built on top of `whatsapp-web.js`.
Readme
whatsapp.js Framework
A high-level, discord.py-inspired framework for building WhatsApp bots easily and quickly. Built on top of whatsapp-web.js.
Features
- Zero Meta API Setup: Uses WhatsApp Web under the hood. No business registrations needed.
- Context Object (
ctx): Just likediscord.py, a rich context object makes replying, reacting, and fetching chat data trivial. - Built-in Command Handler: Define commands easily without complex
if/elseladders. - Self-Message Support: Commands work even if you send them from your own phone!
- TypeScript First: Full autocomplete support.
Installation
(Note: This is a local package for now, but soon you could publish it to npm!)
npm install whatsapp-web.js qrcode-terminalQuick Start
import { Bot } from 'whatsapp';
const bot = new Bot({ prefix: '!' });
bot.command('ping', async (ctx) => {
await ctx.reply('Pong! 🏓');
});
bot.command('echo', async (ctx) => {
await ctx.send(ctx.args.join(' '));
});
bot.start();How to Run
- Run your script using
ts-nodeor by compiling to JS. - A QR code will appear in your terminal.
- Open WhatsApp on your phone -> Linked Devices -> Link a Device.
- Scan the QR code.
- Send
!pingin any chat (or to yourself) and watch the bot reply!
