GithubHelp home page GithubHelp logo

microsoft / botbuilder-location Goto Github PK

View Code? Open in Web Editor NEW
99.0 25.0 84.0 1.43 MB

An open-source location picker control for Microsoft Bot Framework powered by Azure Maps and Bing Maps REST services.

License: MIT License

C# 58.24% HTML 0.19% JavaScript 20.64% TypeScript 20.88% ASP.NET 0.05%
bing-maps microsoft-bot-framework

botbuilder-location's Introduction

Microsoft Location Control for Microsoft Bot Framework

Overview

The Microsoft 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.

Location Control Top Screenshot

Use Case and Features

Bots often need the user's location to complete a task. For example, a Taxi bot requires the user's pickup and destination address before requesting a ride. Similarly, a Pizza bot must know the user's delivery address to submit the order, and so on. Normally, bot developers need to use a combination of location or place APIs, and have their bots engage in a multi-turn dialog with users to get their desired location and subsequently validate it. The development steps are usually complicated and error-prone.

The Microsoft location control makes this process easy by abstracting away the tedious coding steps to let the user pick a location and reliably validate it. The control offers the following capabilities:

  • Address look up and validation using the REST services of Azure Maps or Bing Maps depending on which API key you use in your bot.
  • User location returned as strongly-typed object complying with schema.org.
  • Address disambiguation when more than one address is found.
  • Support for declaring required location fields.
  • Support for FB Messenger's location picker GUI dialog.
  • Open-source code (C# and Node.js) with customizable dialog strings.

Prerequisites

To start using the control, you need to obtain an Azure Maps or Bing Maps API subscription key.

  • You can sign up to get a free Azure Maps key with up to 25,000 transactions per month through Azure. Details are documented here.
  • You can sign up to get a free Bing Maps key with up to 125,000 transactions per year in the Bing Maps Portal.

Getting Started

Navigate to the C# or Node.js folder and follow the guide to add the control to your Bot Framework bot.

Examples

The examples show different location selection scenarios supported by the Microsoft location control.

Address selection with single result returned

Single Address

Address selection with multiple results returned

Multiple Addresses

Address selection with required fields filling

Required Fields

Address selection using FB Messenger's location picker GUI dialog

Messenger Location Dialog

More Information

Read these resources for more information about the Microsoft Bot Framework, Bot Builder SDK and Bing Maps REST Services:

botbuilder-location's People

Contributors

an0o0nym avatar craigomatic avatar dependabot[bot] avatar emmanuelgautier avatar iassal avatar iotgirl avatar jpsaroudakis avatar kgrashad avatar mbadreldin avatar microsoft-github-policy-service[bot] avatar pcostantini avatar rbrundritt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botbuilder-location's Issues

No location results are passed by waterfall after sending facebook location quick reply

After sending this on the first:
var options = { prompt: prompts.locationPrompt, useNativeControl: true }; locationDialog.getLocation(session, options);
i'm checking for results in the next waterfall function and getting nothing back: (means not getting into this "if" statement.
if (args.response){ session.send(JSON.stringify(args)); }

I'm just trying to fetch the lat/lng from facebook.
any idea why it happens?

using locationDialog inside a library

Hi, I made a nodejs bot which is library based.

when i try to use the "botbuilder-location" inside of it, i get this error:

Dialog[botbuilder-location:/My-Library-name] not found

Is there a workaround? am i doing something wrong?

Strings resx did not support other languages

Is there a way to edit the Strings.resx and make them applicable to my application context?
(Eg. make them in Arabic language or change the word "ship" to another word like "deliver")

Current location node js

Bot framework V3, Node Js, Telegram channel, current location.
Hello everyone, I am working with the Telegram channel and I would like to know which is the simplest method to obtain the current location (latitude and longitude) of a user using node js.

I see that there is a button for the Facebook Messenger channel, but it does not apply to other channels.

I would appreciate this information.
Greetings.

Google Map

Hi

Can we manage to show the Google map instead of Bing Location?

Thanks

Problem with prompts in the chat

capture

I am getting "botbuilder-location:SingleResultFound" prompts in the chat instead of actual message. Please help me to fix this issue asap.

Thanx in advance

Latest version has missing method exception

Since bot framework version > 3.5.3 the control gets a missing method exception

Method not found: 'Void Microsoft.Bot.Builder.Dialogs.PromptDialog.Confirm(Microsoft.Bot.Builder.Dialogs.IDialogContext, Microsoft.Bot.Builder.Dialogs.ResumeAfter`1, System.String, System.String, Int32, Microsoft.Bot.Builder.Dialogs.PromptStyle)

A comment on a previous issue mentioned for them it was resolved in 3.8 but for me the issue still exists.

The problem is the assembly still has a reference to 3.3 of BotBuilder.

Stop sending pictures by default over SMS channel

I'm using an SMS channel for my bot and when the control finds an address it sends a picture of the location for the user to verify. That's a nifty feature but I'm looking to only use SMS and not MMS. Is there some way I can get it to just send the raw address for confirmation instead of two messages? One saying a result has been found and another with a picture?

Thanks everybody.

Support sending of location via DirectLine API

I have a Xamarin app using the DirectLine API. I also have the geo coordinates of the device but i have no way of passing them to the control.

The control should support sending of location for any channel, not just Facebook. Alternatively it should recognize latitude/longitude pairs in reply to the address prompt and thus I could just send that in response.

Localization issue with BotBuilder 3.5.1

Hi!
Since version 3.4.4 a few changes have been commited to the botbuilder repo that I think have broken how this control reads its localized strings.

image

These changes, introduced in Session.vgettext, are now passing the module's name along with the resource key.

V3.4.4
localization-3 4

V3.5.1
localization-1

The final resource string (later resolved by DefaultLocalizer) is prepending the namespace 'botbuilder-location' to the key 'botbuilder-location:TitleSuffix':
localization-2

A fix could be to avoid prefixing the localization key with the exports.LibraryName in the constants.
I'm not sure if this impacts other areas, so far I haven't done any further testing.
E.g.:

export const Strings = {
    "AddressSeparator": "AddressSeparator",
    "AskForEmptyAddressTemplate": "AskForEmptyAddressTemplate",
    ...

Unable to run this csharp project from visual studio code

Hi. I downloaded this project and navigated to CSHARP folder using visual studio code. Now in powershell terminal, I tried to run the project using command "dotnet run --project BotBuilderLocation.sln"

I'm getting following error:
C:\Program Files\dotnet\sdk\3.1.416\Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [D:\InsuranceClaimSolution\BotBuilder-Location-master\CSharp\BotBuilderLocation.Tests\BotBuilderLocation.Tests.csproj]
C:\Program Files\dotnet\sdk\3.1.416\Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [D:\InsuranceClaimSolution\BotBuilder-Location-master\CSharp\BotBuilderLocation\BotBuilderLocation.csproj]
D:\InsuranceClaimSolution\BotBuilder-Location-master\CSharp\BotBuilderLocation.Sample\BotBuilderLocation.Sample.csproj(158,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.416\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.416\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.

The build failed. Fix the build errors and run again.

Do I need to install .NET framework v4.6? or do I need to retarget it to my version(3.1.416), if yes, how to retarget using visual studio code?

How to receive selected location geo coordinates?

Hi there,
I am looking for a way to extract geo coordinates from user's selected location.
The same way that I can retrieve location's country and region using place.country and place.region(see node sample app from BotBuilder-Location).

Question : Using BingMapsRestToolkit & evolutions of the location control

I was wondering why the BingGeoSpatialService is not using the BingMapRestToolkit package. Is this a deliberate choice or is this something planned for the future ?

By the way what are the evolutions planned for the bing location control ? Is displaying a route on the control on the roadmap ?

Result doesn't have a response field

I don't see a response from the locationFetcher

let locationFetcher = require('botbuilder-location')
bot.library(locationFetcher.createLibrary(BING_MAPS_API_KEY))

(session) => {
                session.send("I need to find where you are")
                let options = {
                    prompt: '',
                    useNativeControl: true,
                    reverseGeocode: true
                }

                locationFetcher.getLocation(session, options)
            },
(session, results) => {

                console.log(results)

                if (results.response) {
                    let place = results.response
                    console.log(place)
                } else {
                    console.log("Place couldn't be found")
                }
            }

The result object is as follows

{
response: undefined,
resumed: 4,
childId: 'botbuilder-location:locationPickerPrompt'
}

Is it an issue? I'm testing with the Facebook platform

Showing Multiple Location in same Map

Currently if we get EstimatedTotal >1 then we are showing these location in two different cards.
What should be done if I want to show two different location in the same card?

The following code I am using to display different Cards if EstimatedTotal >1

var heroCard = new HeroCard();
var attachments = new List();
long Len = locationsResponse.ResourceSets[0].EstimatedTotal;
long i;
string sOut;
var locationsCardReply= context.MakeMessage();
for (i = 0; i < Len; i++)
{
sOut = string.Format(ImageUrlByPoint,
locationsResponse.ResourceSets[0].Resources[i].Point.Coordinates[0],
locationsResponse.ResourceSets[0].Resources[i].Point.Coordinates[1],
1) + "&key=" + apiKey;
var image = new CardImage(url: sOut);
heroCard.Images = new[] { image };
attachments.Add(heroCard.ToAttachment());
}
locationsCardReply.Attachments = attachments;
locationsCardReply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

Please reply if anyone got the solution.

Can't send location in Facebook Messenger web

Right now you can't send locations to a Facebook page when using Facebook web interface, I think the prompt should allow users to manually type an address like it does in other channels.

image

image

Cannot set default country, location query assumes US by default?

Didn't find a way to programmatically set the default country. E.g. if input 5 daw rd, it goes to US. No options fields to set the default country, region etc.

Also cannot directly massage user's inputted address because it's encapsulated in the getLocation(session, options) function. Very inconvenient for non-US users.

Improvements for Prompt Interfaces

I would like to suggest following improvements for the prompts:

  1. Use the default confirm prompt from BotBuilder for the "SingleResultFound" prompt with the "yes"/"no" buttons.
  2. Add a button "Select" under each one of the herocards for selection of the right location in case multple results are found. Add a button "Detailed View" under each hero card as well to open a bigger version of the map.
  3. Change the text of the "MultipleResultFound" prompt to "Is one of these your address? Use one of the 'select' buttons to choose an location, or type 'No' to modify your search.". Move the prompt to be above the herocards.
  4. Drop the "ConfirmationAsk" prompt if all required fields have already been filled the first time, as it will just ask to confirm the same address that was already shown in the selected herocard.
  5. Make the prompt choices/special commands easily localizable via botbuilder-location.json instead of having to change common.ts, confirm-dialog.ts, and choice-dialog.ts.

mapArea & pushpin invalid format

On a server with locale set to use decimal numbers with comma (i.e. 50,03861) the control doesn't show any map. It sends parameters like this: mapArea=50,03861,14,44113,50,05002,14,45956 and gets this error:

{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http://dev.virtualearth.net/Branding/logo_powered_by.png","copyright":"Copyright © 2017 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","errorDetails":["One or more parameters are not valid.","mapArea: This parameter value has an invalid format.","pushpin: This parameter value has an invalid format."],"resourceSets":[],"statusCode":400,"statusDescription":"Bad Request","traceId":"9b6284056aea46c99cf5c301e32fae0e|DB40170149|7.7.0.0|"}

Map shows allright in a web browser after correcting manually to mapArea=50.03861,14.44113,50.05002,14.45956.
I guess it's because of incorrect handling of double values in BingGeoSpatialService.

Way to provide an EntityRecommendation?

Can't find a way to provide an already user-submitted entity to the LocationDialog, like you can with a FormDialog.
Scenario: intent and entity provided by Luis. Something like this...

        [LuisIntent("donde_esta")]
        public async Task ProcesarDondeEsta(IDialogContext context, IAwaitable<IMessageActivity> activity,
            LuisResult result)
        {
            EntityRecommendation lugar;
            var entities = new List<EntityRecommendation>(result.Entities);
            result.TryFindEntity("lugar", out lugar);
            if (lugar != null)
            {
                Debug.WriteLine($"detectado entity: {lugar.Entity}");
                entities.Add(new EntityRecommendation(type: "Lugar") { Entity = lugar.Entity });
            }

            // how to provide entity???
            var dlg = new LocationDialog(Constants.VIRTUAL_EARTH_API_KEY, context.Activity.ChannelId, "Qué lugar estás buscando?", LocationOptions.None, LocationRequiredFields.None);
            context.Call(dlg, BuscarPlaceComplete);
        }

bot geo location

Hi,

I want to capture the bot geo location and then displaying the offers available at his presence. I have gone through bing location API but there we have to input the address data in query parameter as a rest service then only it will return the lat and long values.

  1. I need to capture the lat and long values of bot(user) geo location
  2. Need to capture the postal code from bot geo location.

Can you please let me know how can I achieve the above mentioned two requirements.

Thanks.

clickable image cards

I want to make map images clickable,
screen shot 2018-12-19 at 4 59 07 pm
currently our bot implemented as above, but we have to remove 1, 2... numbers from images and card images clickable (no more options for user input).

Cannot translate messages

Location uses a resource file to hold all the messages.

There is the LocationResourceModule with no publicly available method to set a new resource file.
The constructor that accepts a new resource file is internal (not accessible).

all the properties are virtual, but it would be much faster to assign a new resource file, instead.

Node.js : Localize dialog commands

Current node confirm dialog implementation is :

function parseBoolean(input) {
input = input.trim();
var yesExp = /^(y|yes|yep|sure|ok|true)/i;
var noExp = /^(n|no|nope|not|false)/i;
if (yesExp.test(input)) {
    return true;
}
else if (noExp.test(input)) {
    return false;
}
return undefined;

}

Which does not allow for localization.
Regex should test for locale/{current_locale}/BotBuilder.json confirm_yes and confirm_no values.

The same for other default command : other, help, reset, etc

Similar to #67 for C#

Decimal separator

If I set Bot Emulator to locale with comma as decimal separator (e.g. it) I get a broken map image due a incorrect coordinates

"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"subtitle": "95 Water St, New York, NY",
"images": [
{
"url": "https://dev.virtualearth.net/REST/V1/Imagery/Map/Road?form=BTCTRL&mapArea=40,6988751528792,-74,0195035709466,40,7066005880206,-74,0059170523339&mapSize=500,280&pp=40,7027378704499,-74,0127103116403;1;1&dpi=1&logo=always&key=Akwtog-Wb5YkszvsxY_nYKbus80tukI1ZL82tQeHvnwWJ2PVGmqchWkeJuDcOpqN"
}
]
}
}
],

40,6988751528792 instead of 40.6988751528792 and so on.

Suggested fix --> BingGeoSpatialService.GetLocationMapImageUrl (force culture to "en-US")

CultureInfo cultureEn = new CultureInfo("en-US");

        if (location.BoundaryBox != null && location.BoundaryBox.Count >= 4)
        {
            return string.Format(cultureEn,
                ImageUrlByBBox,
                location.BoundaryBox[0],
                location.BoundaryBox[1],
                location.BoundaryBox[2],
                location.BoundaryBox[3],
                point.Coordinates[0],
                point.Coordinates[1], index)
                + "&key=" + apiKey;
        }
        else
        {
            return string.Format(cultureEn, ImageUrlByPoint, point.Coordinates[0], point.Coordinates[1], index) + "&key=" + apiKey;
        }

Method not found exception Bot with QnA maker

Hello,

I am using Visual studio 2017 with Bot framework 3.8.1. Created simple QnA Maker dialog using with cognitive services 1.1.0.
QnA maker is working fine, I have tested it online. However when I test the bot which triggers QnA maker I get following exception :

Exception: Method not found: 'Void Microsoft.Bot.Builder.Dialogs.PromptOptions1..ctor(System.String, System.String, System.String, System.Collections.Generic.IReadOnlyList1<!0>, Int32, Microsoft.Bot.Builder.Dialogs.PromptStyler, System.Collections.Generic.IReadOnlyList`1<System.String>)'.",

This works well when I develop using Visual Studio 2015.

What could be the issue?

Filter the response

Is there any way to adjust the response. For example if I just want to show 3 options or just the options in a specific Country?? Also can the response be in Select mode?

Default prompts

Why are all prompts mentioning shipping ? this control should be a generic way to retrieve an address/location from the user, in most cases this has nothing to do with shipping. Please change the default prompts for something more generic.

The documentation should also tell us how to customise those prompts and how to localize them.

Unnecessary confirmation of location

Inside the LocationDialog method ResumeAfterChildDialogInternalAsync it seems to be asking for confirmation again (after I've already confirmed the address is correct). 

This seems a little unnecessary, perhaps that code could be removed?

It's also very strange to have the location dialog hardcoded to confirm that a package will be shipped to that location with no simple way to override it.

This is similar to one of the issues mentioned in #55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.