Facebook Messenger
- User messages your Page on Messenger.
- Meta sends webhook events to your server.
- Your server calls GeniStudio
/api/v1/message
. - Reply to the user through Messenger Send API.
Setup (Meta)
Section titled “Setup (Meta)”- Create an app, add Messenger product.
- Connect your Facebook Page.
- Generate a Page Access Token.
- Set up Webhooks: subscribe to
messages
on the Page.
Webhook (Express example)
Section titled “Webhook (Express example)”// Similar to WhatsApp example; extract sender PSID and textconst sender = entry.messaging[0].sender.id;const text = entry.messaging[0].message?.text;// Forward to GeniStudio, then reply using `/me/messages?access_token=PAGE_TOKEN`.
POST https://graph.facebook.com/v20.0/me/messages?access_token=PAGE_TOKEN{ "recipient": { "id": "<PSID>" }, "message": { "text": "<AI response>" }}
Security: verify webhook, store tokens securely, handle rate limits.