Prerequisites
- A Meta Developers app with Messenger access
- A valid Access Token with page permissions
- The Page ID for the Facebook Page that will receive messages
Backend Configuration (API)
In your API environment, both production and staging, configure:META_APP_SECRETis used to validate webhook signatures. Without it, the webhook returns500.NEXT_PUBLIC_SENDBOT_API_URLmust point to your public API so Studio can generate the webhook URL.- In a local environment, use a public URL such as
https://<your-ngrok>.ngrok.ioand make sure HTTPS is enabled.
Webhook Configuration in Meta
In Meta Developers:- Open Webhooks and add an endpoint for Page.
- Use the webhook URL generated by Studio:
- Generate the Verification Token in Studio and provide it in Meta to validate the signature.
- Select message events to receive DMs.
- For comments, also enable the Comments events on the same webhook.
Studio Configuration
- Go to Share on the bot -> Facebook.
- Create the credentials:
- Access Token
- Page ID
- Click Generate token and copy the Verification Token.
- Configure the webhook in Meta with the URL and token.
- Enable Enable Facebook integration and publish the bot.
Comment Replies
In Studio, you can enable automatic replies to comments:- Open Share on the bot -> Facebook.
- In Comments, enable Enable comment replies.
- Choose the Reply mode:
- Public reply: replies on the comment
- DM only: sends a DM to the user
- Public + DM: replies on the comment and sends a DM
- Optional: define the Start condition (comments) to filter which comments start the bot.
- Publish the bot.
Production Checklist
META_APP_SECRETconfigured in the backend- Public API URL configured in Studio
- Webhook validated in Meta using the token generated by Studio
- Credentials saved and integration enabled on the bot
- Comments events enabled on the webhook if you use comment replies
Quick Troubleshooting
- Webhook 401: invalid signature or incorrect token
- Webhook 500: missing
META_APP_SECRETor unsigned request body - No reply: make sure the Page is connected to the Meta app and the correct events are enabled