WhatsApp Business API Integration

Connect your AI agents to WhatsApp using Meta's official Cloud API. This is the recommended approach for production WhatsApp integrations.


Overview

WhatsApp Business API allows you to: - Send and receive messages programmatically - Connect to your AI agents for automated responses - Handle high message volumes reliably - Use official, supported APIs


Prerequisites

Before connecting WhatsApp Business to NeuroGen, you'll need:

  1. Meta Business Account - Create one at business.facebook.com
  2. WhatsApp Business App - Created in Meta Developer Portal
  3. Verified Business - For production use (test mode available for development)
  4. Phone Number - A phone number to use with WhatsApp Business

Step-by-Step Setup

Step 1: Create Meta Business Account

  1. Go to business.facebook.com
  2. Click "Create Account"
  3. Follow the prompts to set up your business account
  4. Complete business verification (required for production)

Step 2: Create WhatsApp Business App

  1. Go to Meta Developer Portal
  2. Click "Create App"
  3. Select "Business" as the app type
  4. Choose "WhatsApp" as the use case
  5. Name your app and click "Create App"

Step 3: Set Up WhatsApp API

  1. In your app dashboard, find WhatsApp in the left sidebar
  2. Click API Setup
  3. You'll see your Phone Number ID - copy this
  4. Click Generate to create an access token
  5. For testing: Use the temporary token (expires in 24 hours)
  6. For production: Create a System User and permanent token
  1. Go to Business Settings
  2. Navigate to UsersSystem Users
  3. Click Add to create a new system user
  4. Assign the Admin role
  5. Click Generate New Token
  6. Select your WhatsApp app
  7. Add these permissions:
  8. whatsapp_business_management
  9. whatsapp_business_messaging
  10. Click Generate Token and copy it safely

Step 5: Connect to NeuroGen

  1. Go to DashboardIntegrations
  2. Click WhatsApp
  3. Enter your Phone Number ID
  4. Paste your Access Token
  5. Optionally enter your App Secret (for webhook security)
  6. Select an Agent to handle messages
  7. Click Connect WhatsApp Business

Step 6: Configure Webhook

After connecting, you'll receive: - Webhook URL: https://neurogen.cc/api/whatsapp-business/webhook/{your-connection-id} - Verify Token: A unique token for verification

Configure this in Meta Developer Portal:

  1. Go to your WhatsApp app
  2. Navigate to WhatsAppConfiguration
  3. Click Edit under Webhooks
  4. Enter the webhook URL
  5. Enter the verify token
  6. Subscribe to messages field
  7. Click Verify and Save

How Messages Work

Incoming Messages

When someone sends a message to your WhatsApp Business number:

  1. Meta sends a webhook to NeuroGen
  2. NeuroGen processes the message through your AI agent
  3. The response is sent back to the user

Outgoing Messages

Within 24-Hour Window: - After a user messages you, you have 24 hours to respond with any message - No template required during this window

After 24 Hours: - You must use an approved message template - Templates must be pre-approved by Meta - This prevents spam


Message Templates

For initiating conversations or messaging after 24 hours:

  1. Go to WhatsApp Manager in Meta Business Suite
  2. Navigate to Account ToolsMessage Templates
  3. Create and submit templates for approval
  4. Once approved, use them in your responses

Rate Limits

WhatsApp Business API has rate limits based on your tier:

Tier Messages/Day Requirements
Unverified 250 Test numbers only
Tier 1 1,000 Verified business
Tier 2 10,000 Good quality rating
Tier 3 100,000 Consistent high quality
Tier 4 Unlimited Enterprise agreement

Quality Rating

Meta monitors your message quality:

  • Green: High quality, good engagement
  • Yellow: Medium quality, some issues
  • Red: Low quality, restrictions may apply

Tips for maintaining quality: - Only message users who have opted in - Respond promptly (within 24 hours) - Don't send spam or promotional messages - Use templates appropriately


Testing

Test Phone Numbers

Meta provides test phone numbers in the developer dashboard:

  1. Go to WhatsAppAPI Setup
  2. Under Send and receive messages, add your phone number
  3. Verify with SMS code
  4. You can now send test messages

Test Message

Send a test message from the NeuroGen integrations page:

  1. Go to Integrations
  2. Find your WhatsApp connection
  3. Click Test (if available)
  4. Enter a phone number and message

Troubleshooting

Invalid Access Token

  • Ensure you're using the full token
  • Check if the token has expired
  • Verify the token has correct permissions

Webhook Not Receiving Messages

  1. Verify the webhook URL is correct
  2. Check the verify token matches
  3. Ensure you've subscribed to the messages field
  4. Check that your server is accessible from the internet

Message Not Sending

  • Verify the recipient phone number format (country code, no +)
  • Check if you're within the 24-hour window or using a template
  • Verify your business is approved for messaging

Rate Limited

  • Wait for the limit to reset
  • Apply to increase your messaging tier
  • Improve your quality rating

Security Best Practices

  1. Use App Secret: Configure app secret for webhook signature verification
  2. Protect Access Token: Never expose your access token in client-side code
  3. Validate Webhooks: Always verify webhook signatures
  4. Use HTTPS: All communication uses HTTPS by default

Pricing

WhatsApp Business API pricing: - Business-initiated messages: Per-message fee (varies by country) - User-initiated messages: First 1,000/month free, then per-message

Check Meta's pricing page for current rates.


Resources


Support

Need help with WhatsApp Business integration?

Connecting