2016-09-18 34 views
3

我嘗試使用botframework顯示鍵盤聊天電報,但鍵盤未顯示。我試過像這樣發送keybord:通過bot框架的電報聊天鍵盤

 Activity reply = activity.CreateReply(message); 
     var keyboard =new ReplyKeyboardMarkup 
     { 
      Keyboard = new[] { new[] { new KeyboardButton("Text1"), new KeyboardButton("text1") } } 
     }; 
     reply.ChannelData = keyboard; 
     await connector.Conversations.ReplyToActivityAsync(reply); 

還有很多其他的方法。但鍵盤不顯示。

可能是什麼原因?如何讓它顯示出來?

回答

3

您不需要使用ChannelData。只需發送HeroCard上的按鈕:

 var card = new HeroCard("Some Text"); 
     card.Buttons = new List<CardAction>() 
     { 
       new CardAction() 
       { 
        Title = "button1", 
        Type=ActionTypes.ImBack, 
        Value="button1" 
       }, 
       new CardAction() 
       { 
        Title = "button2", 
        Type=ActionTypes.ImBack, 
        Value="button2" 
       } 
     }; 

     var reply = activity.CreateReply(""); 
     reply.Attachments = new List<Attachment>(); 
     reply.Attachments.Add(new Attachment() 
     { 
      ContentType = HeroCard.ContentType, 
      Content = card 
     }); 
     return reply;