@ebonydevcopy/framework
Version:
A module-based NodeJS chatbot framework.
39 lines • 1.38 kB
JavaScript
;
/**
* ebony-framework
*
* @module routers/IntentRouter
* @author Christos Panagiotakopoulos <chrispanag@gmail.com>
* @copyright Copyright(c) 2020 Christos Panagiotakopoulos
* @license MIT
*
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const BasicRouter_1 = __importDefault(require("./BasicRouter"));
/**
* Intent router class
*/
class IntentRouter extends BasicRouter_1.default {
intentRouter(user, msg, nlp) {
if (nlp.entities.intent) {
if (nlp.entities.intent[0]) {
if (nlp.entities.intent[0].value) {
const func = this.getRoute(nlp.entities.intent[0].value);
if (func) {
return func;
}
console.log(`[Warning] Intent not ${nlp.entities.intent[0].value} found!`);
return false;
}
throw new Error(`intentHandler: 'Intent[0].value' is not defined`);
}
throw new Error(`intentHandler: 'Intent[0]' is not defined`);
}
throw new Error(`intentHandler: Entity 'Intent' doesn't exist.`);
}
}
exports.default = IntentRouter;
//# sourceMappingURL=IntentRouter.js.map