Facebook Messenger
Connect a Facebook Page so people who message it on Messenger are answered by
your governed flow. Channel key: messenger.
What you need
- A Facebook Page you administer.
- A Meta app with the Messenger product (https://developers.facebook.com/apps).
- From the App Dashboard: the Page ID, a Page access token and the App secret.
- App Review for
pages_messagingbefore people without a role on the app can message the Page (development mode works for admins/testers).
Official documentation
- Messenger Platform overview: https://developers.facebook.com/docs/messenger-platform
- Get started: https://developers.facebook.com/docs/messenger-platform/get-started
- Webhooks (events, subscriptions): https://developers.facebook.com/docs/messenger-platform/webhooks
- Send API (text,
messaging_type): https://developers.facebook.com/docs/messenger-platform/send-messages - Policy / 24-hour standard messaging window: https://developers.facebook.com/docs/messenger-platform/policy/policy-overview
- Webhook verification +
X-Hub-Signature-256: https://developers.facebook.com/docs/graph-api/webhooks/getting-started - App Review: https://developers.facebook.com/docs/app-review
Set up on Meta
- Create the app: developers.facebook.com → Create App → type Business → add the Messenger product.
- Messenger → Messenger API settings: under Access tokens click
Add or remove Pages, pick your Page, then Generate token → copy the
Page access token (needs
pages_messaging,pages_manage_metadata). - Page ID: shown next to the Page in the same panel (or Page → About).
- App secret: App settings → Basic → App secret → Show.
- Webhook: Messenger API settings → Webhooks → Configure: paste the
Callback URL and Verify token from Tools Anatomy, Verify and save.
Then Add subscriptions for the Page:
messagesandmessaging_postbacks(optionallymessage_reactions). - Submit App Review for
pages_messagingand switch the app to Live when you want the public to reach the bot.
Connect in Tools Anatomy
/channels→ Messaging channels → Facebook Messenger → Connect.- Fill in Page ID, Page access token, App secret; leave Verify token empty to have one generated.
- Connect validates the token (
GET /me?fields=id,namemust return your Page) and shows the Callback URL + Verify token to paste into the webhook configuration. The GET handshake echoeshub.challenge; each POST must carry a validX-Hub-Signature-256(HMAC-SHA256 of the raw body with the App secret) or it is rejected with 401.
Identity we derive
| Canonical key | Source | Notes |
|---|---|---|
external_user_id |
<page_id>:<PSID> |
the PSID is Page-scoped, hence the prefix |
channel |
messenger |
|
display_name |
— (profile requires an extra Graph call/permission) | |
phone_number / email |
— |
conversation_context.channel_account_id = the Page ID. Thread = the PSID.
Limits
- 24-hour standard messaging window: the Page may reply with
messaging_type: RESPONSEfor 24 h after the person's last message; later replies need message tags and are not sent by this channel. - Text is split at 2000 characters.
- Attachments (images, files, audio, stickers) arrive as attachments; the flow answers text-only. Postback buttons arrive as the button title.
- Echoes (
is_echo), delivery and read receipts are ignored; deliveries are deduplicated onmessage.mid.
Test it
While the app is in development mode, message the Page from an account that has a role on the app (admin/developer/tester). Use the Page's Inbox to see both sides.
Troubleshooting
- "the Page access token belongs to a different Page" — the token was generated for another Page; regenerate it for the Page ID you entered.
- Webhook verification fails — Callback URL/verify token mismatch; also make sure the gateway is reachable on HTTPS.
- Bot answers testers but not the public — App Review for
pages_messagingis missing or the app is not Live.