我正在将Botframework与Node.js SDK版本4配合使用,并且尝试将HeroCard发送到Facebook Messanger。
如果我发送的卡没有正常工作,但是如果我添加了一些按钮,则会在控制台中收到一个通用错误,该错误不会提供任何信息。
错误如下:“ [onTurnError]:错误:Facebook API错误bot框架”
不起作用:
await turnContext.sendActivity({attachments: [CardFactory.heroCard("Lorem Ipsum 1","https://mysite/myimg.jpg", ["buy","view"]);, CardFactory.heroCard("Lorem Ipsum 2","https://mysite/myimg.jpg", ["action1","action2"]);], attachmentLayout: "carousel", text:"asd"});
工作无误:
await turnContext.sendActivity({attachments: [CardFactory.heroCard("Lorem Ipsum 1","https://mysite/myimg.jpg", []);, CardFactory.heroCard("Lorem Ipsum 2","https://mysite/myimg.jpg", []);], attachmentLayout: "carousel", text:"asd"});
谢谢, 洛伦佐
答案 0 :(得分:1)
您似乎没有为卡片操作提供正确的参数。至少在您发布的代码中,您只是添加一个字符串而不是实际的卡片操作。
尝试这样的事情:
CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images(['https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg']),
CardFactory.actions([
{
type: 'openUrl',
title: 'Get started',
value: 'https://docs.microsoft.com/en-us/azure/bot-service/'
}
])
);