2.3 KiB
2.3 KiB
Twilio WhatsApp Setup Guide
🔑 Step 1: Get Twilio Credentials
-
Sign up for Twilio:
- Go to https://console.twilio.com/
- Create a free account
-
Get Account SID and Auth Token:
- In Twilio Console, go to Dashboard
- Copy your Account SID (starts with
AC...) - Copy your Auth Token
-
Enable WhatsApp Business API:
- Go to Messaging → WhatsApp
- Follow the setup instructions
- Get your WhatsApp number
📱 Step 2: WhatsApp Group ID
Option A: Using Twilio Console
- In Twilio Console, go to Messaging → WhatsApp
- Look for your group in the list
- Copy the Group ID (format:
g.1234567890@group)
Option B: Manual Discovery
- Open WhatsApp Web
- Go to your target group
- Check the URL or use browser dev tools
- Look for group ID in the page source
Option C: Test with Sample Group
For testing, you can use a sample group ID:
g.1234567890@group
⚙️ Step 3: Environment Configuration
Add these to your .env file:
# Twilio Credentials
TWILIO_ACCOUNT_SID=AC...your_account_sid_here
TWILIO_AUTH_TOKEN=your_auth_token_here
# WhatsApp Configuration
TWILIO_WHATSAPP_NUMBER=+1234567890
WHATSAPP_GROUP_ID=g.1234567890@group
🧪 Step 4: Test the Setup
# Test WhatsApp integration
python test_whatsapp.py
# Test complete system
python test_real_ai.py
🔍 Troubleshooting
Common Issues:
-
"Invalid Account SID"
- Check your Account SID starts with
AC - Verify it's copied correctly
- Check your Account SID starts with
-
"Authentication failed"
- Check your Auth Token
- Make sure it's the correct token
-
"WhatsApp number not found"
- Verify your WhatsApp number is activated
- Check the number format (+1234567890)
-
"Group not found"
- Verify the group ID format
- Make sure the group exists
- Check if you have permission to send to the group
📞 Support
- Twilio Documentation: https://www.twilio.com/docs/whatsapp
- WhatsApp Business API: https://developers.facebook.com/docs/whatsapp
- Twilio Support: https://support.twilio.com/
🎯 Next Steps
Once configured:
- Test with mock data first
- Send a test alert to your group
- Monitor the alerts in your WhatsApp group
- Fine-tune the alert timing and content