我想将 api 响应显示为卡片,但响应重复 - 我做错了什么,这是英雄卡片的有效使用吗?
bot.dialog('/receipt', [
function(session){
bot.on('trigger', function (message) {
var queuedMessage = message.value;
var msg = new builder.Message()
.address(queuedMessage.address)
.attachments([
new builder.HeroCard(session)
.title("Good news - I can book this for you:")
.subtitle("Customer: " + queuedMessage.name)
.images([
builder.CardImage.create(session, "")
])
.buttons([
builder.CardAction.dialogAction(session, "bookIt", "", "Book it?"),
builder.CardAction.dialogAction(session, "help", "", "Start again?")
])
]);
session.send(msg);
})
},
]);
最佳答案
正如 OmG 在评论中建议的那样:删除 bot.on('trigger'
您似乎正在尝试设置 Azure Function
来触发机器人发送消息:https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview为了主动从机器人向用户发送消息,这不一定是必需的。
请参阅https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-proactive-messages有关主动发送消息的文档。以下是 node
中的一些示例:https://github.com/MicrosoftDX/botFramework-proactiveMessages/tree/master/node
关于node.js - 主动机器人中重复的英雄卡响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43946750/