Reputation: 327
I have a step by step question to the user where each question is a dialog. Can I have a step by step flow and each having a different LUIS Intent? What is the best approach for this?
I’m not sure how to assign one intent per dialog because when in RoomReservationDialog
I just instantiate the dialog for the first step which is RoomReservationNameDialog
. Then inside RoomReservationNameDialog
I just instantiate the next step which is RoomReservationDateTimeDialog
in the MessageReceived method.
class RoomReservationDialog
{
protected override async Task StartAsync(IDialogContext context)
{
context.Call(new RoomReservationNameDialog(), MessageReceived);
}
}
class RoomReservationNameDialog
{
public override async Task StartAsync(IDialogContext context)
{
// ask question
}
protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
{
…
context.Call(new RoomReservationDateTimeDialog(), HandleResult);
}
}
Upvotes: 1
Views: 129
Reputation: 29
Have you looked at FormFlow (Microsoft Docs)? It seems like a suitable answer to your step-by-step flow.
Also specifically using FormFlow with LUIS, you can look at this previously asked question (Stack Overflow) and this recent blog post that might help.
Upvotes: 1
Reputation: 3426
Generally, people put their intents in the same dialog like the code below. From this dialog, you can call another one inside the intent if that is how you want to structure your code.
[Serializable]
[LuisModel("Luis app id", "Luis key")]
public class LuisDialog : LuisDialog<object>
{
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
string message = $"Sorry, I did not understand '{result.Query}'. Type 'help' if you need assistance.";
await context.PostAsync(message);
context.Wait(this.MessageReceived);
}
[LuisIntent("greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
string message = $"Hello there";
await context.PostAsync(message);
context.Wait(this.MessageReceived);
}
[LuisIntent("Room.AnswerName")]
public async Task Left(IDialogContext context, LuisResult result)
{
//do stuff
//or call new dialog to do stuff
context.Call(new RoomReservationNameDialog(), ResumeAfterMethod);
}
[LuisIntent("Room.AnswerDateTime")]
public async Task Right(IDialogContext context, LuisResult result)
{
//do stuff
//or call new dialog to do stuff
context.Call(new RoomReservationDateTimeDialog(), ResumeAfterMethod);
}
[LuisIntent("Room.AnswerFloor")]
public async Task Middle(IDialogContext context, LuisResult result)
{
//do stuff
//or call new dialog to do stuff
context.Call(new RoomReservationFloorDialog(), ResumeAfterMethod);
}
}
Upvotes: 1