2016-07-16 101 views
1

我試圖用Microsoft Bot框架創建Telegram bot客戶端,當我用這個框架創建signincard時,signincard創建成功,我可以在Microsoft Bot Emulator中看到按鈕,但是當我發佈到服務器和用電報測試它,signincard沒有顯示在機器人,請告訴我如何解決它。Microsoft Bot框架:SigninCard沒有在電報中顯示

代碼:

  Activity reply = null; 
      ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl), "", ""); 

      if (activity.Type == ActivityTypes.Message) 
      {      
       if (activity.Text == "/start") 
       { 
        reply = activity.CreateReply($"Welcome, please select an option"); 
        reply.Recipient = activity.From; 
        reply.Type = ActivityTypes.Message; 
        reply.Attachments = new List<Attachment>(); 

        List<CardAction> cardButtons = new List<CardAction>(); 
        var helpAction = new CardAction() 
        { 
         Image = "", 
         Title = "Get Menu", 
         Type = "imBack", 
         Value = "help" 
        }; 

        var contactAction = new CardAction() 
        { 
         Image = "", 
         Title = "Contact Us", 
         Type = "imBack", 
         Value = "contact" 
        }; 
        cardButtons.Add(helpAction); 
        cardButtons.Add(contactAction); 

        var sc = new SigninCard() 
        { 
         Buttons = cardButtons, 
         Text = "" 
        }; 

        Attachment attach = sc.ToAttachment(); 
        reply.Attachments.Add(attach); 
       } 
       else 
       { 

       } 
      } 
      await connector.Conversations.ReplyToActivityAsync(reply); 

抱歉不好英語。

回答

1

我覺得登入卡的類型必須是 「登入」,和值應爲網址,而不是字符串

工作代碼:

replyActivity.Attachments = new List<Attachment>(); 

var cardButtons = new List<CardAction>(); 
var plButton = new CardAction 
{ 
    Value = auth.SessionUrl, 
    Type = "signin", 
    Title = "Connect" 
}; 
cardButtons.Add(plButton); 
var plCard = new SigninCard("You need to authorize to use Quick Book feature", cardButtons); 

var plAttachment = plCard.ToAttachment(); 
replyActivity.Attachments.Add(plAttachment); 
replyActivity.Text = "Should go to conversation, sign-in card"; 

截圖:

enter image description here

+0

謝謝y ou kienct89 – Varooneh

+0

@Varooneh不客氣 –