microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.45k stars 2.44k forks source link

Facebook messenger chat plugin - activity not received by bot when clicking get started button #6372

Open geo-msft opened 2 years ago

geo-msft commented 2 years ago

Version

4.13, C#

Describe the bug

I was working with a customer on a support request on the following scenario:

When a new user clicks on the "Get started" button in the chat with the bot, in a web page using the Facebook chat plugin https://developers.facebook.com/docs/messenger-platform/discovery/facebook-chat-plugin, the bot code does not receive this sender.user_ref (nor any activity).

The issue does not happen if the users use the regular mobile Facebook Messenger app.

The customer is able to reproduce the issue here hi-logicbot.it/bots/testMessengerChatPlugin_MarinaDiVenezia.html

In addition, the customer has the necessity to receive all the web hook in channel data, not only sender.user_ref (as per Facebook documentation: https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_postbacks). The issue here is that they do not receive any activity at all when clicking that "Get started" button.

To Reproduce

Steps to reproduce the behavior:

  1. Setup the chat plugin on a web page as described here Facebook Chat Plugin - Messenger Platform
    My page page with the chat plugin is Microsoft Azure App Service - Welcome (wothchatplugin.azurewebsites.net) https://wothchatplugin.azurewebsites.net/
  2. Click on Continue as "username"
  3. Actual result: The bot does not receive an activity when clicking the button Continue as "username"

Expected behavior

Expected result: The bot should receive an activity when clicking the button Continue as "username" (before even that the user writes his first message).

The correct behaviour happens on the mobile Messenger (but not on the chat plugin https://developers.facebook.com/docs/messenger-platform/discovery/facebook-chat-plugin): usually when “messaging_postbacks” web hook is delivered to their bot as an Activity, they can find the entire web hook in the ChannelData of the Activity.

Additional context

The customer also asked this on the Microsoft QnA page https://docs.microsoft.com/en-us/answers/questions/360453/facebook-messenger-chat-plugin-webhook.html

The customer does not use Facebook custom adapter and they just configured Facebook channel as explained in our documentation https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-facebook?view=azure-bot-service-4.0 These are the web hooks they chose

image

Tracking Status

geo-msft commented 2 years ago

Facebook mentioned the web hook (sender.user_ref instead of sender.id) should be correctly received from the webchat plugin as well, not only from mobile messenger.