채팅 봇을 초기화 할 때 메시지를 표시하고 대화 상자를 호출하고 싶습니다. 아래 코드는 메시지를 보여줍니다. 그러나 대화를 부를 수는 없습니다.Node.js의 conversationUpdate 이벤트에서 대화 상자 시작하기 BotBuilder
bot.on('conversationUpdate', function (activity) {
// when user joins conversation, send welcome message
if (activity.membersAdded) {
activity.membersAdded.forEach(function (identity) {
if (identity.id === activity.address.bot.id) {
var reply = new builder.Message()
.address(activity.address)
.text("Hi, Welcome ");
bot.send(reply);
// bot.beginDialog("initialize", '/');
// session.beginDialog("initialize");
}
});
}});bot.dialog('/', intents);
다음은 대화 코드입니다. chatbot이 시작될 때 아래 대화 상자를 호출해야합니다.
bot.dialog('initialize', [
function (session, args, next) {
builder.Prompts.choice(session, "Do you have account?", "Yes|No", { listStyle: builder.ListStyle.button });
}, function (session, args, next) {
if (args.response.entity.toLowerCase() === 'yes') {
//session.beginDialog("lousyspeed");
session.send("No pressed");
} else if (args.response.entity.toLowerCase() === 'no') {
session.send("Yes pressed");
session.endConversation();
}
}]).endConversationAction("stop",
"",
{
matches: /^cancel$|^goodbye$|^exit|^stop|^close/i
// confirmPrompt: "This will cancel your order. Are you sure?"
});
시도한 방법은 다음과 같습니다. 그러나 그들은 같은 방법 이름을 가지고 있지만, 메소드 서명은 session.beginDialog()
및 <UniversalBot>bot.beginDialog()
사이에 차이가, 당신은 때문에이 오류가 타격
1. bot.beginDialog("initialize", '/');
2. session.beginDialog("initialize");
를 사용하여 내 문제를 해결 활동 "여기? 귀하의 코드를 사용하면 활동이 정의되지 않는다고 말합니다 ... – Johan