Articles → MICROSOFT BOT FRAMEWORK → Open Google map in Microsoft Bot Framework

Open Google map in Microsoft Bot Framework






Generate API key








Picture showing the steps for creating the API key

Click to Enlarge





Picture showing the list of projects in Credentails screen

Click to Enlarge





Picture showing the menu option for API key generation

Click to Enlarge



Picture showing a popup window with generated API key

Click to Enlarge




Code in Bot project




var images = new List <CardImage> ();
HeroCard _card = new HeroCard();
string apiKey = "<your_generated_api_key>";
string storeAddress = "Banaras";
images.Add(
  new CardImage($"https://maps.googleapis.com/maps/api/staticmap?zoom=17&scale=2&size=600x300&maptype=roadmap&key={apiKey}&format=png&visual_refresh=true&markers=size:mid%10Ccolor:0xff0000%7Clabel:1%7C" + storeAddress));

var buttons = new List < CardAction > ();

buttons.Add(new CardAction(ActionTypes.OpenUrl, "Directions", value: $ "https://www.google.co.in/maps/dir/{"
  "}/{storeAddress}"));

_card.Buttons = buttons;
_card.Images = images;

await turnContext.SendActivityAsync(MessageFactory.Attachment(_card.ToAttachment()), cancellationToken);



Output


Picture showing the Google map on the chat bot

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, February 11, 2021

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250