in templates/csharp/Skill/Skill/Dialogs/MainDialog.cs [116:178]
protected async Task<DialogTurnResult> InterruptDialogAsync(DialogContext innerDc, CancellationToken cancellationToken)
{
DialogTurnResult interrupted = null;
var activity = innerDc.Context.Activity;
if (activity.Type == ActivityTypes.Message && !string.IsNullOrEmpty(activity.Text))
{
// Get connected LUIS result from turn state.
var generalResult = innerDc.Context.TurnState.Get<GeneralLuis>(StateProperties.GeneralLuisResult);
(var generalIntent, var generalScore) = generalResult.TopIntent();
if (generalScore > 0.5)
{
switch (generalIntent)
{
case GeneralLuis.Intent.Cancel:
{
await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("CancelledMessage"), cancellationToken);
await innerDc.CancelAllDialogsAsync(cancellationToken);
if (innerDc.Context.IsSkill())
{
interrupted = await innerDc.EndDialogAsync(cancellationToken: cancellationToken);
}
else
{
interrupted = await innerDc.BeginDialogAsync(InitialDialogId, cancellationToken: cancellationToken);
}
break;
}
case GeneralLuis.Intent.Help:
{
await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("HelpCard"), cancellationToken);
await innerDc.RepromptDialogAsync(cancellationToken);
interrupted = EndOfTurn;
break;
}
case GeneralLuis.Intent.Logout:
{
// Log user out of all accounts.
await LogUserOutAsync(innerDc, cancellationToken);
await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("LogoutMessage"), cancellationToken);
await innerDc.CancelAllDialogsAsync(cancellationToken);
if (innerDc.Context.IsSkill())
{
interrupted = await innerDc.EndDialogAsync(cancellationToken: cancellationToken);
}
else
{
interrupted = await innerDc.BeginDialogAsync(InitialDialogId, cancellationToken: cancellationToken);
}
break;
}
}
}
}
return interrupted;
}