如何在多行中询问用户的选择?
How to ask choices from user in multi line?
我要求用户从多个选项中select,如下
var reportData = {
"Report A Traffic Violation": {
intent: 'report_a_traffic_violation'
},
"Report a Lost Property": {
intent: 'report_a_traffic_violation'
},
"Describe Incident": {
intent: '/describeIncident'
}
};
builder.Prompts.choice(session, "please select from options", reportData);
但是选项以单行显示给用户。如何使用如下多行向用户显示选项?
- 选项一
- 选项二
- 选项三
对于js:虽然'\n'是通用的换行符。
对于 C# SDK:Environment.NewLine.
Node.js
根据您提供的代码,我想您正在使用 node.js
您可以查看 Microsoft 提供的 Contoso-Flowers 示例,在其 settings
函数中:code here and preview with the list visible here.
这是他们处理列表的方式:
var SettingChoice = {
Email: 'edit_email',
Phone: 'edit_phone',
Addresses: 'edit_addresses',
Cancel: 'cancel'
};
var lib = new builder.Library('settings');
lib.dialog('/', [
// Display options
function (session) {
builder.Prompts.choice(session, 'settings_intro', [
session.gettext(SettingChoice.Email),
session.gettext(SettingChoice.Phone),
session.gettext(SettingChoice.Addresses),
session.gettext(SettingChoice.Cancel)
]);
},
你试过像这里一样使用数组吗?
C#
对于使用 C# 构建机器人的用户,您只需将 PromptStyle
指定为 PromptStyle.PerLine
尝试添加 listStyle 参数:
builder.Prompts.choice(
session,
"please select from options",
reportData,
{listStyle: builder.ListStyle.list}
);
Bot Framework 文档中有关列表样式的更多信息:https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-prompt
我要求用户从多个选项中select,如下
var reportData = {
"Report A Traffic Violation": {
intent: 'report_a_traffic_violation'
},
"Report a Lost Property": {
intent: 'report_a_traffic_violation'
},
"Describe Incident": {
intent: '/describeIncident'
}
};
builder.Prompts.choice(session, "please select from options", reportData);
但是选项以单行显示给用户。如何使用如下多行向用户显示选项?
- 选项一
- 选项二
- 选项三
对于js:虽然'\n'是通用的换行符。 对于 C# SDK:Environment.NewLine.
Node.js
根据您提供的代码,我想您正在使用 node.js
您可以查看 Microsoft 提供的 Contoso-Flowers 示例,在其 settings
函数中:code here and preview with the list visible here.
这是他们处理列表的方式:
var SettingChoice = {
Email: 'edit_email',
Phone: 'edit_phone',
Addresses: 'edit_addresses',
Cancel: 'cancel'
};
var lib = new builder.Library('settings');
lib.dialog('/', [
// Display options
function (session) {
builder.Prompts.choice(session, 'settings_intro', [
session.gettext(SettingChoice.Email),
session.gettext(SettingChoice.Phone),
session.gettext(SettingChoice.Addresses),
session.gettext(SettingChoice.Cancel)
]);
},
你试过像这里一样使用数组吗?
C#
对于使用 C# 构建机器人的用户,您只需将 PromptStyle
指定为 PromptStyle.PerLine
尝试添加 listStyle 参数:
builder.Prompts.choice(
session,
"please select from options",
reportData,
{listStyle: builder.ListStyle.list}
);
Bot Framework 文档中有关列表样式的更多信息:https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-prompt