【发布时间】:2018-04-05 22:03:27
【问题描述】:
我使用英雄卡创建了一个轮播。它在 bot 框架模拟器中运行良好,但在 Facebook Messenger 中,它只显示我对下面代码的第一个回复“选择一个选项”?我错过了什么吗,Messenger 支持轮播吗?为什么图片和按钮不见了?
Activity replyToConversation = activity.CreateReply("Select an option");
replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
replyToConversation.Attachments = new List<Attachment>();
Dictionary<string, string> cardContentList = new Dictionary<string, string>();
cardContentList.Add("Shirt", System.Web.HttpContext.Current.Server.MapPath(@"~\imgs\shirt.jpg"));
cardContentList.Add("shoes", System.Web.HttpContext.Current.Server.MapPath(@"~\imgs\shoes.jpg"));
foreach (KeyValuePair<string, string> cardContent in cardContentList)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: cardContent.Value));
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = "nike",
Type = "postBack",
Title = "shirt"
};
cardButtons.Add(plButton);
HeroCard plCard = new HeroCard()
{
Title = "nike",
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
await context.PostAsync(replyToConversation);
【问题讨论】:
-
您可以尝试使用托管在网络上(但不在您的机器人上)的图片吗?
-
是的……这是为什么呢?我不能使用本地文件夹吗?
-
当我使用互联网网址获取图片时,它在我身边工作
-
是的,它可以使用 url,但它不应该也可以使用本地文件夹路径吗?
标签: c# carousel botframework facebook-messenger