Calling LUIS from the bot
To incorporate a call to LUIS, we can start by adding this function. It simply calls LUIS and returns the city, state, or country names if the message is a weather query mentioning state and country.
Create a method in the WeatherDialog.cs
class as follows; we will call this method from the MessageReceivedAsync
method by passing the sentence asked by the user to your bot:
private static async Task<string> IdentifyCityUsingLUIS(string message) { }
Now do a GET request to your LUIS app using the LUIS URL, which you saved in an earlier step, as follows:
var responseInString = await httpClient.GetStringAsync(@"REPLACE_WITH_YOUR_URL_HERE&q=" + System.Uri.EscapeDataString(message)); dynamic response = JObject.Parse(responseInString);
Once you get a response from LUIS, try to parse it and identify whether the sentence contains the required Intent and Entities. For that, write the following code:
var intent = response.intents?.First...