簡體   English   中英

Microsoft Bot Framework自適應卡無法正確呈現

[英]Microsoft Bot Framework Adaptive Cards not rendering properly

我正在嘗試使用自適應卡,將其添加到我的路易斯響應中,並遵循指南: https//docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-add-富卡附件

為什么我的按鈕沒有顯示在我的機器人模擬器上? 我錯過了什么嗎? 看圖: 在此輸入圖像描述

我的代碼:

 [LuisIntent("Test")]
    public async Task Test(IDialogContext context, LuisResult result)
    {

        Activity replyToConversation = (Activity)context.MakeMessage();
        //Activity replyToConversation = message.CreateReply("Should go to conversation");
        replyToConversation.Attachments = new List<Attachment>();
        AdaptiveCard card = new AdaptiveCard();

       // Add text to the card.
        card.Body.Add(new TextBlock()
        {
            Text = "Adaptive Card design session",
            Size = TextSize.Large,
            Weight = TextWeight.Bolder
        });

        // Add text to the card.
        card.Body.Add(new TextBlock()
        {
            Text = "Conf Room 112/3377 (10)"
        });

        // Add text to the card.
        card.Body.Add(new TextBlock()
        {
            Text = "12:30 PM - 1:30 PM"
        });

        // Add list of choices to the card.
        card.Body.Add(new ChoiceSet()
        {
            Id = "snooze",
            Style = ChoiceInputStyle.Compact,
            Choices = new List<Choice>()
            {
                new Choice() { Title = "5 minutes", Value = "5", IsSelected = true },
                new Choice() { Title = "15 minutes", Value = "15" },
                new Choice() { Title = "30 minutes", Value = "30" }
            }
        });

        // Add buttons to the card.
        card.Actions.Add(new HttpAction()
        {
            Url = "http://foo.com",
            Title = "Snooze"
        });

        card.Actions.Add(new HttpAction()
        {
            Url = "http://foo.com",
            Title = "I'll be late"
        });

        card.Actions.Add(new HttpAction()
        {
            Url = "http://foo.com",
            Title = "Dismiss"
        });

        // Create the attachment.
        Attachment attachment = new Attachment()
        {
            ContentType = AdaptiveCard.ContentType,
            Content = card
        };

        replyToConversation.Attachments.Add(attachment);

        // var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
        await context.PostAsync(replyToConversation);
        context.Done(true);
    }

將您的HttpAction更改為OpenUrlAction (或SubmitAction ,具體取決於您的需要),您將獲得按鈕:

演示

查看文檔時,Actions的可能性如下:

  • Action.OpenUrl
  • Action.Submit
  • Action.ShowCard

它們在C#對象中的等價物是OpenUrlActionSubmitActionShowCardAction

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM