通过bot框架发送电报聊天键盘

时间:2016-09-18 11:59:39

标签: c# telegram-bot botframework

我尝试使用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);

还有很多其他方法。但是键盘没有显示出来。

可能是什么原因?如何让它出现?

1 个答案:

答案 0 :(得分:3)

您不需要使用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;
相关问题