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

Bot Framework未收到Facebook Messenger Referral事件,询问是否支持

Does Bot Framework Support Facebook Messenger Referral Events?

Yes, Bot Framework does support Facebook Messenger's Referral events—let’s walk through the common issues that might be preventing you from receiving them, since you’ve already confirmed permissions and routing via nGrok.

Key Checks to Troubleshoot:

  1. Verify Referral Trigger Format
    The m.me link must include a ref parameter to trigger the event, like:

    http://m.me/YourPageName?ref=your_custom_value
    

    Without the ref parameter, Facebook won’t send a Referral event at all. Double-check your link structure to ensure it’s correctly formatted.

  2. Confirm Webhook Event Subscription
    Even if you’ve granted permissions in Facebook’s app settings, you need to explicitly subscribe to the messaging_referrals event in your Bot Framework’s Facebook channel configuration:

    • Go to your Azure Bot resource → Channels → Select Facebook Messenger → Edit
    • Under "Webhook Subscriptions", ensure messaging_referrals is checked
    • Save the configuration and re-authenticate the channel if needed
  3. Check Your Bot’s Event Handling Logic
    Bot Framework wraps Facebook’s Referral event into an EventActivity with the name facebook_referral. Make sure your code is listening for this specific event type:

    • For C# SDK:
      protected override async Task OnEventActivityAsync(ITurnContext<IEventActivity> turnContext, CancellationToken cancellationToken)
      {
          if (turnContext.Activity.Name == "facebook_referral")
          {
              // Access referral data from the activity's Value property
              var referralData = turnContext.Activity.Value as JObject;
              // Add your referral handling logic here
          }
          await base.OnEventActivityAsync(turnContext, cancellationToken);
      }
      
    • For JavaScript SDK:
      this.onEvent(async (context, next) => {
          if (context.activity.name === 'facebook_referral') {
              const referralData = context.activity.value;
              // Process the referral data as needed
          }
          await next();
      });
      
  4. Inspect nGrok Request Details
    While you see messages routing to your bot, dig into the raw POST requests in nGrok to confirm if Facebook is actually sending the Referral event:

    • Look for requests where the payload includes entry[0].messaging[0].referral
    • If this payload isn’t present, the issue lies with Facebook’s event triggering (double-check your page settings or link validity)
    • If the payload is present but your bot isn’t receiving it, check Azure Monitor logs for your Bot resource to see if the event is being filtered or dropped
  5. Test with Facebook’s Graph API Explorer
    To isolate the issue, manually send a Referral event to your webhook using the Graph API:

    • Use the POST /{page-id}/messages endpoint with a payload like:
      {
          "recipient": {"id": "USER_ID"},
          "referral": {"ref": "test_ref", "source": "SHORTLINK", "type": "OPEN_THREAD"}
      }
      

    If your bot receives this test event, the problem is with how your m.me link is configured; if not, there’s likely an issue with your Bot Framework channel setup or event handling code.

Final Notes

If all checks pass and you still don’t receive the event, consider updating your Bot Framework SDK to the latest version—older versions may have compatibility issues with newer Facebook Messenger features.

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

相关产品推荐
方舟 Agent Plan

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

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