WhatsApp Business Integration Setup Guide
Complete setup instructions for Meta WhatsApp Business API on Fly.io.
---
PART 1: Meta Developer Console Setup
Step 1: Create Meta App
- Go to Meta for Developers
- Click **"Create App"**
- Select **"Business"** app type
- Enter app name:
Atom WhatsApp Integration(or your preference) - Click **"Create App"**
Step 2: Add WhatsApp Product
- In your app dashboard, find **"Add Products"** section
- Click **"Set up"** under **WhatsApp**
- You'll be redirected to WhatsApp configuration
Step 3: Configure WhatsApp
**A. Basic Setup**
- Select **"Get Started"** with WhatsApp Cloud API
- Select your **Meta Business Account** (or create one)
- Enter your business display name and category
**B. Webhook Configuration**
- Scroll to **"Webhooks"** section
- Click **"Configure"**
- **Webhook URL:**
- **Verify Token:**
- Click **"Verify and Save"**
**C. Subscribe to Webhook Events**
After verification succeeds, subscribe to these events:
- ✅ **Messages** - Required for receiving messages
- ✅ **Messaging Postbacks** - Delivery status
- ✅ **Message Template Status** - Template approval updates
**D. Phone Number Setup**
- Go to **"Send & Receive Messages"** section
- Add a phone number (or use test number)
- Copy the **Phone Number ID** - you'll need this later
- Copy the **WhatsApp Business Account ID (WABA ID)**
Step 4: Generate Access Token
- In WhatsApp configuration, scroll to **"Access Token"**
- Click **"Generate"** or **"Edit"**
- Select token expiration (prefer **"Never expires"** for production)
- Copy the **Temporary Access Token** (starts with
EAA...) - **⚠️ IMPORTANT:** Copy this token NOW - you won't see it again!
Step 5: Get App Credentials
- Go to **Settings** → **Basic**
- Copy **App ID** (also called Client ID)
- Copy **App Secret** (click "Show" to reveal)
- Note your **App Secret** - you'll need it for OAuth
Step 6: Configure Embedded Signup (Optional but Recommended)
- Go to **WhatsApp** → **Embedded Signup**
- Add your domain:
app.atomagentos.com - Copy the **Configuration ID**
---
PART 2: Fly.io Configuration
Step 1: Set Secrets on Fly.io
Run these commands to set your WhatsApp credentials:
# App Credentials (for OAuth)
fly secrets set WHATSAPP_APP_ID=your_app_id_here -a atom-saas
fly secrets set WHATSAPP_APP_SECRET=your_app_secret_here -a atom-saas
fly secrets set WHATSAPP_CONFIG_ID=your_config_id_here -a atom-saas
# Webhook Verification Token
fly secrets set WHATSAPP_WEBHOOK_VERIFY_TOKEN=atom_whatsapp_verify_token_2024 -a atom-saas
# Redirect URI (should match Meta dashboard)
fly secrets set WHATSAPP_REDIRECT_URI=https://app.atomagentos.com/api/integrations/whatsapp/callback -a atom-saas**Example:**
fly secrets set WHATSAPP_APP_ID=123456789012345 -a atom-saas
fly secrets set WHATSAPP_APP_SECRET=abc123def456 -a atom-saas
fly secrets set WHATSAPP_CONFIG_ID=987654321 -a atom-saasStep 2: Verify Secrets are Set
fly secrets list -a atom-saas | grep WHATSAPPYou should see:
* WHATSAPP_APP_ID [HASH] Staged
* WHATSAPP_APP_SECRET [HASH] Staged
* WHATSAPP_CONFIG_ID [HASH] Staged
* WHATSAPP_REDIRECT_URI [HASH] Staged
* WHATSAPP_WEBHOOK_VERIFY_TOKEN [HASH] StagedStep 3: Deploy (if not already deployed)
fly deploy -a atom-saas---
PART 3: Meta Developer Console - Final Configuration
Step 1: Configure Redirect URI
In your Meta App:
- Go to **WhatsApp** → **Configuration**
- Find **"Callback URL"** or **"Redirect URI"** setting
- Set it to:
Step 2: Configure OAuth (for Embedded Signup)
- Go to **Settings** → **Basic**
- Under **"App Domlices"**, add:
app.atomagentos.com - Under **"Redirect OAuth URIs"**, add:
---
PART 4: Verification & Testing
Test 1: Verify Webhook Endpoint
curl "https://app.atomagentos.com/api/v1/webhooks/whatsapp?hub.mode=subscribe&hub.verify_token=atom_whatsapp_verify_token_2024&hub.challenge=TEST123"**Expected Response:** TEST123 (the challenge string echoed back)
Test 2: Test OAuth Authorization
- Visit in your browser:
- Should return JSON with
authorization_url - Click that URL - should redirect to Meta's OAuth screen
Test 3: Check Connection Status
# After completing OAuth, check status
curl https://app.atomagentos.com/api/integrations/whatsapp/status**Expected Response:**
{
"connected": true,
"phone_number": "+1234567890",
"business_name": "Your Business Name",
"connected_at": "2026-04-07T..."
}Test 4: Send Test Message
# Via SSH into the container
fly ssh console -a atom-saas -C "curl -X POST http://localhost:8000/api/v1/integrations/whatsapp/message -H 'Content-Type: application/json' -d '{\"to\": \"PHONE_NUMBER\", \"message\": \"Test from Atom\"}'"---
PART 5: Troubleshooting
Issue: Webhook Verification Fails (403 Forbidden)
**Cause:** Verify token mismatch
**Solution:**
- Check Meta dashboard has exact token:
atom_whatsapp_verify_token_2024 - Check Fly secret:
fly secrets list -a atom-saas | grep WHATSAPP_WEBHOOK_VERIFY_TOKEN - Both must match exactly
Issue: Webhook Returns 500 Error
**Cause:** Internal server error
**Solution:**
# Check logs
fly logs -a atom-saas -c 100 | grep -i whatsapp
# Check Python health
fly ssh console -a atom-saas -C "curl http://localhost:8000/health"Issue: OAuth Callback Fails
**Cause:** Redirect URI mismatch
**Solution:**
- Meta dashboard: Check Callback URL matches exactly
- Fly secret: Check
WHATSAPP_REDIRECT_URI - Both must be:
https://app.atomagentos.com/api/integrations/whatsapp/callback
Issue: Messages Not Received
**Cause:** Phone number ID not mapped to tenant
**Solution:**
- Complete OAuth flow for your tenant
- Check
phone_number_idis saved in tenant credentials - Webhook uses
phone_number_idto resolve tenant
Issue: HTTP 431 Errors
**Cause:** atom-saas-api.fly.dev references (old architecture)
**Solution:**
- Verify
PYTHON_BACKEND_URL=http://localhost:8000in fly.toml - Check next.config.mjs doesn't reference
atom-saas-api.fly.dev - See
SINGLE_APP_ARCHITECTURE.mdfor details
---
PART 6: Environment Variables Reference
| Variable | Description | Example | Required |
|---|---|---|---|
WHATSAPP_APP_ID | Meta App ID | 123456789012345 | ✅ Yes |
WHATSAPP_APP_SECRET | Meta App Secret | abc123def456 | ✅ Yes |
WHATSAPP_CONFIG_ID | Embedded Signup Config ID | 987654321 | Optional |
WHATSAPP_REDIRECT_URI | OAuth Callback URL | https://app.atomagentos.com/api/integrations/whatsapp/callback | ✅ Yes |
WHATSAPP_WEBHOOK_VERIFY_TOKEN | Webhook verification token | atom_whatsapp_verify_token_2024 | ✅ Yes |
---
PART 7: Meta Dashboard URLs Reference
| Resource | URL |
|---|---|
| Meta for Developers | https://developers.facebook.com |
| Your Apps | https://developers.facebook.com/apps |
| WhatsApp Documentation | https://developers.facebook.com/docs/whatsapp |
| Webhooks Documentation | https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks |
| Embedded Signup | https://developers.facebook.com/docs/whatsapp/embedded-signup |
---
Summary Checklist
Meta Developer Console
- [ ] Create Business app
- [ ] Add WhatsApp product
- [ ] Configure webhook URL:
https://app.atomagentos.com/api/v1/webhooks/whatsapp - [ ] Set verify token:
atom_whatsapp_verify_token_2024 - [ ] Subscribe to webhook events (Messages, Message Postbacks)
- [ ] Generate access token (never expires)
- [ ] Copy App ID, App Secret, Phone Number ID, WABA ID
- [ ] Configure Embedded Signup (optional)
- [ ] Add domain and redirect URI
Fly.io
- [ ] Set WHATSAPP_APP_ID secret
- [ ] Set WHATSAPP_APP_SECRET secret
- [ ] Set WHATSAPP_CONFIG_ID secret (if using Embedded Signup)
- [ ] Set WHATSAPP_WEBHOOK_VERIFY_TOKEN secret
- [ ] Set WHATSAPP_REDIRECT_URI secret
- [ ] Deploy app:
fly deploy -a atom-saas - [ ] Test webhook verification endpoint
- [ ] Test OAuth authorization flow
Verification
- [ ] Webhook verification returns challenge
- [ ] OAuth authorization URL is generated
- [ ] OAuth callback succeeds
- [ ] Connection status shows connected
- [ ] Test message can be sent
---
Last Updated: 2026-04-07
Related Docs: SINGLE_APP_ARCHITECTURE.md