Comparing version 1.2.0 to 1.2.1
@@ -141,4 +141,67 @@ /* | ||
} | ||
/** | ||
* Route to a default route of the bot. First the route is calculated as the | ||
* best route based on the results and the dialog stack. If no best route exists | ||
* then is routed to the active dialog. | ||
* @param {Object} bot Microsoft Bot Framework Universal Bot instance. | ||
* @param {Object} session Microsoft bot framework session. | ||
* @param {Object} results Results for the routing. | ||
*/ | ||
defaultRouting(bot, session, results) { | ||
const route = bot.libraries.BotBuilder.constructor | ||
.bestRouteResult(results, session.dialogStack(), bot.name); | ||
if (route) { | ||
return bot.library(route.libraryName).selectRoute(session, route); | ||
} | ||
return session.routeToActiveDialog(); | ||
} | ||
/** | ||
* Sets the recognizer to a Microsoft bot framework universal bot instance. | ||
* Also, the default bot routing can be overrided and replaced by the | ||
* recognizer routing. | ||
* @param {Object} bot Microsoft Bot Framework Universal Bot instance. | ||
* @param {boolean} activateRouting True if default routing should be overrided. | ||
* @param {number} routingThreshold Threshold for the score of the intent. | ||
*/ | ||
setBot(bot, activateRouting = false, routingThreshold = 0.7) { | ||
bot.recognizer(this); | ||
if (!activateRouting) { | ||
return; | ||
} | ||
const self = this; | ||
// eslint-disable-next-line no-underscore-dangle, no-param-reassign | ||
bot._onDisambiguateRoute = function disambiguate(session, results) { | ||
if (self.onBeginRouting && !self.onBeginRouting(session)) { | ||
return undefined; | ||
} | ||
if (session.message && session.message.text) { | ||
self.recognize(session, (err, result) => { | ||
if (result.score > routingThreshold && result.answer && result.answer !== '') { | ||
if (self.onRecognizedRouting && !self.onRecognizedRouting(session, result)) { | ||
return undefined; | ||
} | ||
const response = result.answer; | ||
if (response[0] === '/') { | ||
return session.beginDialog(response); | ||
} | ||
return session.send(response); | ||
} | ||
if (self.onUnrecognizedRouting && !self.onUnrecognizedRouting(session, result)) { | ||
return undefined; | ||
} | ||
return self.defaultRouting(bot, session, results); | ||
}); | ||
} else { | ||
if (self.onNoTextRouting && !self.onNoTextRouting(session)) { | ||
return undefined; | ||
} | ||
return self.defaultRouting(bot, session, results); | ||
} | ||
return undefined; | ||
}; | ||
} | ||
} | ||
module.exports = Recognizer; |
{ | ||
"name": "node-nlp", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Library for NLU (Natural Language Understanding) done in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11422488
337136