Created
June 7, 2020 10:10
-
-
Save Anshul0305/ba7cbc86455e11250952e4b1b50b8e1a to your computer and use it in GitHub Desktop.
Get Facebook User Name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you Anshul