node.js - 为 botframework v4 选择提示应用列表样式:NodeJS
问题描述
您好我正在尝试在 botbuilder-dialog 的选项中添加列表样式;Botframework v4,NodeJS。
我正在尝试使用下面的代码来实现它,但似乎列表样式对选择没有任何影响。它应该提示一个编号列表,但它会提示一个类似列表的按钮。
const{ChoicePrompt, ListStyle} = require('botbuilder-dialogs');
const CHOICE_PROMPT = 'CHOICE_PROMPT';
//Set up ChoicePrompt
var cp = new ChoicePrompt(CHOICE_PROMPT);
cp.Style = ListStyle.list;
this.addDialog(cp);
this.choicesX = ['Pick1', 'Pick2', 'Pick3'];
//function
async test(stepContext){
return await stepContext.prompt(CHOICE_PROMPT, {
prompt: 'Select item:',
choices: this.choicesX
});
}
在选择提示中添加列表样式的正确方法是什么?
解决方案
这似乎是这个 StackOverflow 问题的副本;但是,答案在 C# 中。这就是在 Node SDK 中设置样式提示选项的方式。
节点SDK v4.5
const { ListStyle, ... } = require('botbuilder-dialogs');
async transportStep(step) {
// WaterfallStep always finishes with the end of the Waterfall or with another dialog; here it is a Prompt Dialog.
// Running a prompt here means the next WaterfallStep will be run when the users response is received.
return await step.prompt(CHOICE_PROMPT, {
prompt: 'Please enter your mode of transport.',
choices: ChoiceFactory.toChoices(['Car', 'Bus', 'Bicycle']),
style: ListStyle.list
});
}
列表样式选项是none
、auto
、inline
、list
、suggestedAction
和heroCard
。
希望这可以帮助!
推荐阅读
- java - 使用 Java REST API 接收两次相同的参数名称
- google-apps-script - 我的 if 语句似乎没有输出任何东西
- java - 如何在 scollview 中的图像上方添加 textview?
- html - 由于右侧的 Hamburger-Icon,徽标向左移动
- yocto - u-boot bbappend 导致文件系统损坏
- javascript - 点击 ReactJs 动态切换视图
- swift - 两个物体的碰撞
- javascript - 获取对象数组中不存在的 id
- arrays - VHDL中的多维数组部分赋值
- xaml - 为什么我不能将依赖项注入 ContentPage?