whatsapp-chess-bot
v1.0.4
Published
A WhatsApp bot that lets you play chess via interactive polls with an AI opponent
Readme
WhatsApp Chess Bot ♟️
A WhatsApp bot that lets you play chess against an AI opponent using interactive polls. The bot displays the chess board as images and uses polls for move selection.
Features
- Play chess via WhatsApp polls
- AI opponent powered by js-chess-engine
- Visual chess board using chessboardimage.com
- Automatic message cleanup (keeps only last 2 board images)
- Choose piece type, then select specific move
Installation
npm install whatsapp-chess-botOr clone and run:
git clone https://github.com/Davdadev/whatsapp-chess-bot.git
cd whatsapp-chess-bot
npm install
npm startSetup
Run the bot:
npm startScan the QR code with WhatsApp (Link Device)
Bot is ready! Send commands in any WhatsApp chat.
Commands
@chess start- Start a new chess game@chess clean- Delete all bot images from chat
How to Play
- Send
@chess startin any WhatsApp chat - The bot shows the current board position
- Vote in the "Choose a piece type" poll (Pawn, Knight, Bishop, etc.)
- Vote in the move poll to select your piece's destination
- The AI responds automatically
- Repeat until checkmate or stalemate
Configuration
Edit index.js to customize:
- AI Difficulty: Change
engine.aiMove(gameData.game.fen(), 2)- the2is the search depth (higher = stronger) - Max Images: Change
enforceMaxImages(chatId, 2)- default keeps 2 board images - Session Name: Change
clientId: "chess-poll-session"for multiple instances
Requirements
- Node.js 14 or higher
- WhatsApp account
- Internet connection
Dependencies
whatsapp-web.js- WhatsApp clientqrcode-terminal- QR code displaychess.js- Chess game logicjs-chess-engine- AI opponent
Notes
- WhatsApp may prevent deletion of old messages depending on timing/permissions
- For best experience, enable disappearing messages in the chat
- Board images are fetched from https://chessboardimage.com/
License
GPL-3.0
