【发布时间】:2019-08-08 04:43:05
【问题描述】:
我在 node.js 中使用 Microsoft Bot Framework V4。在对话框的一个步骤中,我们需要使用 ChoicePrompt 对象和 TextPrompt 组合按钮。如果用户单击按钮,则会触发建议的操作,如果用户编写纯文本,我们将使用 LUIS 和某些意图来处理该操作。问题在于将这两种操作结合起来。
我尝试避免在使用 ChoicePrompt 时重新提示,但我无法做到。我也在寻找其他可以直接结合按钮和文本的提示,但似乎没有。
首先我在提示符中声明我正在使用的对象:
class ExampleDialog extends LogoutDialog {
constructor(userState, logger) {
super(EXAMPLE_DIALOG);
this.addDialog(new TextPrompt(TEXT_PROMPT));
this.addDialog(new ChoicePrompt(CHOICE_PROMPT));
其次,在步骤中,我使用了之前声明的提示:
async firstStep(step) {
const promptOptions = {
prompt: 'Text to prompt',
retryPrompt: 'Retry text prompt',
choices: ChoiceFactory.toChoices(['option1', 'option2', 'option3'])
};
const promptAction = await step.prompt(A_PROMPT_ID, promptOptions);
return promptAction;
}
async secondStep(step) {
const thePreviousStepResult = step.result.values
}
【问题讨论】:
-
明确地说,您希望提示接受任何字符串但仍为用户提供按钮。对吗?
-
是的,正是这个。
-
LogoutDialog是组件对话框吗? -
是的,LogoutDialog 继承自 ComponentDialog,是登录所必需的。
标签: node.js botframework