In Facebook Messenger there is an icon allowing the user to send their geo coordinates.
Is this available on the Facebook Messenger platform yet i.e. if a user sends me their location does my Chatbot have access to it? If so how is it done because i can't see it in the response in my webhook.
In the Live Dashboard, navigate to Tools & Settings. Under Tools, select Chatbot. On the Chatbot Settings page, select Chatbot from the dropdown menu on the left-hand side.
So, a chatbot in Facebook is an artificial intelligence program, capable of “conversing” with people, respond particular questions, and automatically provide suggestions. This way, it is possible to configure it to answer the public, according to the profile and exact needs of each business.
You get the location as attachment in message. See sample below:
{ mid: 'mid.1463464074086:96b149e1a047e47842',
seq: 2076,
attachments:
[ { title: 'Anupam\'s Location',
url: 'https://www.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3D19.120002%252C%2B72.863715%26FORM%3DFBKPL1%26mkt%3Den-US&h=AAQH523sr&s=1&enc=AZNmEBjv3zHHm0_dYnEIC6j7EDsJNt8PZRZZyaXbIZ6VzjPsQUOOaMIPGtXFH17CevUiNK0_K594CgDQHAMQSru7uS_jjbkxojBWNwBnncqzaw',
type: 'location',
payload: [Object] } ] }
From the payload, you can access the Latitude and Longitude using:
lat = event.message.attachments[0].payload.coordinates.lat
lng = event.message.attachments[0].payload.coordinates.long
Yes, the location will be sent as an attachment in the message. If you are referring to the example code given in the facebook messenger platform documentation the fix can be done as follows....(please refer the complete code here https://developers.facebook.com/docs/messenger-platform/quickstart)
in the else section
else if (messageAttachments) {
console.log(messageAttachments[0].payload.coordinates.lat); //gives you lat
console.log(messageAttachments[0].payload.coordinates.long); // gives you long
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With