1
I’m using Luis.ai to create my neural network of intents and Microsoft Bot Framework to create my chatbot, but I’m not able to read a json that luis is generating for me.
Luis' class:
public static async Task<LuisResult> GetResponse(string message)
{
using (var client = new HttpClient())
{
var url = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/06145033-fb92-485e-acd5-0bf432e892d5?subscription-key=a66048dcba8e4dcd845c91ebfff5a031&verbose=true&timezoneOffset=-180&q=" + message;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode) return null;
var result = await response.Content.ReadAsStreamAsync();
var js = new DataContractJsonSerializer(typeof(LuisResult));
return (LuisResult)js.ReadObject(result);
}
}
As I’m calling you:
Console.WriteLine(luis.GetResponse(activity.Text.ToLower()).Result.Intents[0].Intent.ToString());
I’m doing everything locally.
EDIT:
When I do the debugging, it gets infinitely on this line:
var response = await client.GetAsync(url);
I created another solution, did the whole process of downloading Json, and in this new solution worked perfectly...
You can switch to the Newtonsoft.Json Library?
– Tiago S
I believe so, but what would the code look like? @Tiago
– Francisco
Minimal changes
– Tiago S
So far you have no error, are 2 warnings. The first, about the debug of System.Net.Http.WebRequest.dll and the debug option "just my code". The second Warning speaks of the passing of the JWT token, however the message is just a Warning that is not passing the token.
– Luiz Carlos Faria