【发布时间】:2016-09-05 08:58:02
【问题描述】:
我正在尝试将 Microsoft Bot 连接器操作呈现为 Facebook Messenger 中的按钮,但它没有按预期呈现。事实上,信使并没有显示任何东西。在 BotFramework Emulator 上进行测试时,仅显示 .Text 属性,但不显示按钮。
class myFactory
{
public static IForm<myButton> BuildForm()
{
return new FormBuilder<myButton>()
.Message("Welcome to my test Button!")
.OnCompletionAsync(async (context, myButton) =>
{
var reply = context.MakeMessage();
reply.Text = "Test actions";
reply.Attachments = new List<Attachment>();
var actions = new List<Microsoft.Bot.Connector.Action>();
actions.Add(new Microsoft.Bot.Connector.Action() { Title = "button1", Message = "message1", Url = "http://google.com" });
actions.Add(new Microsoft.Bot.Connector.Action() { Title = "button2", Message = "message2", Url = "http://google.com" });
actions.Add(new Microsoft.Bot.Connector.Action() { Title = "button3", Message = "message3", Url = "http://google.com" });
Attachment at = new Attachment();
at.Title = "Choose One:";
at.Actions = actions;
at.ContentType = "template";
at.Text = "Text choose";
at.TitleLink = "http://www.google.com";
at.ContentUrl = "http://msdn.microsoft.com";
reply.Attachments.Add(at);
await context.PostAsync(reply);
})
.Build();
}
};
【问题讨论】:
-
经过严格测试。我发现 Buttons 仅适用于 Web Facebook 消息,而不适用于移动 facebook messenger 应用程序。 Telegram 也不显示我想要的按钮。我现在正在考虑的解决方案是检查我的机器人正在运行的频道以呈现适当的回复。
-
按钮应该在所有 Facebook Messenger 客户端、kik 和电报中通用。是不是你有一个不支持按钮和轮播的旧版本的 fb messenger 应用程序?我使用
Actions在我的机器人中生成按钮,并依靠连接器将它们降级为不支持按钮的频道的文本选项。 -
@ShahinShayandeh 是的。你说得对,我忘了说我在 Windows 手机上运行它,但它使用 UWP 桌面版 Messenger 和 android Messenger 版可以正常工作。请添加您的评论作为答案,以便我可以将其标记为正确答案。谢谢。
标签: c# bots telegram-bot facebook-messenger botframework