Azure bot Nodejs 函数调用

Azure bot Nodejs Function calls

我正在尝试在必须转到特定功能的机器人中调用一个对话框,这是场景... 我有一个对话机器人,如下所示

bot.dialog('/Welcome', [
function(session){
builder.Prompts.text(session, "Welcome to the Bot");
},
function (session, args) {
// Has some code 
},
function (session, args){
//has some code
}......

我什么时候更换对话框,即。

bot.replaceDialog('/Welcome') 

它不应该转到第一个功能,即。 欢迎使用 Bot 它应该跳过这个并转到下一个功能。

有什么方法可以在 azure bot 中完成这个吗?

如果你看看他们的文章,这很简单

https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-dialog-replace

他们的例子如下

// This dialog prompts the user for a phone number. 
// It will re-prompt the user if the input does not match a pattern for phone number.
bot.dialog('phonePrompt', [
    function (session, args) {
        if (args && args.reprompt) {
            builder.Prompts.text(session, "Enter the number using a format of either: '(555) 123-4567' or '555-123-4567' or '5551234567'")
        } else {
            builder.Prompts.text(session, "What's your phone number?");
        }
    },
    function (session, results) {
        var matched = results.response.match(/\d+/g);
        var number = matched ? matched.join('') : '';
        if (number.length == 10 || number.length == 11) {
            session.userData.phoneNumber = number; // Save the number.
            session.endDialogWithResult({ response: number });
        } else {
            // Repeat the dialog
            session.replaceDialog('phonePrompt', { reprompt: true });
        }
    }
]);

所以你的会像下面这样

bot.dialog('/Welcome', [
function(session, args, next){
if (!args || args.prompt)
    builder.Prompts.text(session, "Welcome to the Bot");
else
    next();
},
function (session, args) {
// Has some code 
},
function (session, args){
//has some code
}......

你会像下面这样称呼它

bot.replaceDialog('/Welcome', {prompt: false}))