gpt4 book ai didi

javascript - Microsoft QnA Maker - 欢迎消息循环

转载 作者:太空宇宙 更新时间:2023-11-04 00:21:01 25 4
gpt4 key购买 nike

我正在尝试实现与该主题类似的目标 Begin Dialog with QnA Maker Bot Framework recognizer (Node JS)

该建议的工作方式是让机器人首先发送欢迎消息,然后等待问题。然而机器人现在说“Hj!”我能为您提供什么帮助?”,等待问题,然后再次回到欢迎。

类似

答:嗨!我怎么帮你?问: 修车电话号码是多少答:调用 500-XXXX 等。问:假期期间我应该联系谁?答:嗨!我能为您提供什么帮助?

我玩了beginDialog,结束对话,替换对话..但是没有运气。

这是最新的代码。

bot.dialog('/', [
function (session ) {
session.beginDialog('/welcome');
},
function (session) {
session.beginDialog('/qna');
}
]) ;



bot.dialog('/welcome', [
function (session) {
// Send a greeting and show help.
builder.Prompts.text(session, "Hi! How can I help you?");
// session.endDialog();
}
]);


bot.dialog('/qna', basicQnAMakerDialog ) ;

最佳答案

以下代码示例展示了如何监听新用户连接到机器人时触发的 conversationUpdate 事件。又名“欢迎消息”:

// Listen for 'conversationUpdate' event to detect members joining conversation.
bot.on('conversationUpdate', function (message) {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id == message.address.bot.id) {
// Bot is joining conversation
// - For WebChat channel you'll get this on page load.
var reply = new builder.Message()
.address(message.address)
.text("Welcome to my page");
bot.send(reply);
} else {
// User is joining conversation
// - For WebChat channel this will be sent when user sends first message.
// - When a user joins a conversation the address.user field is often for
// essentially a system account so to ensure we're targeting the right
// user we can tweek the address object to reference the joining user.
// - If we wanted to send a private message to teh joining user we could
// delete the address.conversation field from the cloned address.
var address = Object.create(message.address);
address.user = identity;
var reply = new builder.Message()
.address(address)
.text("Hello %s", identity.name);
bot.send(reply);
}
});
}
});

关于javascript - Microsoft QnA Maker - 欢迎消息循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44572065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com