> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kaie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# WhatsApp Business Integration

> Connect and automate WhatsApp Business messaging with Kaie

## WhatsApp Business Integration

WhatsApp Business integration allows you to send and receive messages, media, and interactive content through WhatsApp's official Business API. This integration is perfect for customer support, sales, and marketing automation.

## Getting Started

### Prerequisites

* WhatsApp Business Account
* Facebook Business Manager account
* Verified phone number
* Business verification (for some features)

### Setup Process

<Steps>
  <Step title="Create WhatsApp Business Account">
    1. Go to [business.whatsapp.com](https://business.whatsapp.com)
    2. Sign up with your business information
    3. Verify your business details
    4. Complete the onboarding process
  </Step>

  <Step title="Connect to Kaie">
    1. Navigate to Integrations in your Kaie dashboard
    2. Select "WhatsApp Business" from the available integrations
    3. Click "Connect Account"
    4. Authorize Kaie to access your WhatsApp Business account
  </Step>

  <Step title="Configure Settings">
    1. Set your business display name
    2. Upload your business logo
    3. Configure message templates
    4. Set up webhook endpoints
  </Step>
</Steps>

## Message Types

### Text Messages

Send simple text messages to customers.

<AccordionGroup>
  <Accordion title="Basic Text Messages">
    * Plain text messages
    * Emoji support
    * Basic formatting (bold, italic, strikethrough)
    * Variable substitution
  </Accordion>

  <Accordion title="Configuration">
    ```json theme={null}
    {
      "type": "text",
      "text": "Hello {{customer_name}}, how can I help you today?",
      "preview_url": false
    }
    ```
  </Accordion>
</AccordionGroup>

### Media Messages

Send images, videos, documents, and audio files.

<AccordionGroup>
  <Accordion title="Supported Media Types">
    * **Images**: JPG, PNG, GIF (max 5MB)
    * **Videos**: MP4, 3GPP (max 16MB)
    * **Documents**: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX (max 100MB)
    * **Audio**: AAC, M4A, AMR, MP3, OGG (max 16MB)
  </Accordion>

  <Accordion title="Configuration">
    ```json theme={null}
    {
      "type": "image",
      "image": {
        "link": "https://example.com/image.jpg",
        "caption": "Check out our latest product!"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### Interactive Messages

Send buttons, lists, and quick replies for better user engagement.

<AccordionGroup>
  <Accordion title="Button Messages">
    * Up to 3 buttons per message
    * Call-to-action buttons
    * URL buttons
    * Quick reply buttons
  </Accordion>

  <Accordion title="List Messages">
    * Up to 10 list items
    * Section headers
    * Descriptions and emojis
    * Interactive selection
  </Accordion>
</AccordionGroup>

### Template Messages

Send pre-approved message templates for marketing and notifications.

<AccordionGroup>
  <Accordion title="Template Types">
    * **Marketing**: Promotional content
    * **Utility**: Account updates, notifications
    * **Authentication**: OTP, verification codes
  </Accordion>

  <Accordion title="Template Requirements">
    * Must be approved by WhatsApp
    * Follow specific formatting rules
    * Include required parameters
    * Respect messaging policies
  </Accordion>
</AccordionGroup>

## Webhook Configuration

### Setting Up Webhooks

Configure webhooks to receive incoming messages and status updates.

<AccordionGroup>
  <Accordion title="Webhook Events">
    * **messages**: Incoming customer messages
    * **message\_status**: Delivery and read receipts
    * **message\_errors**: Failed message notifications
  </Accordion>

  <Accordion title="Configuration">
    1. Go to your WhatsApp Business API settings
    2. Add webhook URL: `https://api.kaie.ai/webhooks/whatsapp`
    3. Verify webhook with challenge token
    4. Subscribe to required events
  </Accordion>
</AccordionGroup>

### Webhook Payload Structure

Understand the structure of incoming webhook data.

```json theme={null}
{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "WHATSAPP_BUSINESS_ACCOUNT_ID",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": {
              "display_phone_number": "PHONE_NUMBER",
              "phone_number_id": "PHONE_NUMBER_ID"
            },
            "messages": [
              {
                "id": "MESSAGE_ID",
                "from": "CUSTOMER_PHONE_NUMBER",
                "timestamp": "TIMESTAMP",
                "text": {
                  "body": "MESSAGE_TEXT"
                },
                "type": "text"
              }
            ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}
```

## Workflow Integration

### Message Triggers

Set up workflows that respond to incoming WhatsApp messages.

<AccordionGroup>
  <Accordion title="Trigger Configuration">
    * **Message Content**: Respond to specific text
    * **Media Type**: React to images, videos, etc.
    * **Customer Type**: New vs. existing customers
    * **Time-based**: Business hours only
  </Accordion>

  <Accordion title="Use Cases">
    * **Customer Support**: Answer common questions
    * **Order Status**: Provide order updates
    * **Appointment Booking**: Schedule meetings
    * **Product Information**: Share product details
  </Accordion>
</AccordionGroup>

### Automated Responses

Configure AI-powered responses for customer inquiries.

<AccordionGroup>
  <Accordion title="Response Types">
    * **Instant Replies**: Quick responses to common questions
    * **AI-Generated**: Intelligent responses using AI Brain
    * **Template-Based**: Pre-written responses for specific scenarios
    * **Escalation**: Route complex issues to human agents
  </Accordion>

  <Accordion title="Configuration">
    * Set response time limits
    * Configure escalation rules
    * Define conversation flows
    * Set up fallback responses
  </Accordion>
</AccordionGroup>

## Advanced Features

### Rich Media Support

Send engaging content with images, videos, and documents.

<AccordionGroup>
  <Accordion title="Image Messages">
    * High-quality image sharing
    * Caption support
    * Thumbnail generation
    * Format optimization
  </Accordion>

  <Accordion title="Video Messages">
    * Video preview generation
    * Caption support
    * Format conversion
    * Size optimization
  </Accordion>
</AccordionGroup>

### Interactive Elements

Create engaging conversations with interactive components.

<AccordionGroup>
  <Accordion title="Quick Replies">
    * Pre-defined response options
    * Easy customer selection
    * Workflow branching
    * Data collection
  </Accordion>

  <Accordion title="Call-to-Action Buttons">
    * Visit website
    * Call phone number
    * Send email
    * Custom actions
  </Accordion>
</AccordionGroup>

### Message Status Tracking

Monitor message delivery and engagement.

<AccordionGroup>
  <Accordion title="Status Types">
    * **Sent**: Message sent to WhatsApp
    * **Delivered**: Message delivered to customer
    * **Read**: Customer opened the message
    * **Failed**: Message delivery failed
  </Accordion>

  <Accordion title="Use Cases">
    * Track campaign performance
    * Monitor customer engagement
    * Identify delivery issues
    * Optimize send times
  </Accordion>
</AccordionGroup>

## Best Practices

### Message Guidelines

Follow WhatsApp's messaging policies and best practices.

<AccordionGroup>
  <Accordion title="Content Guidelines">
    * Keep messages relevant and valuable
    * Avoid spammy or promotional content
    * Respect customer preferences
    * Follow WhatsApp's terms of service
  </Accordion>

  <Accordion title="Timing Guidelines">
    * Send messages during business hours
    * Respect customer time zones
    * Avoid excessive messaging
    * Allow opt-out options
  </Accordion>
</AccordionGroup>

### Performance Optimization

Optimize your WhatsApp integration for better performance.

<AccordionGroup>
  <Accordion title="Message Optimization">
    * Use appropriate message types
    * Optimize media file sizes
    * Test message rendering
    * Monitor delivery rates
  </Accordion>

  <Accordion title="Workflow Optimization">
    * Minimize response times
    * Use efficient trigger conditions
    * Implement proper error handling
    * Monitor workflow performance
  </Accordion>
</AccordionGroup>

## Troubleshooting

### Common Issues

Resolve common WhatsApp integration problems.

<AccordionGroup>
  <Accordion title="Message Delivery Issues">
    * Check phone number format
    * Verify webhook configuration
    * Review message content
    * Check rate limits
  </Accordion>

  <Accordion title="Authentication Problems">
    * Verify API credentials
    * Check token expiration
    * Review permissions
    * Test webhook connectivity
  </Accordion>
</AccordionGroup>

### Error Codes

Understand common error codes and their solutions.

| Error Code | Description              | Solution             |
| ---------- | ------------------------ | -------------------- |
| 100        | Invalid parameter        | Check message format |
| 131000     | Message undeliverable    | Verify phone number  |
| 131021     | Re-engagement message    | Use template message |
| 131026     | Unsupported message type | Use supported format |

## Next Steps

Explore more integration options:

<CardGroup cols={2}>
  <Card title="Instagram Integration" icon="instagram" href="/integrations/instagram">
    Connect with customers through Instagram Direct
  </Card>

  <Card title="Voice Calls" icon="phone" href="/integrations/voice-calls">
    Set up AI-powered voice interactions
  </Card>

  <Card title="AI Brain System" icon="brain" href="/integrations/ai-brain">
    Leverage AI for intelligent conversations
  </Card>

  <Card title="Analytics" icon="chart-line" href="/analytics/overview">
    Monitor WhatsApp performance and engagement
  </Card>
</CardGroup>
