答案 0 :(得分:2)
您可以使用建议的操作,单击时会消失。以下是根据Bot Framework documentation进行修改的示例,了解如何执行此操作:
var reply = activity.CreateReply("Hi, do you want to hear a joke?");
reply.Type = ActivityTypes.Message;
reply.TextFormat = TextFormatTypes.Plain;
reply.SuggestedActions = new SuggestedActions()
{
Actions = new List<CardAction>()
{
new CardAction(){ Title = "Yes", Type=ActionTypes.ImBack, Value="Yes" },
new CardAction(){ Title = "No", Type=ActionTypes.ImBack, Value="No" },
new CardAction(){ Title = "I don't know", Type=ActionTypes.ImBack, Value="IDontKnow" }
}
};
答案 1 :(得分:0)
您可以使用HeroCard来实现此类功能。 HeroCard可以在bot框架上全局使用,对话框的外观取决于平台的设计。
对于您的情况,您可以使用以下内容:
private async void HiMessage(IDialogContext ctx)
{
List<CardAction> list = new List<CardAction>();
list.Add(new CardAction { Title = "Yes", Type = ActionTypes.ImBack, Value = "yes" });
list.Add(new CardAction { Title = "No", Type = ActionTypes.ImBack, Value = "no" });
list.Add(new CardAction { Title = "I don't know", Type = ActionTypes.ImBack, Value = "dontknow" });
HeroCard hero = new HeroCard();
hero.Title = "Hi";
hero.Text = "Do you want to hear a joke?";
hero.Buttons = list;
var msg = ctx.MakeMessage();
msg.Attachments.Add(hero.ToAttachment());
await ctx.PostAsync(msg);
}
您可以进一步探索this
中的丰富卡片