How can I return the senders first name, last name, and gender from the Facebook Graph API when a message is received?
We need two required parameters such the sender id and a page access token. The sender id can be parsed when a message is received while the page access token can be obtained when you link your page to your Facebook app.
Send a get request to the following replacing the variables with the actual values:
https://graph.facebook.com/v2.11/{ID}?fields={FIELDS_TO_ACCESS_HERE}&access_token={PAGE_ACCESS_TOKEN}
I used Postman to make the GET request and which gives a pretty-printed response of the JSON object.
Another way is by making a CURL request which gives just the same result.
You can then use the sender’s details to personalize your response in messenger.