# Connecting the WhatsApp API with ActiveMSG

### Overview

ActiveMSG provides an integrated platform for managing WhatsApp messaging. By following this guide, you can connect your WhatsApp Business account with ActiveMSG to leverage enhanced messaging and automation capabilities.

### Prerequisites

Before starting, ensure you have:

* An [ActiveMSG ](https://activemsg.com/)account
* A WhatsApp Business account
* Access to the Facebook Developer portal
* A verified phone number for WhatsApp Business

### Registering with ActiveMSG

1. **Create an Account:**
   * Visit the [ActiveMSG ](https://docs.activemsg.com/connecting-the-whatsapp-api-with-activemsg)website and sign up for an account.
   * Complete the registration process by following the on-screen instructions.
2. **Login to Your Account:**
   * After registration, log in to your ActiveMSG account to access the dashboard.

### Setting Up Your WhatsApp Business Account

1. **Create a Meta Business Account:**
   * Go to the [Meta Business Suite](https://business.facebook.com/).
   * Click "Create Account" and follow the steps to set up your business profile.
2. **Verify Your Business:**
   * Navigate to "Business Settings" and complete the verification by providing necessary documents.

### Generating API Credentials

1. **theRegister Your WhatsApp Business Account:**
   * Visit the [WhatsApp Business API](https://developers.facebook.com/docs/whatsapp) and register your business.
2. **Create a WhatsApp Business App:**
   * In the Facebook Developer portal, go to "My Apps" and click "Create App."
   * Select "Business" type and fill in the required details.
3. **Generate Access Tokens:**
   * Go to "Settings" > "Basic" in your app dashboard.
   * Copy your "App ID" and "App Secret."
   * Generate an access token for API requests.
4. **Obtain Phone Number ID and WhatsApp Business Account ID:**
   * Navigate to the Facebook app, then go to "WhatsApp" -> "API Setup."
   * Copy your "Phone Number ID" and "WhatsApp Business Account ID."

### Configuring ActiveMSG

1. **Access API Integration:**
   * In your ActiveMSG dashboard, go to the "API Integration" section.
2. **Enter API Credentials:**
   * Input the following details:
     * **App ID:** Enter your App ID
     * **App Secret:** Enter your App Secret
     * **Phone Number ID:** Enter your Phone Number ID
     * **WhatsApp Business Account ID:** Enter your WhatsApp Business Account ID
3. **Save Configuration:**
   * Save the configuration to establish the connection between ActiveMSG and your WhatsApp Business account.

### Testing the Integration

1. **Send a Test Message:**
   * In the ActiveMSG dashboard, go to the "Test Message" section.
   * Enter a recipient's phone number and a test message.
   * Click "Send" to verify the integration.
2. **Verify Message Delivery:**
   * Check the recipient’s WhatsApp to confirm the message was received.

### Handling Webhooks

1. **Set Up Webhooks:**
   * In the Facebook Developer portal, navigate to "Webhooks."
   * Configure your webhook endpoint using the following example details:
     * **Webhook callback URL:** `https://activemsg.com/whatsapp/webhook/YOUR_UNIQUE_TOKEN`
     * **Verify Token:** `YOUR_UNIQUE_VERIFY_TOKEN`
   * **Note:** Replace `YOUR_UNIQUE_TOKEN` and `YOUR_UNIQUE_VERIFY_TOKEN` with your unique values provided by ActiveMSG.
2. **Verify Webhooks:**
   * Complete the verification process by providing the verification token and URL.
3. **Enable Message Handling:**
   * In the Webhook fields, select "Messages" under "Manage" to enable message handling.

### Best Practices

* **Security:** Keep your access tokens and credentials secure and confidential.
* **Rate Limits:** Adhere to API rate limits to avoid service throttling.
* **Compliance:** Follow WhatsApp’s messaging policies to ensure compliance.

### FAQs

1. **How do I reset my access token?**
   * Go to your app's settings in the Facebook Developer portal to regenerate the token.
2. **What message types are supported?**
   * The API supports various message types, including text, media, and templates.

### Support

* For further assistance, visit the [ActiveMSG](https://activemsg.com/) Support Center.
* Refer to the [WhatsApp Business API documentation](https://developers.facebook.com/docs/whatsapp) for additional details.
