C# Microsoft BOT框架是否允许开发交互式UI?
我需要使用Microsoft Bot Framework for Cortana Channel实现一些交互式UI,但我还没有找到任何实现方法。我想在按钮上应用样式,重要的是在Cortana上使用图形和图表(如web dashboard) 我想在按钮上应用样式,重要的是在Cortana上使用图形和图表(如web dashboard) bot是一种在服务器端工作的web应用程序服务,C# Microsoft BOT框架是否允许开发交互式UI?,c#,botframework,cortana,C#,Botframework,Cortana,我需要使用Microsoft Bot Framework for Cortana Channel实现一些交互式UI,但我还没有找到任何实现方法。我想在按钮上应用样式,重要的是在Cortana上使用图形和图表(如web dashboard) 我想在按钮上应用样式,重要的是在Cortana上使用图形和图表(如web dashboard) bot是一种在服务器端工作的web应用程序服务,BotFramework提供连接bot和本机应用程序(如Skype和here Cortana)的通道。UI部分在每个
BotFramework
提供连接bot和本机应用程序(如Skype和here Cortana)的通道。UI部分在每个本机应用程序中呈现,我找不到自定义Cortana应用程序样式的方法。但是,提供了几个简单的样式属性,有关详细信息,您可以参考官方示例:
对于交互式图形和图表的问题,AFAIK,它目前不受支持。现在我们可以做的是将图表渲染为图像,并在
HeroCard
或AdaptiveCard
中显示此图像,但这种解决方法会使图表失去其交互性。您可以参考线程中我的最后一个答案事实上,您可以使用英雄卡、自适应卡、缩略图卡、收据卡等
以下是供您参考的示例。
公共任务StartSync(IDialogContext上下文)
{
Wait(MessageReceivedAsync)
returntask.CompletedTask;
}
公共虚拟异步任务消息ReceivedAsync(IDialogContext上下文,IAwaitable结果)
{
var reply=context.MakeMessage();
reply.AttachmentLayout=attachmentlayoututypes.Carousel;
答复.附件=GetCardsAttachments();
等待上下文。PostAsync(回复);
context.Wait(this.MessageReceivedAsync);
}
私有静态IList您可以根据以下内容自定义网络聊天本身。就图表和图表而言,自适应卡是您的最佳选择,但如上所述,它目前不受支持 感谢@Grace Feng的可能副本,我们可能会使用HeroCard在Cortana上显示图像,因为Cortana不支持AdaptiveCard。通过以下链接进行检查:谢谢@Manoj当前Cortana频道不允许使用自适应卡。是的,我可以使用不足以满足我要求的英雄卡,因为我想显示交互式图形和UI。
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();
}