airyhq / airy

💬 Open Source App Framework to build streaming apps with real-time data - 💎 Build real-time data pipelines and make real-time data universally accessible - 🤖 Join historical and real-time data in the stream to create smarter ML and AI applications. - ⚡ Standardize complex data ingestion and stream data to apps with pre-built connectors
https://airy.co/docs/core
Apache License 2.0
369 stars 44 forks source link

Asynchronously fetch user profile via the Facebook User Profile API #482

Closed steffh closed 3 years ago

steffh commented 3 years ago

As a developer receiving a message from a Facebook user who messaged a Facebook page that is validly connected as a channel of source type "facebook", in case the tuple of a Facebook page id and a page scoped user id (PSID) is unknown to my Airy instance, I want to be able to asynchronously fetch the user profile information via the Facebook User Profile API and have the returned data stored in the system, so that I can more easily distinguish who messaged the relevant Facebook page


## Acceptance Criteria

## Acceptance Criteria

## Acceptance Criteria

## Design Notes

## Dev Notes

  1. Send the following GET request with the PSID of the contact and the PAGE_TOKEN as parameters in the url:

Request:

curl --request GET \
  --url 'https://graph.facebook.com/v9.0/<PSID>?access_token=<PAGE_TOKEN>&fields=first_name,last_name,profile_pic'

Response:

{
  "first_name": "Peter",
  "last_name": "Chang",
  "profile_pic": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p200x200/13055603_10105219398495383_8237637584159975445_n.jpg?oh=1d241d4b6d4dac50eaf9bb73288ea192&oe=57AF5C03&__gda__=1470213755_ab17c8c8e3a0a447fed3f272fa2179ce",
  "locale": "en_US", // optional - only there if permission has been granted & the field has been set in the request
  "timezone": -7, // optional - only there if permission has been granted & the field has been set in the request
  "gender": "male" // optional - only there if permission has been granted  & the field has been set in the request
}

In case you send a request ton include a field that you don't have permission for either on App-level or page level, the relevant property will not just be empty, but the whole request will fail.

  1. From the successful response download the image specified at profile_pic as the link will expire and upload it to a cloud storage provider as chosen by the relevant setting in the Airy Instance configuration / environment variables.

  2. Update the conversation / contact profile with the relevant data received from the Facebook User Profile API request and the uploaded user profile picture / avatar image url.

## Definition of Done

lucapette commented 3 years ago

this was done in #528