简体   繁体   中英

How to move to last formfield in order to end formflow and start new intent

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))

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM