This guide shows how to configure the Facebook channel in Sendbot (backend + Studio) to receive and reply to messages via DMs and comments.

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

Meta App Secret and API URL

The Meta App Secret belongs to the Meta App connected to this workspace. Do not configure appSecret as a global SendBot environment variable. When creating the Facebook credential in Studio, provide the App Secret together with the account credentials. SendBot stores it encrypted with the workspace credential and uses it only to validate webhook signatures for that credential. Configure the public API URL used by Studio:
Important notes
  • Each connected Meta App can have a different App Secret.
  • NEXT_PUBLIC_SENDBOT_API_URL must 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.io and make sure HTTPS is enabled.

Webhook Configuration in Meta

In Meta Developers:
  1. Open Webhooks and add an endpoint for Page.
  2. Use the webhook URL generated by Studio:
  1. Generate the Verification Token in Studio and provide it in Meta to validate the signature.
  2. Select message events to receive DMs.
  3. For comments, also enable the Comments events on the same webhook.

Studio Configuration

  1. Go to Share on the bot -> Facebook.
  2. Create the credentials:
    • Access Token
    • Meta App Secret
    • Page ID
  3. Click Generate token and copy the Verification Token.
  4. Configure the webhook in Meta with the URL and token.
  5. Enable Enable Facebook integration and publish the bot.

Comment Replies

In Studio, you can enable automatic replies to comments:
  1. Open Share on the bot -> Facebook.
  2. In Comments, enable Enable comment replies.
  3. 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
  4. Optional: define the Start condition (comments) to filter which comments start the bot.
  5. Publish the bot.

Production Checklist

  • appSecret configured 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 appSecret or unsigned request body
  • No reply: make sure the Page is connected to the Meta app and the correct events are enabled