# WhatsApp

## What it is

**WhatsApp** connects your constructor bot to WhatsApp Business via **Meta Cloud API**. Customers write to your business number; Botconsole runs the same scenarios and can show chats in the account inbox.

WhatsApp has stricter rules than Telegram: button limits, file sizes, and a **24-hour messaging window**.

## Requirements

- A **constructor bot** in Botconsole  
- A **Meta Developer App** with WhatsApp Cloud API (your team or agency sets this up)  
- WhatsApp Business number linked in Meta  
- Access to **Phone number ID** and a long-lived **access token**  

> Some plans may require a paid tariff that includes Meta channels.

## How to connect

1. Open **Bots** → your bot → **Settings**.
2. **Add connection** → **WhatsApp**.
3. Open the **Connection setup** (Meta) tab.
4. Copy **Webhook URL** and **Verify token** into your Meta App → Webhooks (if you manage the app).
5. Fill in:
   - **Phone number ID** (required)
   - **Access token** (required)
   - **App secret** (recommended)
   - WABA ID / display phone (optional)
6. Click **Save credentials**. Status should show that setup is complete.
7. In Meta, confirm the webhook is subscribed to **messages**.
8. Send a test WhatsApp message from a phone to your business number — the scenario should reply.

## Message types and limits

### Available message types

| Type | Supported | Notes |
|------|-----------|--------|
| Text | Yes | |
| Image | Yes | |
| Video | Yes | |
| Audio | Yes | |
| Voice message | Yes | Sent as WhatsApp audio |
| Document | Yes | |
| Sticker | Yes | Prefer static WebP |
| Location | Yes | Coordinates |
| Contact | Yes | Needs name and phone |
| Media group | Yes | Sent as **separate** messages (not a native album) |
| Poll | No | |
| Invoice | No | Use other payment flows if needed |

### Buttons

- **Yes**, mapped to WhatsApp interactive messages  
- Up to **3** quick reply buttons under a message  
- More than 3 (up to **10**) → **list menu** style  
- Button title up to **20** characters  
- **URL buttons** are not native WhatsApp “CTA buttons” here — the link is usually appended as text  
- Media with buttons: media is sent first, then a separate interactive message with buttons  

### Extra message options

| Option | Available |
|--------|-----------|
| Message effects | No |
| Reply to message | No |
| Link preview toggle | No (previews work by default when applicable) |
| Forward to another chat | No |
| Forum threads | No |
| AI streaming | No (full reply is sent at once) |
| Edit / delete message | No |

### Limits

| Limit | Value |
|-------|--------|
| Text | up to **4 096** characters |
| Caption | up to **1 024** |
| Interactive message body | up to **1 024** |
| Image | ~**5 MB** |
| Video / audio | ~**16 MB** |
| Document | ~**100 MB** |
| Sticker | ~**500 KB**, WebP preferred |

## Formatting

WhatsApp-style markup is supported for many styles:

- **Bold** (`*text*`), *italic* (`_text_`), ~~strikethrough~~ (`~text~`)  
- Code blocks  
- Blockquotes  
- Markdown links like `[label](url)` become plain label + URL  

Underline and spoilers are not available as on Telegram.

## Message templates

Outside the 24-hour window you can only message a customer with a **template approved by Meta**. Templates live in the bot settings: **WhatsApp → Message templates**.

1. Click **Sync** to pull templates from your WhatsApp Business Account (the connection needs a **WABA ID**), or **Create template** right there — it goes to Meta for review.
2. Open a template and choose a source for each `{{1}}`, `{{2}}`… variable: a contact field (name, phone, city…), a field of the **last order** (number, total, delivery date, items…) or fixed text. Set a default value — Meta rejects empty variables.
3. Check the result in the preview and with a **test send** to your own number.

In a WhatsApp chat, click the **WhatsApp templates** icon in the composer: variables are already filled with the customer's data and can be edited before sending.

## Notes and limitations

> **24-hour window.** It counts from the **customer's last message**: each new message from them (including a reply to a template) reopens it for another 24 hours. While it is open you can write free text; once it closes, the chat shows a warning and offers to send a template. Sending a template does not open the window.

> Customers usually need to **message you first**. Cold free-form “spam” is not allowed.

> This is **not** a Telegram BotFather token. You need Meta Cloud API credentials.

> Keep button labels short (20 characters). Long Telegram-style keyboards will be simplified on WhatsApp.
