You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Facebook Messenger PHP机器人非管理员无法正确响应问题求助

Troubleshooting Your Facebook Messenger Bot: Admin vs Subscriber Response Issue

Hey there, let's figure out why your PHP-built Messenger bot works great for admins but keeps spitting out [get_started payload] (or no response at all) for regular subscribers. This is a super common hiccup, so let's walk through the most likely fixes step by step:

1. Fix Your Event Handling Logic

First off, the get_started payload usually triggers when a user interacts with your bot for the first time. If subscribers are seeing this every time they message, your code might be misclassifying regular messages as postback events, or failing to handle standard message events entirely.

Check your webhook code to make sure you're properly distinguishing between postback events (like the initial get_started tap) and regular message events:

$input = json_decode(file_get_contents('php://input'), true);
if (isset($input['entry'][0]['messaging'][0]['postback'])) {
    // Handle postback actions (e.g., get_started button taps)
    $payload = $input['entry'][0]['messaging'][0]['postback']['payload'];
    if ($payload === 'GET_STARTED') {
        // Send your welcome message here
        sendWelcomeMessage($input['entry'][0]['messaging'][0]['sender']['id']);
    }
} elseif (isset($input['entry'][0]['messaging'][0]['message'])) {
    // Handle regular text messages from users
    $userId = $input['entry'][0]['messaging'][0]['sender']['id'];
    $userMessage = $input['entry'][0]['messaging'][0]['message']['text'];
    // Generate and send your custom response here
    sendCustomResponse($userId, $userMessage);
}

Double-check that you aren't accidentally calling the get_started handling function inside the regular message branch—that's an easy mistake to make!

2. Verify Webhook Event Subscriptions

Admins often get special treatment during testing, so your webhook might not be set up to receive regular message events from subscribers. Head over to your Facebook Developer Dashboard:

  • Go to your app → Messenger → Settings → Webhooks
  • Make sure you've subscribed to both messages and messaging_postbacks events. If messages isn't checked, your bot will never receive regular messages from non-admin users.
  • Confirm your webhook is properly verified (no red errors here—if verification failed, re-run the setup process).

3. Check Page & App Permissions

Your bot might not have permission to interact with all users. Let's confirm:

  • Go to your Facebook Page → Settings → Advanced → Page Roles
  • Ensure your app is listed as a Page App with at least "Manage Page" permissions (or permission to receive messages).
  • Also, in the Messenger settings of your app, check if you've restricted interactions to only admins/test users. Look for any settings labeled "Subscriber Access" or "Test Mode" that might be limiting who can message the bot.

4. Hunt for Hardcoded Payload Text

It's possible your code has a hardcoded [get_started payload] string somewhere that's being sent accidentally. Search your entire codebase for this exact phrase—you might find something like:

// Oops! Wrong response being sent
sendMessage($userId, '[get_started payload]');

Replace that with your actual message handling logic, and you should see the issue disappear.

5. Debug with Logs & Non-Admin Testing

To get to the bottom of it, enable error logging in your PHP code to see exactly what data Facebook is sending your webhook:

// Log incoming webhook data to your server's error log
error_log('Webhook Input: ' . file_get_contents('php://input'));

Then test with a non-admin account (ask a friend to message the bot!) and check your server logs. You'll be able to see if:

  • The webhook isn't receiving message events from subscribers
  • Your code is throwing errors when processing those events
  • The payload data isn't being parsed correctly

内容的提问来源于stack exchange,提问作者Arber Coku

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:42:30