in blog-samples/CSharp/TriviaBotSpeechSample/TriviaBot/TriviaDialog.cs [50:98]
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
var LU = (LuisResult)null;
// We have some text to process, run LUIS to get intent + entities
if (message.Text != null)
{
LU = await QueryLuis.GetIntentAndEntitiesFromLuis(
#error You must specify the LUIS endpoint to talk to. You can do this by creating a new LUIS app on http://luis.ai/, importing the included TriviaBotLU.json, and publishing it.
"appID", "subscriptionKey",
message.Text);
}
// Process
if (LU?.Intents?.Max()?.Intent.NormalizedEquals("Cancel") == true)
{
await Responses.Send_Goodbye(context, message);
ResetState();
}
else if (CurrentState == BotState.None)
{
await State_None(context, message, LU);
}
else if (CurrentState == BotState.Trivia)
{
await State_Trivia(context, message, LU);
}
else if (CurrentState == BotState.SwitchCategory)
{
await State_SwitchCategory(context, message, LU);
}
else if (CurrentState == BotState.WaitingForReengagement)
{
CurrentState = BotState.Trivia;
TimedOutLastTime = false;
await Responses.Send_LetsGo(context, message);
await Trivia_AskQuestion(context, message, true);
}
else
{
await Responses.Send_Error_UnknownState(context, message);
ResetState();
}
context.Wait(MessageReceivedAsync);
}