通过机器人框架的电报聊天键盘
Telegram chat keyboard through bot framework
我尝试使用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;
我尝试使用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;