Botpress连接Messenger遇Facebook API 400错误(#100):callback_url无效求助
Hey there, let's walk through the most likely issues causing this callback URL error—even though your fallback URL passed verification in the Facebook Developer Console. Here are the key checks and fixes to get your bot connected:
1. Ensure Your Callback URL Uses HTTPS (Critical for All Scenarios)
Facebook requires all webhook URLs to be HTTPS-enabled (localhost is only allowed in strict debug mode, and Facebook’s servers still can’t reach your local machine directly). If you’re developing locally:
- Use a tool like ngrok to generate a public HTTPS tunnel for your Botpress server. Run
ngrok http 3000(replace 3000 with your Botpress port) to get a URL likehttps://abc123.ngrok.io. - Update both your Facebook Webhook URL and Botpress config to use this ngrok URL:
https://abc123.ngrok.io/api/v1/messenger/webhook.
2. Verify Exact URL Match Between Botpress & Facebook
Even a tiny discrepancy will trigger this error. Double-check:
- In your
botpress-messenger.config.yml, confirm thecallbackUrlfield matches the URL you entered in Facebook's Webhook settings exactly (including HTTPS, domain, path, and no trailing slashes unless both sides use them).
Example correct config entry:messenger: enabled: true credentials: appId: "YOUR_APP_ID" appSecret: "YOUR_APP_SECRET" accessToken: "YOUR_ACCESS_TOKEN" webhook: callbackUrl: "https://your-public-domain.com/api/v1/messenger/webhook" verifyToken: "YOUR_VERIFY_TOKEN" - In Facebook's Developer Console, go to your app > Messenger > Settings > Webhooks, and confirm the URL matches what’s in Botpress down to every character.
3. Watch for Trailing Slashes or Typos
A common gotcha is extra trailing slashes or typos in the URL. For example:
- Wrong:
https://your-domain.com/api/v1/messenger/webhook/(with trailing slash) - Correct:
https://your-domain.com/api/v1/messenger/webhook
4. Confirm Botpress Webhook is Active
Make sure the Messenger plugin’s webhook isn’t disabled in Botpress:
- Go to your Botpress dashboard > Plugins > Messenger > Settings.
- Ensure the "Enable Webhook" toggle is turned on (if present).
- Re-enter your credentials and callback URL here, then save and test the connection again.
5. Dig Into Botpress Logs for Detailed Context
If the above steps don’t resolve the issue, check Botpress logs for hidden errors:
- Navigate to your Botpress installation’s
data/logsdirectory. - Look for logs tagged with the Messenger plugin—you might find specific issues like URL parsing errors or connection timeouts that aren’t visible in the UI error message.
Final Test
After making changes:
- Go back to Facebook's Webhook settings, click "Verify and Save" to confirm the URL works.
- Restart your Botpress server to apply config changes.
- Try connecting the Messenger integration again in Botpress.
内容的提问来源于stack exchange,提问作者KISHLAY KISHORE

