Я пытаюсь следовать этой статье из Документов Microsoft, чтобы перенести наш код версии 3 в версию 4.
Однако я не уверен, как переписать диалог Luis.Что нужно сделать?
Я добавил приведенный ниже код в onturnasync, не уверен, как переписать метод возобновления AfterFAQ сейчас.
Пожалуйста, помогите мне переписать эти существующие методы Luis:
//The LUIS dialog service call the back the method if the conversation is part of Greeting intent
[LuisIntent("Greetings")]
public async Task Greetings(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
needMoreInformation = false;
qnaInvalidMessageCount = 0;
var messageToForward = await activity;
string[] supportList = { "HELP", "FEEDBACK", "SUPPORT", "ESCALATE", "AGENT" };
string qnaAnswer;
if (messageToForward.Text == null || supportList.Any(x => x == messageToForward.Text.ToUpper()))
{
await context.PostAsync("Please reach out to ...");
context.Wait(MessageReceived);
}
else if (GreetingColl.TryGetValue(messageToForward.Text.Trim().ToLower(), out qnaAnswer))
{
await context.PostAsync(qnaAnswer);
context.Wait(MessageReceived);
}
else
{
await context.Forward(new QnAGreetingsDialog(), AfterFAQDialog, messageToForward, CancellationToken.None);
}
}
модифицированный код:
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
if (turnContext.Activity.Type == ActivityTypes.Message)
{
...
var luisResults = await botServices.LuisServices[LuisKey].RecognizeAsync(turnContext, cancellationToken);
var topScoringIntent = luisResults?.GetTopScoringIntent();
var topIntent = topScoringIntent.Value.intent;
// Continue the current dialog
var dialogResult = await dc.ContinueDialogAsync();
// if no one has responded,
if (!dc.Context.Responded)
{
// examine results from active dialog
switch (dialogResult.Status)
{
case DialogTurnStatus.Empty:
switch (topIntent)
{
case NoneIntent:
case GreetingsIntent:
await dc.BeginDialogAsync(nameof(QnAGreetingsDialog));
break;
case CredentialsIntent:
case ContactusIntent:
await LuisVar.Feedback(turnContext);
break;
case FeedbackIntent:
await LuisVar.Feedback(turnContext);
break;
default:
// No intent identified, provide some help to the user
await dc.Context.SendActivityAsync("I didn't understand what you just said to me.");
break;
}
break;
case DialogTurnStatus.Waiting:
// The active dialog is waiting for a response from the user, so do nothing.
break;
case DialogTurnStatus.Complete:
await dc.EndDialogAsync();
break;
default:
await dc.CancelAllDialogsAsync();
break;
}
}
}
}