首页 > 解决方案 > 瀑布步骤中的建议操作

问题描述

输出

我正在使用 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;
        }

标签: botframework

解决方案


在提示选项中,您可以指定您的选择样式:

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.

来源


推荐阅读