我正在使用带有枚举的 FormFlow 来呈现一些问题,但似乎 formflow 将它们呈现为带有按钮的 HeroCard,我希望将提示呈现为建议的操作,以便在 FB 中显示为快速回复,最好的方法是什么这样做?现在,我实现了一个自定义提示器,如下所示,但想知道是否有更好的方法来使用属性,所以我不需要编写自定义代码。
private static async Task<FormPrompt> Prompter(IDialogContext context, FormPrompt prompt, JObject state, IField<JObject> field)
{
IMessageActivity promptMessage;
// Handle buttons as quick replies when possible (FB only renders 11 quick replies)
if (prompt.Buttons.Count > 0 && prompt.Buttons.Count <= 11)
{
// Build a standard prompt with suggested actions.
promptMessage = context.MakeMessage();
promptMessage.Text = prompt.Prompt;
var actions = prompt.Buttons.Select(button => new CardAction
{
Type = ActionTypes.ImBack,
Title = button.Description,
Value = button.Description
})
.ToList();
promptMessage.SuggestedActions = new SuggestedActions(actions: actions);
}
else
{
promptMessage = await Extensions.GetDefaultPrompter(context, prompt);
}
await context.PostAsync(promptMessage);
return prompt;
}