I am trying to use MS bot framework connected to Facebook Messenger to create a simple demo. The demo would have a predefined list of company branches (e.g. coordinates) and when the user would send their location to the bot (using the "Share Location" function in FB messenger), it would call Google Maps API to measure distance to all branches and find the closest one.
However, I cannot acquire the location sent by the user as an attachment:
//if there is an attachment, assume it's a location
//and print out the attachments count and other info;
if (activity.Attachments != null)
int attachmentsCount = activity.Attachments.Count;
await SendReplyToUser(activity.Attachments.Count + " attachments.", activity);
if (attachmentsCount > 0)
await SendReplyToUser("I got your attachment! (" + attachmentsCount + ") " +
activity.Attachments.Content + "\n\n" + activity.Attachments.ContentType + "\n\n" +
activity.Attachments.ContentUrl + "\n\n" +
//otherwise continue processing the user's text message
The location is actually in the Entities collection, rather than the attachments collection. Look there and you should find what you need.