watson-developer-cloud / conversation-connector

The Conversation connector is a set of components that mediate communication between your Conversation workspace and a Slack or Facebook app. Use the connector to deploy a chat bot that Slack or Facebook Messenger users can interact with.
Apache License 2.0
28 stars 62 forks source link

Does this hook up to FB's profile API? #52

Closed CJohnDesign closed 5 years ago

CJohnDesign commented 6 years ago

I have conversation-connector up and running but I have no access to the user's basic data. I need first and last name at the least but would also like profile picture and email address.

Does this app gather that information out of the box? https://developers.facebook.com/docs/messenger-platform/identity/user-profile?hc_location=ufi

dgterry commented 6 years ago

Hi @CJohnDesign by default the connector does not link up to Facebook APIs. However, it was our hope that things like this would be easy to add. If you look at the code in this folder: https://github.com/watson-developer-cloud/conversation-connector/tree/master/starter-code you'll notice several pre and post js files that are essentially stubbed out functions. The params coming into this contain the payload that facebook sends us when a user sends a message to the bot.

For example, before calling Conversation you could write some code in the pre-conversation.js main function to make a call to the facebook API you linked earlier. That API needs the PSID which facebook sends to us in the messaging.sender.id field. That API should get you the first, last, and profile picture but I believe facebook locks down information that uniquely identifies a user (for example I don't believe you can get e-mail address with this API).

Facebook does allow account linking, so if you have say a web site for your business where your user has an account...you could have them login to your bot and pull that information using an approach similar to this: https://developers.facebook.com/docs/messenger-platform/identity/account-linking