我尝试使用Microsoft Bot Framework创建Telegram bot客户端,当我使用此框架创建signincard时,signincard成功创建并且我可以看到Microsoft Bot Emulator中的按钮但是当我发布到服务器并使用Telegram测试时,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);
抱歉英语不好。
答案 0 :(得分:1)
我认为登录卡类型必须为&#34; 登录&#34;,而值应为 url 字符串
工作代码:
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";
屏幕截图: