WhatsApp Channel
Connect your Moxxy agent to WhatsApp via a bridge.
WARNING
WhatsApp integration uses a third-party bridge and is in Beta. It may have limitations and require periodic re-pairing.
Overview
WhatsApp integration uses Baileys or similar library to connect as a regular WhatsApp user (not a Business API).
Limitations
- Not officially supported by WhatsApp/Meta
- Requires QR code pairing
- May need re-pairing periodically
- Subject to WhatsApp ToS
Setup
Prerequisites
- A phone number for the bot
- Access to scan QR code
Step 1: Initialize WhatsApp Channel
bash
moxxy channel whatsapp --agent defaultStep 2: Scan QR Code
A QR code will be displayed in your terminal:
┌─────────────────────────────────────┐
│ │
│ ██████╗ ██╗██╗ ██╗ ██████╗ │
│ ██╔══██╗██║██║ ██║██╔═══██╗ │
│ ██████╔╝██║██║ ██║██║ ██║ │
│ ██╔══██╗██║╚██╗ ██╔╝██║ ██║ │
│ ██████╔╝██║ ╚████╔╝ ╚██████╔╝ │
│ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ │
│ │
│ Scan with WhatsApp → Settings │
│ → Linked Devices → Link Device │
│ │
└─────────────────────────────────────┘Step 3: Scan with Phone
- Open WhatsApp on your phone
- Go to Settings → Linked Devices
- Tap Link a Device
- Scan the QR code
Step 4: Connected!
Once scanned, the bot is connected and ready to use.
Usage
Direct Messages
Send a message to the connected phone number:
You: Hello bot!
Bot: Hi! I'm your Moxxy assistant. How can I help you?Group Chats
Add the phone number to a WhatsApp group:
- Open group info
- Add participant
- Enter the bot's phone number
- The bot will respond to mentions/replies
Triggering Responses
In groups, the bot responds to:
- Messages starting with the bot's number:
@1234567890 Hello - Replies to the bot's messages
- Direct messages
Configuration
Vault Keys
| Key | Description |
|---|---|
whatsapp_session | Session data (auto-managed) |
whatsapp_trigger_prefix | Prefix to trigger bot in groups |
Session Persistence
WhatsApp session is stored in:
~/.moxxy/agents/default/whatsapp_session/This allows reconnection without rescanning.
Features
Text Messages
Send and receive text messages:
You: What's the weather?
Bot: Let me check the weather for you.
The current weather is sunny, 72°F.Media Support
Receiving:
- Images
- Documents
- Voice notes
Sending:
- Images
- Documents
You: Send me the report
Bot: Here's the report:
[Attachment: report.pdf]Voice Messages
Voice messages can be transcribed:
[Voice message received]
Bot: I received your voice message saying "remind me to call John tomorrow".
I've set a reminder for you.Troubleshooting
QR Code Not Displaying
- Ensure terminal supports ANSI colors
- Try a different terminal emulator
- Check if terminal size is large enough
Session Expired
Error: Session expired, please re-pair- Run setup again:bash
moxxy channel whatsapp --agent default - Scan the new QR code
- Previous session is invalidated
Rate Limited
Error: Rate limited by WhatsApp- Reduce message frequency
- Wait before sending more
- Avoid spamming
Banned Number
Error: Account temporarily banned- Wait for ban to expire
- Use a different number
- Follow WhatsApp ToS
Not Receiving Messages
- Check internet connection
- Verify session is active:bash
moxxy logs | grep -i whatsapp - Try re-pairing
Security Considerations
Account Security
- Use a dedicated phone number for the bot
- Don't use your personal WhatsApp account
- Keep session data secure
Privacy
- Messages are processed by Moxxy
- Don't share sensitive information
- Consider data retention policies
ToS Compliance
- Follow WhatsApp Terms of Service
- Don't spam users
- Respect opt-out requests
- Don't automate bulk messaging
API Reference
Send Message
bash
curl -X POST http://localhost:17890/api/agents/default/whatsapp/send \
-H "Content-Type: application/json" \
-d '{
"to": "1234567890",
"text": "Hello from Moxxy!"
}'Send Image
bash
curl -X POST http://localhost:17890/api/agents/default/whatsapp/send \
-H "Content-Type: application/json" \
-d '{
"to": "1234567890",
"image": {
"url": "https://example.com/image.jpg"
},
"caption": "Check this out!"
}'Send Document
bash
curl -X POST http://localhost:17890/api/agents/default/whatsapp/send \
-H "Content-Type: application/json" \
-d '{
"to": "1234567890",
"document": {
"url": "https://example.com/doc.pdf"
},
"filename": "report.pdf"
}'Best Practices
Professional Use
- Inform users they're chatting with a bot
- Provide clear value
- Don't spam
Error Handling
- Handle rate limits gracefully
- Implement retry logic
- Log errors for debugging
Session Management
- Keep session data backed up
- Handle re-pairing smoothly
- Monitor connection status
Alternatives
For production WhatsApp integration, consider:
WhatsApp Business API
Official API from Meta:
- Verified business accounts
- Higher message limits
- Better reliability
- Official support
Third-Party Services
- Twilio WhatsApp API
- MessageBird
- WATI
These provide:
- Managed infrastructure
- Official compliance
- Better support
- Higher costs