TheVoĉoTheVoĉo

WhatsApp Business API Setup

Connect WhatsApp Business API to enable rich messaging with your customers through WhatsApp.

Overview

WhatsApp Business API Authentication connects your Cloud-PBX to WhatsApp's messaging platform using Meta (Facebook) Business credentials.

Requirements:

  • Facebook Business Manager account
  • Verified business
  • WhatsApp Business API access
  • Dedicated phone number
  • Webhook endpoint

Configuration Steps

Create Facebook Business Manager Account

  1. Go to business.facebook.com
  2. Click Create Account
  3. Enter business name and details
  4. Verify business email
  5. Complete business verification:
    • Business documents (registration, tax ID)
    • Business address
    • Website or social media presence
    • Business phone number

Verification Time

Business verification can take 1-5 business days.

Apply for WhatsApp Business API Access

  1. In Facebook Business Manager, go to Business Settings
  2. Click Accounts → WhatsApp Accounts
  3. Click Add → Create a WhatsApp Business Account
  4. Fill application:
    • Business name
    • Business use case
    • Expected message volume
    • Customer opt-in method
  5. Accept WhatsApp Business Policy
  6. Submit application

Approval typically within 24-48 hours

Register Phone Number

  1. In WhatsApp Manager, click Phone Numbers
  2. Click Add Phone Number
  3. Enter phone number (must not be on personal WhatsApp)
  4. Choose verification method (SMS or voice call)
  5. Enter verification code
  6. Set display name
  7. Complete registration

Phone Number Requirements:

  • Not registered on WhatsApp before
  • SMS/voice capable
  • Dedicated business line
  • Not banned/restricted

Generate API Credentials

  1. Go to WhatsApp Manager → API Setup
  2. Copy Phone Number ID
  3. Copy WhatsApp Business Account ID
  4. Generate Access Token:
    • Navigate to System Users (in Business Settings)
    • Create system user: "Cloud-PBX Integration"
    • Assign assets (WhatsApp account)
    • Generate token with permissions:
      • whatsapp_business_messaging
      • whatsapp_business_management
  5. Store credentials securely

Credentials Needed:

  • Phone Number ID
  • WhatsApp Business Account ID
  • Access Token (permanent token recommended)

Configure Cloud-PBX

  1. Navigate to Messaging → WhatsApp → Authentication
  2. Enter credentials:
    • Phone Number ID: From Step 4
    • Business Account ID: From Step 4
    • Access Token: From Step 4
    • Phone Number: Your WhatsApp number (+15551234567)
  3. Click Verify Connection
  4. Save configuration

Connection Verified

Your Cloud-PBX is now connected to WhatsApp!

Set Up Webhooks

Configure WhatsApp to send incoming messages to Cloud-PBX:

  1. In WhatsApp Manager, go to Configuration → Webhooks

  2. Click Edit

  3. Callback URL: https://your-pbx-domain.com/api/messaging/whatsapp/webhook

  4. Verify Token: Generate random string (save it)

  5. Subscribe to webhook fields:

    • messages (incoming messages)
    • message_status (delivery/read receipts)
    • message_template_status_update (template approvals)
  6. Save configuration

  7. In Cloud-PBX:

    • Go to Messaging → WhatsApp → Webhooks
    • Enter Verify Token (same as Step 4)
    • Save
  8. In WhatsApp Manager, click Verify and Save

Webhook Security:

  • WhatsApp signs requests with SHA-256
  • Cloud-PBX validates signature automatically
  • Only accept requests from WhatsApp IPs

Create Business Profile

  1. Go to WhatsApp Manager → Profile
  2. Complete business profile:
    • Display Name: Your business name
    • About: Brief description (max 139 chars)
    • Profile Photo: Logo (min 640x640px)
    • Business Description: Detailed description
    • Address: Business address
    • Business Hours: Operating hours
    • Email: Customer contact email
    • Website: Business website
    • Category: Business category
  3. Submit for verification (green badge)
  4. Save profile

