So far I have the following code to be used to check whether a LUIS JSON response contains a entity or not
public static class StatusHelper
{
public static bool EntityCheck(LuisResult result)
{
try
{
var statuscheck = result.Entities[0].Entity;
return true;
} catch (Exception)
{
return false;
}
}
}
And inside another file I used
if (StatusHelper.EntityCheck(LuisResult result))
{
//code
}
else
{
await context.PostAsync("No Entities");
}
In my bot emulator, if no entities were found, it would have the bot saying
No Entities
But on the dev.botframework.com website it would say
Sorry, my bot code is having an issue.
I'm not sure what's going on here
Why are you using an Exception throw for testing if there is a value? Can't you just check is your result and some entities in the array, then check if the 1st entity is not null like the following:
public static bool EntityCheck(LuisResult result)
{
return (result.Entities.Count > 0 && result.Entities[0].Entity != null);
}