我是Bot Bot的新手,我正在使用C#編寫一個簡單的機器人程序,它應該返回一個樣本英雄卡作爲回覆。問題是英雄卡沒有出現在Bot Framework通道模擬器中。下面的代碼:英雄卡在Bot框架的模擬器中沒有顯示
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> arg)
{
var referenceMessage = await arg as IMessageActivity;
var msg = (Activity)context.MakeMessage();
Activity replyToConversation = msg.CreateReply($"Buscando resultados para {referenceMessage.Text}");
replyToConversation.Recipient = msg.From;
replyToConversation.Type = "message";
replyToConversation.ReplyToId = referenceMessage.Id;
replyToConversation.AttachmentLayout = "carousel";
replyToConversation.Attachments = new List<Attachment>();
List<CardImage> CardImages = new List<CardImage>();
CardImages.Add(new CardImage()
{
Url = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/BMW-Z4_diagonal_front_at_IAA_2005.jpg/243px-BMW-Z4_diagonal_front_at_IAA_2005.jpg"
});
CardAction btnWebsite = new CardAction()
{
Type = "openUrl",
Title = "Open",
Value = "http://bmw.com"
};
HeroCard plCard = new HeroCard()
{
Title = $"{referenceMessage.Text}",
Subtitle = $"Resultados de busqueda para {referenceMessage.Text}",
Images = CardImages,
Tap = btnWebsite
};
var attachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(attachment);
await context.PostAsync(replyToConversation);
//var connector = new ConnectorClient(new Uri(msg.ServiceUrl));
//var reply = connector.Conversations.SendToConversationAsync(replyToConversation);
}
正如你所看到的,我一直在試圖與這兩個上下文和連接器,但該卡不顯示up.I've調試的應用程序,我可以看到輸入的信息被正確捕獲
對此有何看法?
有時來自問題圖像的網址。將圖片網址更改爲「https://upload.wikimedia.org/wikipedia/en/archive/a/a9/20151112035044!Banyan_Tree_(_Shiv_Bajrang_Dham_Kishunpur).jpeg」。如果有效,請告訴我們。 – OmG