I couldn't manage to read location from facebook channel inside botbuilder
var activity = await result as IMessageActivity;
String t = activity.ChannelData.get();
Get the longitude and latitude sent by user in the location button in facebook
I found this in another GitHub issue see if it helps you https://github.com/Yudner/Bot-Framework-Code/blob/master/LocationFacebookControl/FacebookLocationControlDialog.cs It looks like you have to read it from Channeldata > quick_reply
var channelData = JObject.FromObject(new
{
quick_replies = new dynamic[]
{
new
{
content_type = "location",
}
}
});
try this
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
dynamic data = JObject.Parse(activity.ChannelData.ToString());
string longitude = data.message.attachments[0].payload.coordinates["long"].ToString();
string latitude = data.message.attachments[0].payload.coordinates["lat"].ToString();
// return our reply to the user
await context.PostAsync(longitude + "\n\n" + latitude);
context.Wait(MessageReceivedAsync);
}
Works like charm, thank you @JasonSowers.
Thank you. I really needed this and am up and running now. It works perfectly well..
Most helpful comment
Works like charm, thank you @JasonSowers.