Skip to content

Instantly share code, notes, and snippets.

@Anshul0305
Created June 7, 2020 10:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anshul0305/ba7cbc86455e11250952e4b1b50b8e1a to your computer and use it in GitHub Desktop.
Save Anshul0305/ba7cbc86455e11250952e4b1b50b8e1a to your computer and use it in GitHub Desktop.
Get Facebook User Name
const axios = require('axios');
function getFacebookData(){
const PAGE_ACCESS_TOKEN=`YOUR_PAGE_ACCESS_TOKEN`;
const fb_id = request.body.originalDetectIntentRequest.payload.data.sender.id;
return axios.get(`https://graph.facebook.com/v6.0/${fb_id}?fields=first_name,last_name,profile_pic&access_token=${PAGE_ACCESS_TOKEN}`);
}
function welcome(agent) {
return getFacebookData()
.then(res => agent.add(`Hello ${res.data.first_name}`);
}
@SAAHMATHWORKS
Copy link

Thank you Anshul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment