Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram chat keyboard through bot framework

I try to show the keyboard chatting telegram using botframework, but the keyboard is not displayed. I tried send keybord like this:

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

And many other ways. But keyboard does not show up.

What could be the reason? How to make it show up?

like image 425
Alex Skiffin Avatar asked Jun 07 '26 21:06

Alex Skiffin


1 Answers

You don't need to use ChannelData. Just send the buttons on a 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;
like image 197
Lars Avatar answered Jun 09 '26 09:06

Lars



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!