我需要使用Microsoft Bot Framework for Cortana Channel实现一些交互式UI,但我还没有找到任何方法来实现它。我想在按钮上应用样式,重要的是使用图形& Cortana上的图表(如网页仪表板)。
答案 0 :(得分:1)
我想在按钮上应用样式,重要的是使用图形& Cortana上的图表(如网页仪表板)。
bot是一种在服务器端工作的Web应用程序服务,BotFramework
提供了一些通道,这些通道是机器人和本机应用程序(如Skype和Cortana)之间的连接。 UI部分在每个本机应用程序中呈现,我找不到自定义Cortana应用程序样式的方法。但是,AdaptiveCards提供了几个简单的样式属性,有关更多信息,请参阅官方示例:cards-AdaptiveCards。
关于互动图表的问题&图表,AFAIK,目前不支持。我们现在可以做的是将图表渲染为图像并在HeroCard
或AdaptiveCard
中显示此图像,但此解决方法将使图表失去其交互性。你可以在帖子How to create Charts using c# Bot Framework?
答案 1 :(得分:0)
确实,您可以使用Hero card, adaptive cards, thumbnail cards, receipt cards etc
。
以下是供您参考的示例。
public Task StartAsync(IDialogContext context) { context.Wait(MessageReceivedAsync);
return Task.CompletedTask;
}
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var reply = context.MakeMessage();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
reply.Attachments = GetCardsAttachments();
await context.PostAsync(reply);
context.Wait(this.MessageReceivedAsync);
}
private static IList<Attachment> GetCardsAttachments()
{
return new List<Attachment>()
{
GetHeroCard(
"Add a webpage",
"",
"",
new CardImage(url: "https://cdn.dribbble.com/users/22691/screenshots/1958250/attachments/340010/Button_800x600.gif?sz=328"),
new CardAction(ActionTypes.ImBack, "Add a webpage", value: "Add a webpage")),
GetHeroCard(
"delete a webpage",
"",
"",
new CardImage(url: "https://cdn.dribbble.com/users/22691/screenshots/1958250/attachments/340010/Button_800x600.gif?sz=328"),
new CardAction(ActionTypes.ImBack, "delete a webpage", value: "delete a webpage")),
GetHeroCard(
"Display help",
"",
"",
new CardImage(url: "https://cdn.dribbble.com/users/22691/screenshots/1958250/attachments/340010/Button_800x600.gif?sz=328"),
new CardAction(ActionTypes.ImBack, "Display help", value: "Display help")),
GetHeroCard(
"etc",
"",
"",
new CardImage(url: "https://cdn.dribbble.com/users/22691/screenshots/1958250/attachments/340010/Button_800x600.gif?sz=328"),
new CardAction(ActionTypes.ImBack, "etc", value: "etc")),
};
}
private static Attachment GetHeroCard(string title, string subtitle, string text, CardImage cardImage, CardAction cardAction)
{
var heroCard = new HeroCard
{
Title = title,
Subtitle = subtitle,
Text = text,
Images = new List<CardImage>() { cardImage },
Buttons = new List<CardAction>() { cardAction },
};
return heroCard.ToAttachment();
}
答案 2 :(得分:0)
您可以在this guideline之后自定义网络聊天。就图表和图表而言,自适应卡是您最好的选择,但如上所述,它目前不受支持。