Introduction
This guide covers creating and deploying WhatsApp bots on Shard Cloud using the whatsapp-web.js library.Creating Your Bot
Setup
Basic Bot Code
index.js
Package.json
package.json
Authentication
When you first run the bot, it will generate a QR code (qrcode.png). You need to:
- Download the QR code from Shard Cloud’s file manager
- Scan it with WhatsApp on your phone (Settings → Linked Devices → Link a Device)
- Once authenticated, the session is saved and you won’t need to scan again
The
LocalAuth strategy saves the session in a .wwebjs_auth folder. This persists between restarts.Shard Cloud Configuration
.shardcloud
Deploying
Upload to Shard Cloud
Go to Shard Cloud Dashboard and upload.
Additional Resources
Visit the whatsapp-web.js documentation for more information.Troubleshooting
QR code not generating
QR code not generating
- Ensure Puppeteer has enough memory (1024MB+)
- Check logs for Chromium errors
Session expires frequently
Session expires frequently
- Ensure your phone stays connected to the internet
- Keep the WhatsApp app open on your phone
Chromium errors
Chromium errors
Make sure you’re using the
--no-sandbox and --disable-setuid-sandbox flags.