我正在使用Bot Framework .Net SDK v4和直接Web聊天客户端。我将对话框作为瀑布步骤。是否可以在瀑布步骤中使用建议的操作?我知道选择提示会达到目的,但是我希望按钮在用户单击任何选择后消失,因此希望使用建议的操作。
我尝试过的。
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;
}
答案 0 :(得分:0)
在提示选项中,您可以指定选择样式:
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.