电报聊天键盘通过bot框架
本文关键字:bot 框架 键盘 聊天 | 更新日期: 2023-09-27 18:07:22
我尝试用botframework显示键盘聊天电报,但是键盘不显示。我试着像这样发送键盘:
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;