简体   繁体   English

如何移动到最后一个表单域以结束表单流并开始新的意图

[英]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. 在协助用户之后的表单流程中,假设Bot在表单字段中问我的用户“还有什么我可以帮助的,说是或否”。 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. BuildForm方法中,我希望完成表单流程,而不是将UserWantToCompleteEndOption设置为要执行的下一个方法,而是寻找新的luis意图,即问候语。

.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. 要停止填写表单,您可以使用FormFlow的功能退出。 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. 基本上,当您输入单词“ quit”时,机器人会引发一个异常FormCanceledException,该异常可以在表单填写后被调用的方法捕获。

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. 如果需要,可以在LUIS对话框中实现相同的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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