/ / Azure Bot Nodejs Funktionsaufrufe - node.js, azure, bots, Chatbot, azure-bot-service

Azure Bot Nodejs Funktionsaufrufe - node.js, azure, bots, Chatbot, azure-bot-service

Ich versuche einen Dialog im Bot aufzurufen, der zu bestimmten Funktionen gehen muss, Hier ist das Szenario ... Ich habe einen Dialog-Bot, wie unten gezeigt

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
}......

Wann immer ich Dialog deletiere, dh.

bot.replaceDialog("/Welcome")

es sollte nicht auf die erste Funktion gehen, dh. Willkommen im Bot Es sollte dies überspringen und zur nächsten Funktion gehen.

Gibt es eine Möglichkeit, dies in azurblauen Bot zu erreichen?

Antworten:

0 für die Antwort № 1

Das ist ganz einfach, wenn Sie sich ihren Artikel ansehen

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

Ihr Beispiel ist wie folgt

// 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 });
}
}
]);

Also wäre deins so etwas wie unten

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
}......

und du wirst es wie unten nennen

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