Varooneh Varooneh - 1 year ago 283
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"

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

Attachment attach = sc.ToAttachment();

await connector.Conversations.ReplyToActivityAsync(reply);

sorry for bad english.

Answer Source

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"
var plCard = new SigninCard("You need to authorize to use Quick Book feature", cardButtons);

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


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download