Varooneh Varooneh - 3 months ago 26
C# Question

Microsoft Bot Framework : SigninCard not showing in telegram

I tried create Telegram bot client with Microsoft Bot Framework, when I create signincard with this framework, signincard created successfully and I can see buttons in Microsoft Bot Emulator but when I publish to server and test it with Telegram, signincard not showing in bot, please tell me how to fix it.

code :

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


sorry for bad english.

Answer

I think sign-in card type must be "signin", and the value should be url instead of string

working code:

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";

screenshot:

enter image description here