如何在带有缩略图卡预览的 Teams Messaging Extension 上使用自适应卡?

How to use Adaptive Cards on Teams Messaging Extension with thumbnail card preview?

我想使用消息扩展将卡片发送到团队频道。在消息传递扩展程序中,我需要显示预览缩略图卡片,然后单击该缩略图将显示自适应卡片。

我已经尝试了下面的代码,但在尝试使用 "MessagingExtensionResult" 时出现了错误。此外,我无法为 "MessagingExtensionResult" 添加 dll,它给出了不兼容的版本错误。我正在使用 .Net Framework 4.6。

 var results = new ComposeExtensionResult()
                {
                    AttachmentLayout = "list",
                    Type = "result",
                    Attachments = new List<ComposeExtensionAttachment>(),
                };

   var card = CardHelper.CreateCardForExperties(pos, true);
   var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment();
results.Attachments.Add(new ComposeExtensionAttachment
                        {
                            ContentType = "application/vnd.microsoft.teams.card.adaptive",
                            Content = JsonConvert.DeserializeObject(updatedJsonString),
                            Preview = composeExtensionAttachment
                        });

使用下面的代码,我们可以从缩略图卡片预览中调用自适应卡片。

ComposeExtensionResponse response = null;

 1.  var results = new ComposeExtensionResult()
            {
                AttachmentLayout = "list",
                Type = "result",
                Attachments = new List<ComposeExtensionAttachment>(),
            };
  1. 创建一个函数 returns 缩略图卡片(预览卡片)

    var previewThumbnailCard = CreateThumbnailCard();

  2. 创建returns附件形式自适应卡片的功能。 var adaptivecardattachment = CreateAdaptiveCardAsAttachment();

  3. 施放该附件卡以组成扩展附件并通过 缩略图卡作为附件。 var composeExtensionAttachmentAdaptive = adaptivecardattachment .ToComposeExtensionAttachment(previewThumbnailCard.ToAttachment());

    1. Return 回应
                {
                    ComposeExtension = results
                };
    return response;