如何在Bot Framework中从PromptDialog.Choice中取消/退出或退出? [英] How do I cancel/exit or escape from PromptDialog.Choice in Bot Framework?

查看:112
本文介绍了如何在Bot Framework中从PromptDialog.Choice中取消/退出或退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bot Framework中的PromptDialog.Choice显示工作正常的选择列表.但是,我想有一个选项来取消/退出/退出对话框,并在列表中提供取消/退出/退出选择.在PromptDialog.Choice中有什么可以覆盖的,因为我还没有找到任何取消选项.

The PromptDialog.Choice in the Bot Framework display the choice list which is working well. However, I would like to have an option to cancel/escape/exit the dialog with giving cancel/escape/exit optioin in the list. Is there anything in PromptDialog.Choice which can be overridden since i have not found any cancel option.

这是我在c#中的代码.

here is my code in c#..

PromptDialog.Choice(
                 context: context,
                 resume: ChoiceSelectAsync,
                 options: getSoftwareList(softwareItem),
                 prompt: "We have the following software items matching " + softwareItem + ". (1), (2), (3). Which one do you want?:",
                 retry: "I didn't understand. Please try again.",
                 promptStyle: PromptStyle.PerLine);

示例:

Bot:我们具有以下与Photoshop匹配的软件. (1),(2),(3).你想要哪一个

Bot: We have the following software items matching Photoshop. (1), (2), (3). Which one do you want

  • 版本1
  • 版本2
  • 版本3

如果用户不输入以上任何内容或输入命令或数字,取消,退出而绕过上面的选项,而又不触发重试错误消息,我想要什么.

What I want if user enter none of above or a command or number, cancel, exit, that bypasses the options above, without triggering the retry error message.

我们该怎么做?

推荐答案

有两种方法可以实现此目的:

There are two ways of achieving this:

  1. 添加取消"作为建议的选项.尽管这肯定行得通,但是从长远来看,您会发现自己经常重复一遍,此外,您还会在选项列表中看到取消选项,这可能是您所不希望的.
  2. 更好的方法是扩展当前的PromptChoice以添加退出/取消逻辑.好消息是,已经实现了一些东西,您可以按原样使用或作为满足您需求的基础.看看 BotBuilder-Samples 存储库中包含的> CancelablePromptChoice . 此处是如何使用它.
  1. Add cancel as an option as suggested. While this would definitely work, long term you will find repeating yourself a lot, plus that you will see the cancel option in the list of choices, what may not be desired.
  2. A better approach would be to extend the current PromptChoice to add your exit/cancelation logic. The good news is that there is something already implemented that you could use as is or as the base to achieve your needs. Take a look to the CancelablePromptChoice included in the BotBuilder-Samples repository. Here is how to use it.

这篇关于如何在Bot Framework中从PromptDialog.Choice中取消/退出或退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