2017-09-12 7 views
3

ヒーローカードに6個のボタンを追加して表示しようとしました。チームやエミュレータでは正常に動作しますが、Skypeでは動作しません。それは3つのボタンを表示するだけです。Skypeに3つ以上のボタンが表示されていないMicrosoft bot framework

private List<CardAction> GetCardButton(List<string> opts) 
    { 
     List<CardAction> cardButtons = new List<CardAction>(); 
     int i = 1; 
     foreach(string opt in opts) 
     { 
      CardAction plButton = new CardAction() 
      { 
       Title = opt, 
       Type = "postBack", 
       Text = i.ToString(), 
       Value = i.ToString() 
      }; 
      cardButtons.Add(plButton); 
      i++; 
     } 

     return cardButtons; 

    } 
//passing list of strings. 
List<CardAction> cardButtons = GetCardButton(cardOpts); 

     HeroCard plCard = new HeroCard() 
     { 
      Title = "Try here", 
      Text = "with:", 
      Buttons = cardButtons 

     }; 
     plAttachment = plCard.ToAttachment(); 

しかし、skypeでは最初の3つのボタンしか表示されません。カードをスクロール可能にする方法や、ボタンのサイズを小さくする方法はありますか?

答えて

1

、ボタンの数、テキストの長さ、あなたはこの制限に遭遇しているようです。 1つのことは、3つ以上のボタンが別のカードを表示し、それらをリストまたはカルーセルに提示する場合です。ここ

は一緒にハッキングのコード例である:私は私のテキストはカードに切り取ら参照also..because

using Microsoft.Bot.Builder.Dialogs; 
using Microsoft.Bot.Connector; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Threading.Tasks; 

namespace Bot_Application13.Dialogs 
{ 
    [Serializable] 
    public class RootDialog : IDialog<object> 
    { 

     public Task StartAsync(IDialogContext context) 
     { 
      context.Wait(MessageReceivedAsync); 

      return Task.CompletedTask; 
     } 

     private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result) 
     { 
      List<Attachment> cards = new List<Attachment>(); 
      List<CardAction> buttons = new List<CardAction>(); 
      for (int i = 0; i < 10; i++) 
      { 
       CardAction ca = new CardAction() 
       { 
        Title = i.ToString(), 
        Type = "postBack", 
        Text = i.ToString(), 
        Value = i.ToString() 
       }; 
       buttons.Add(ca); 
      } 

      var reply = context.MakeMessage(); 
      GetCardsAttachments(buttons, cards); 
      //reply.AttachmentLayout = AttachmentLayoutTypes.List; 
      //or 
      reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; 
      reply.Attachments = cards; 

      await context.PostAsync(reply); 

      context.Wait(this.MessageReceivedAsync); 
     } 

     private Attachment GetHeroCard(List<CardAction> buttons) 
     { 
      var heroCard = new HeroCard(); 
      //heroCard.Title = "Title"; 
      heroCard.Buttons = buttons; 
      return heroCard.ToAttachment(); 
     } 

     private void GetCardsAttachments(List<CardAction> buttons, List<Attachment> cards) 
     { 
      if (buttons.Count <= 3) 
      { 
       cards.Add(GetHeroCard(buttons)); 
      } 
      else 
      { 
       var temp = new List<CardAction>(); 
       for (int i = 0; i < buttons.Count; i++) 
       { 
        if (i % 3 != 0) 
        { 
         temp.Add(buttons.ElementAt(i)); 
        } 
        else 
        { 
         if (i != 0) 
         { 
          cards.Add(GetHeroCard(temp)); 
         } 

         temp = new List<CardAction>(); 
         temp.Add(buttons.ElementAt(i)); 
        } 

       } 
       cards.Add(GetHeroCard(temp)); 
      } 
     } 
    } 
} 
4

Skypeでカードに表示できるボタンの数に制限があります。この制限は、他のテキスト要素とメディア要素がいくつ含まれているかによって異なります。ドキュメントごと

https://dev.skype.com/bots/からのセクション#6を参照)、各チャネルが正確に表示することができるものに制限があり、以前の回答に示すよう

enter image description here

+0

は、文字数のいずれかの制限がテキストであり:(? – Harshini

関連する問題