Reputation: 487
In the form flow after assisting user, assume Bot asking my user, "Is there anything else I can assist, Say yes or no" in the form field. If user says yes, I have to start again new intent which is greeting dialogue. Is it possible with form flow?
In the BuildForm
method, Instead of setting UserWantToCompleteEndOption
as next method to get executed, I want to complete the form flow, and look for new luis intent which is greeting dialogue.
.Field(nameof(UserWantToComplete), state => state.ReportRequest.Contains("UserWantToComplete"))
.Field(new FieldReflector<SoftwareRequestWithName>(nameof(UserWantToComplete))
.SetActive(state => state.AskToChooseReport)
.SetNext(UserWantToCompleteEndOption))
Upvotes: 0
Views: 67
Reputation: 1153
For stop filling the form you can use FormFlow's feature quit. You can find details here.
Basically when you enter the word 'quit', the bot throw an exception FormCanceledException which can be caught in the method you call after your form is filled.
Root Dialog
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
CustomerDetails form = new CustomerDetails();
FormDialog<CustomerDetails> customerForm = new FormDialog<CustomerDetails>(form, CustomerDetails.BuildForm, FormOptions.PromptInStart);
context.Call(customerForm, FormSubmitted);
}
public async Task FormSubmitted(IDialogContext context, IAwaitable<CustomerDetails> result)
{
try
{
var form = await result;
}
catch (FormCanceledException<CustomerDetails> e)
{
string reply;
if (e.InnerException == null)
{
reply = $"Thanks for filling out the form.";
}
else
{
reply = $"Sorry, I've had a short circuit. Please try again.";
}
context.Done(true);
await context.PostAsync(reply);
}
}
If you want you can implement the same in your LUIS dialog.
Upvotes: 1