2017-10-10 16 views
3

アダプティブカードを私のルイスレスポンスに追加して使用しようとしていて、ガイドに従っていた:https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-add-rich-card-attachmentsMicrosoftボットフレームワークアダプティブカードが正しくレンダリングされない

ボットエミュレータにボタンが表示されないのはなぜですか?私は何かが欠けていましたか参照画像: enter image description here

私のコード:

[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); 
    } 

答えて

4
が変更

あなたHttpActionからOpenUrlAction(またはSubmitAction、ニーズに応じて)、あなたはあなたのボタンが表示されます:

demo

あなたはドキュメントを見て、アクションの可能性は:

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

C#のオブジェクトにそれらと同等であるOpenUrlActionSubmitActionShowCardAction

関連する問題