botframework - 瀑布步骤中的建议操作
问题描述
我正在使用 Bot Framework .Net SDK v4 和直线网络聊天客户端。我将对话作为瀑布步骤。是否可以在瀑布步骤中使用建议的操作?我知道选择提示将达到目的,但我希望按钮在用户单击任何选择后消失,因此想要使用建议的操作。
我已经尝试过。
In the constructor :
AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
In waterfall step:
public async Task<DialogTurnResult> FirstStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var promptOptions = new PromptOptions()
{
Prompt = MessageFactory.Text("What card would you like to see? You can click or type the card name"),
RetryPrompt = MessageFactory.Text("That was not a valid choice, please select a card or number from 1 to 9."),
Choices = GetChoices(),
Style = ListStyle.SuggestedAction
};
return await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions);
}
private IList<Choice> GetChoices()
{
var cardOptions = new List<Choice>()
{
new Choice() { Value = "Card 1", Synonyms = new List<string>() { "adaptive" } },
new Choice() { Value = "Card 2", Synonyms = new List<string>() { "animation" } },
};
return cardOptions;
}
解决方案
在提示选项中,您可以指定您的选择样式:
var promptOptions = new PromptOptions {
Prompt = (Activity) MessageFactory.Attachment(card.ToAttachment()),
Style = ListStyle.SuggestedAction
};
return await stepContext.PromptAsync(nameof(ChoicePrompt), promptOptions, cancellationToken);
// Auto: Automatically select the appropriate style for the current channel.
// HeroCard: Add choices to prompt as a HeroCard with buttons.
// Inline : Add choices to prompt as an inline list.
// List : Add choices to prompt as a numbered list.
// None: Don't include any choices for prompt.
// SuggestedAction: Add choices to prompt as suggested actions.
推荐阅读
- r - 用另一个索引一个数据帧
- c# - 在其他控件顶部设置动画控件高度
- c# - 如果记录被其他用户在编辑方法控制器中删除,则为 Null
- python-3.x - Python Selenium 如何检索当前的 xpath
- postgresql - Postgres query execution time much longer as a view
- java - Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean] in xml configuration file
- sql - Daily snapshot table using cte loop
- javascript - How To Change Order Of Objects In Array
- anaconda - Spyder 启动错误:无法生成核心文件
- javascript - 克隆一个反应的合成事件的实例