Twilio WhatsApp Integration
Connect your AI4Africa bot to WhatsApp using Twilio's official Business API
Prerequisites
Before you begin, make sure you have:
- A Twilio account (sign up at twilio.com)
- An approved WhatsApp Business Profile
- Your AI4Africa account credentials
- A public domain for webhook URL (for production)
Setup Guide
Create Twilio Account
- Visit Twilio's website
- Sign up for a new account or log in
- Complete phone verification
- Navigate to the WhatsApp section in Console
Configure WhatsApp Sandbox
- In Twilio Console, go to Messaging → WhatsApp
- Click "Settings" and note your Sandbox number
- Follow the join code instructions to connect your phone
- Save your WhatsApp number for later use
For production use, you'll need to apply for a WhatsApp Business Profile through Twilio. The approval process typically takes 1-2 business days.
Get Twilio Credentials
- Go to Twilio Console Dashboard
- Find your Account SID and Auth Token
- Keep these credentials secure
Never share your Auth Token publicly. Store it securely.
Configure in AI4Africa
- Log into your AI4Africa dashboard
- Go to Bot Settings → WhatsApp Integration
- Select Twilio as provider
- Copy the generated webhook URL for your bot
Important Note:
Currently, you only need to set up the webhook URL to receive messages. Twilio credentials (Account SID, Auth Token, WhatsApp number) are temporarily disabled and will be needed in the future for sending messages directly from our website. For now, you can skip entering these credentials.
Set Webhook URL in Twilio
- Return to Twilio Console → WhatsApp Settings
- Find the "Sandbox Configuration" section
- Paste your AI4Africa webhook URL from step 4
- Set HTTP POST as the method
- Save changes
This webhook setup is all you need to start receiving WhatsApp messages in your AI4Africa dashboard!
Testing Your Integration
To verify your setup is working:
- Send a message to your Twilio WhatsApp number
- Check if your bot responds appropriately
- Verify message appears in AI4Africa dashboard
- Test different message types (text, media, etc.)
If everything is set up correctly, you should receive an automatic response from your bot.
Security Best Practices
- Keep your Twilio credentials secure and never share them
- Use environment variables for sensitive data
- Regularly rotate your Auth Token
- Monitor your Twilio console for unusual activity
- Set up IP address restrictions in production
Troubleshooting
Common Issues
- Messages not being received
- Webhook errors
- Authentication failed
Solutions
- Verify webhook URL is correct
- Check credentials are valid
- Monitor Twilio logs
Need Help?
Contact our support team at [email protected]