Verified Badge

Green verified badge appears after Meta reviews your business (1-2 weeks).

Test Integration

Outbound Test:

  1. Go to Messaging → WhatsApp → Send Test
  2. Enter your personal WhatsApp number
  3. Send test message
  4. Verify receipt on your phone

Inbound Test:

  1. From your personal WhatsApp, message your business number
  2. Verify message appears in Cloud-PBX inbox
  3. Reply from Cloud-PBX
  4. Verify reply received on your phone

Check Read Receipts:

  • Blue checkmarks when message read
  • Gray checkmarks when delivered

Integration Complete

WhatsApp Business is fully operational!


Webhook Configuration

Cloud-PBX Webhook URL:

https://your-pbx-domain.com/api/messaging/whatsapp/webhook

Webhook Events:

  • messages: Incoming text, media, location, contact
  • message_status: sent, delivered, read, failed
  • message_template_status_update: approved, rejected

Webhook Payload Example:

{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "WHATSAPP_BUSINESS_ACCOUNT_ID",
    "changes": [{
      "value": {
        "messaging_product": "whatsapp",
        "metadata": {
          "display_phone_number": "15551234567",
          "phone_number_id": "PHONE_NUMBER_ID"
        },
        "messages": [{
          "from": "15559876543",
          "id": "wamid.XXX",
          "timestamp": "1634567890",
          "type": "text",
          "text": {
            "body": "Hello, I need help with my order"
          }
        }]
      }
    }]
  }]
}

Security Best Practices

Access Token Security:

  • Use permanent system user tokens (not temporary)
  • Store securely (encrypted)
  • Never commit to version control
  • Rotate tokens every 90 days
  • Limit token permissions to minimum required
  • Use separate tokens for dev/staging/production

Webhook Security:

  • Validate webhook signatures (SHA-256)
  • Use HTTPS only
  • Verify requests from WhatsApp IPs only
  • Implement rate limiting
  • Log all webhook activity
  • Monitor for suspicious patterns

Phone Number Security:

  • Don't share phone number publicly initially
  • Monitor for spam/abuse
  • Enable two-factor authentication
  • Restrict admin access
  • Review usage regularly

Troubleshooting

Business Verification Rejected:

  • Provide clearer business documents
  • Ensure business name matches documents
  • Verify business address and phone
  • Check website/social media presence
  • Resubmit with corrections

Phone Number Verification Fails:

  • Number not on personal WhatsApp
  • Number can receive SMS/calls
  • Correct country code format (+1...)
  • Not previously banned
  • Try different verification method (SMS vs voice)

Webhook Not Receiving Messages:

  • Verify URL publicly accessible (HTTPS)
  • Check SSL certificate valid
  • Review firewall rules (allow WhatsApp IPs)
  • Test webhook with curl/Postman
  • Verify webhook subscribed to "messages" event
  • Check verify token matches

API Connection Fails:

  • Verify all credentials correct
  • Check access token permissions
  • Confirm WhatsApp Business Account ID accurate
  • Ensure API access approved
  • Review Meta Business Manager status

Migration Notes

From WhatsApp Business App:

  • API uses different phone number
  • Can't migrate app number directly without losing history
  • Export contacts manually
  • Notify customers of new number
  • Gradually transition

Provider Migration (e.g., from Twilio to Meta directly):

  • Set up new Meta Business Manager
  • Register new phone number
  • Update authentication in Cloud-PBX
  • Test thoroughly before switching
  • Update templates with new number
  • Notify customers if number changes

Next Steps

Authentication Complete

WhatsApp Business API is connected! Configure templates and settings next.

  1. Configure Settings: Set up business profile, templates in WhatsApp Settings
  2. Create Templates: Build message templates for notifications
  3. Configure Routing: Route WhatsApp messages to queues in Message Queues
  4. Train Team: Familiarize agents with WhatsApp features
  5. Launch: Start customer conversations