编程语言
首页 > 编程语言> > C#-通过Bot框架进行电报聊天键盘

C#-通过Bot框架进行电报聊天键盘

作者:互联网

我尝试使用botframework显示键盘聊天电报,但未显示键盘.我试过像这样发送keybord:

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

和许多其他方式.但是键盘没有出现.

可能是什么原因?如何使其显示?

解决方法:

您不需要使用ChannelData.只需发送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;

标签:telegram-bot,botframework,c
来源: https://codeday.me/bug/20191118/2026073.html