# Facebook Messenger

## What it is

**Facebook Messenger** connects a Facebook Page to your constructor bot through **Meta**. When someone writes to your Page in Messenger, Botconsole answers with the published scenario and shows the dialogue in Chats — the same way Telegram, WhatsApp, and Instagram already do.

Unlike the current MVP-level Instagram integration, Messenger supports constructor buttons **for real**: quick replies and links render as native Messenger buttons instead of being flattened into plain text.

## Requirements

- A **constructor bot** in Botconsole
- A Facebook **Page** the bot should reply from
- A Meta app with the **Messenger** product
- **Page ID** and **Page access token**

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

## How to connect

1. Open **Bots** → your bot → **Settings**.
2. **Add connection** → **Messenger**.
3. Open **Connection setup**.
4. Copy **Webhook URL** and **Verify token** into the Meta App webhooks (the same URL as WhatsApp/Instagram — Meta sends every connected channel's webhooks to one address, and Botconsole works out which Page a message belongs to).
5. Paste:
   - **Facebook Page ID** (required)
   - **Page access token** (required)
   - **Page name** (optional, shown in the dashboard)
   - **Public page username** (optional — used for the `m.me/...` link in the web widget)
   - **App secret** (recommended — verifies webhook signatures)
6. **Save credentials**.
7. Subscribe the Page to the webhook in the Meta App (`messages`, `messaging_postbacks` fields).
8. Message the Page in Messenger — the scenario should reply.

## Message types and limits

### Available message types

| Type | Supported | Notes |
|------|-----------|--------|
| Text | Yes | Main channel for scenarios |
| Image | Yes | Sent by direct file URL |
| Video | Yes | |
| Audio | Yes | |
| Document | Yes | Sent as a file attachment |
| Media album | Yes | Sent as consecutive messages |
| Voice, sticker | No | |
| Location, contact | No | |
| Poll, invoice, carousel | No | |

### Buttons

- **Callback (reply) buttons** map to **quick replies** — up to **13**, button text up to **20** characters
- **URL buttons** map to a native Messenger **button template** — up to **3** links per message
- A constructor reply keyboard also becomes quick replies — not persistent, shown only alongside the message it's attached to

### Extra message options

| Option | Available |
|--------|-----------|
| Typing indicator | Yes |
| Message effects | No |
| Reply to message | No |
| Link preview toggle | No |
| Forward / forum | No |
| AI streaming | No — the full reply is sent once generation finishes |
| Edit / delete | No |
| Carousels (Generic Template) | No — planned |

### Limits

| Limit | Value |
|-------|--------|
| Text | up to **2 000** characters |
| Button (quick reply / link) | text up to **20** characters |
| Media | up to **25 MB** |

## Formatting

Messages are sent as **plain text**. Constructor Markdown (bold, links, etc.) is stripped — Messenger has no rich-text formatting.

## Notes and limitations

> **24-hour messaging window.** Like other Meta channels, free-form replies require the user to have written within the last 24 hours. Outside that window a standard message send fails — scenario-based broadcasts outside the messaging window aren't supported for Messenger yet.

> The user's profile (name, avatar) is fetched automatically on first contact only — no repeated calls to Meta afterward.

> If both Messenger and (legacy) Instagram are connected to the same Facebook Page, the Messenger connection takes priority.

> After saving credentials, always test by messaging from a **different Facebook account**, not the Page admin's own account.
