问题
I am developing a Bot Framework application that integrates with Slack using Microsoft Bot technology. In the bot project, I was trying to get the user location when the user sends a message.
What I am trying to achieve is that, when a user types the message "Show me nearby hospitals", I want to get the users Geo coordinates and pass them to an API that will return a list of hospitals near that location. So any idea on how to get the user's current location in the Microsoft Bot project?
I tried using the Geo location class, however I am not able to add the class reference directly and when I add the external DLL for the Geo location class, Visual Studio throws some errors.
Is there any way to get the users current location in Bots?
回答1:
The Bot Framework is getting updated every minute!!!
The Bing location control for Microsoft Bot Framework makes the process of collecting and validating the user’s desired location in a conversation easy and reliable.
The control is available for C# and Node.js and works consistently across all channels supported by Bot Framework.
Check the documentation here.
Click to view the code sample
回答2:
This question is old but this is now a thing that exists to help with location hope it will help someone looking for this answer. https://github.com/Microsoft/BotBuilder-Location
回答3:
Channels vary on whether they support location information. There is currently no way to get location information for users on Slack. Telegram, for instance, does. When location data is available it will returned in the Attachment data structure and in the channel's native format in the ChannelData field. Note that the user needs to opt into sending this data (to protect their privacy). The bot developer can send a message to the user requesting that they share their location data, but they cannot get it from the channel it w/o user action to share it.
回答4:
This is currently not handled by the BotBuilder well. I've opened an issue to get this standardize across platforms. Regarding Slack, they don't have an option to send a location as an attachment as Telegram, Messenger and Kik do, so you might want to use Google Geocode API to derive coordinates from a string.
来源:https://stackoverflow.com/questions/37268385/how-to-get-users-location-while-chatting-with-bots