我们尝试使用Microsoft Azure Web应用程序bot服务制作聊天机器人应用程序。
const bot = module.exports = new builder.UniversalBot(connector, [
bot.beginDialog
// this section becomes the root dialog
// If a conversation hasn't been started, and the message
// sent by the user doesn't match a pattern, the
// conversation will start here
(session, args, next) => {
session.send(`Hi there! I'm a sample bot showing how multiple dialogs work.`);
session.send(`Let's start the first dialog, which will ask you your name.`);
// Launch the getName dialog using beginDialog
// When beginDialog completes, control will be passed
// to the next function in the waterfall
session.beginDialog('getName');
},
首先, 我们使用bot.on函数自动启动应用程序。
但是,如果使用此代码,则无法返回到先前的代码。 因为我们使用nodejs(脚本语言)。它是无状态的。
因此,第二,我们找到了另一种制作应用程序的方式(代码)。 但是,如果使用此代码,我们将无法自动启动chatbot应用程序。 我们必须输入任何内容才能开始聊天。
const bot = module.exports = new builder.UniversalBot(connector, [
bot.beginDialog
// this section becomes the root dialog
// If a conversation hasn't been started, and the message
// sent by the user doesn't match a pattern, the
// conversation will start here
(session, args, next) => {
session.send(`Hi there! I'm a sample bot showing how multiple dialogs work.`);
session.send(`Let's start the first dialog, which will ask you your name.`);
// Launch the getName dialog using beginDialog
// When beginDialog completes, control will be passed
// to the next function in the waterfall
session.beginDialog('getName');
}
请让我们知道如何以这种方法启动应用程序。