botium-core 1.15.5 → 1.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +88 -4
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +88 -4
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/Capabilities.js +7 -0
- package/src/containers/plugins/SimpleRestContainer.js +73 -3
- package/test/connectors/simplerest.spec.js +62 -0
package/dist/botium-es.js
CHANGED
|
@@ -35,7 +35,7 @@ import express from 'express';
|
|
|
35
35
|
import bodyParser from 'body-parser';
|
|
36
36
|
|
|
37
37
|
var name = "botium-core";
|
|
38
|
-
var version$1 = "1.15.
|
|
38
|
+
var version$1 = "1.15.6";
|
|
39
39
|
var description = "The Selenium for Chatbots";
|
|
40
40
|
var main = "index.js";
|
|
41
41
|
var module = "dist/botium-es.js";
|
|
@@ -273,6 +273,13 @@ var Capabilities = {
|
|
|
273
273
|
SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
|
|
274
274
|
SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
|
|
275
275
|
SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
|
|
276
|
+
SIMPLEREST_NLP_INTENT_JSONPATH: 'SIMPLEREST_NLP_INTENT_JSONPATH',
|
|
277
|
+
SIMPLEREST_NLP_CONFIDENCE_JSONPATH: 'SIMPLEREST_NLP_CONFIDENCE_JSONPATH',
|
|
278
|
+
SIMPLEREST_NLP_CONFIDENCE_DIVIDEBY100: 'SIMPLEREST_NLP_CONFIDENCE_DIVIDEBY100',
|
|
279
|
+
SIMPLEREST_NLP_FALLBACK_INTENTS: 'SIMPLEREST_NLP_FALLBACK_INTENTS',
|
|
280
|
+
SIMPLEREST_NLP_LIST_JSONPATH: 'SIMPLEREST_NLP_LIST_JSONPATH',
|
|
281
|
+
SIMPLEREST_NLP_LIST_INTENT_JSONPATH: 'SIMPLEREST_NLP_LIST_INTENT_JSONPATH',
|
|
282
|
+
SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH: 'SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH',
|
|
276
283
|
// Script Compiler
|
|
277
284
|
SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
|
|
278
285
|
// ROW_PER_MESSAGE or QUESTION_ANSWER
|
|
@@ -451,6 +458,13 @@ Capabilities.SIMPLEREST_REDIS_TOPIC;
|
|
|
451
458
|
Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
|
|
452
459
|
Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
|
|
453
460
|
Capabilities.SIMPLEREST_COOKIE_REPLICATION;
|
|
461
|
+
Capabilities.SIMPLEREST_NLP_INTENT_JSONPATH;
|
|
462
|
+
Capabilities.SIMPLEREST_NLP_CONFIDENCE_JSONPATH;
|
|
463
|
+
Capabilities.SIMPLEREST_NLP_CONFIDENCE_DIVIDEBY100;
|
|
464
|
+
Capabilities.SIMPLEREST_NLP_FALLBACK_INTENTS;
|
|
465
|
+
Capabilities.SIMPLEREST_NLP_LIST_JSONPATH;
|
|
466
|
+
Capabilities.SIMPLEREST_NLP_LIST_INTENT_JSONPATH;
|
|
467
|
+
Capabilities.SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH;
|
|
454
468
|
Capabilities.SCRIPTING_TXT_EOL;
|
|
455
469
|
Capabilities.SCRIPTING_XLSX_MODE;
|
|
456
470
|
Capabilities.SCRIPTING_XLSX_EOL_WRITE;
|
|
@@ -8383,6 +8397,75 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8383
8397
|
}
|
|
8384
8398
|
});
|
|
8385
8399
|
debug$4(`found response cards: ${util.inspect(cards)}`);
|
|
8400
|
+
let nlp = {
|
|
8401
|
+
intent: {}
|
|
8402
|
+
};
|
|
8403
|
+
const _normalizeIntent = intent => {
|
|
8404
|
+
if ('name' in intent) {
|
|
8405
|
+
if (!intent.name) {
|
|
8406
|
+
intent.name = 'None';
|
|
8407
|
+
}
|
|
8408
|
+
const fallbackIntents = this.caps[Capabilities.SIMPLEREST_NLP_FALLBACK_INTENTS];
|
|
8409
|
+
if (fallbackIntents) {
|
|
8410
|
+
intent.incomprehension = this.caps[Capabilities.SIMPLEREST_NLP_FALLBACK_INTENTS].includes(intent.name) ? true : undefined;
|
|
8411
|
+
} else {
|
|
8412
|
+
intent.incomprehension = intent.name.toLowerCase() === 'none' ? true : undefined;
|
|
8413
|
+
}
|
|
8414
|
+
}
|
|
8415
|
+
if (!lodash.isNil(intent.confidence)) {
|
|
8416
|
+
if (typeof intent.confidence === 'string') {
|
|
8417
|
+
intent.confidence = Number(intent.confidence);
|
|
8418
|
+
}
|
|
8419
|
+
if (lodash.isNil(this.caps[Capabilities.SIMPLEREST_NLP_CONFIDENCE_DIVIDEBY100]) ? intent.confidence > 1 : this.caps[Capabilities.SIMPLEREST_NLP_CONFIDENCE_DIVIDEBY100]) {
|
|
8420
|
+
intent.confidence /= 100;
|
|
8421
|
+
}
|
|
8422
|
+
}
|
|
8423
|
+
return intent;
|
|
8424
|
+
};
|
|
8425
|
+
const jsonPathIntent = this.caps[Capabilities.SIMPLEREST_NLP_INTENT_JSONPATH];
|
|
8426
|
+
if (jsonPathIntent) {
|
|
8427
|
+
const name = jsonpath.query(jsonPathRoot, jsonPathIntent);
|
|
8428
|
+
nlp.intent.name = name?.length ? name[0] : null;
|
|
8429
|
+
}
|
|
8430
|
+
const jsonPathConfidence = this.caps[Capabilities.SIMPLEREST_NLP_CONFIDENCE_JSONPATH];
|
|
8431
|
+
if (jsonPathConfidence) {
|
|
8432
|
+
const confidence = jsonpath.query(jsonPathRoot, jsonPathConfidence);
|
|
8433
|
+
nlp.intent.confidence = confidence?.length ? confidence[0] : null;
|
|
8434
|
+
}
|
|
8435
|
+
_normalizeIntent(nlp.intent);
|
|
8436
|
+
const jsonPathList = this.caps[Capabilities.SIMPLEREST_NLP_LIST_JSONPATH];
|
|
8437
|
+
const jsonPathListIntent = this.caps[Capabilities.SIMPLEREST_NLP_LIST_INTENT_JSONPATH];
|
|
8438
|
+
const jsonPathListConfidence = this.caps[Capabilities.SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH];
|
|
8439
|
+
if (jsonPathList) {
|
|
8440
|
+
const list = jsonpath.query(jsonPathRoot, jsonPathList);
|
|
8441
|
+
if (list?.length) {
|
|
8442
|
+
const intentList = list[0].map(e => {
|
|
8443
|
+
const name = jsonpath.query(e, jsonPathListIntent);
|
|
8444
|
+
const res = {
|
|
8445
|
+
name: name?.length ? name[0] : null
|
|
8446
|
+
};
|
|
8447
|
+
if (jsonPathListConfidence) {
|
|
8448
|
+
const confidence = jsonpath.query(e, jsonPathListConfidence);
|
|
8449
|
+
res.confidence = confidence?.length ? confidence[0] : null;
|
|
8450
|
+
}
|
|
8451
|
+
_normalizeIntent(res);
|
|
8452
|
+
return res;
|
|
8453
|
+
});
|
|
8454
|
+
if (intentList.length > 0 && !nlp.intent.name) {
|
|
8455
|
+
nlp.intent.name = intentList[0].name;
|
|
8456
|
+
nlp.intent.confidence = intentList[0].confidence;
|
|
8457
|
+
}
|
|
8458
|
+
if (nlp.intent.name === intentList[0].name) {
|
|
8459
|
+
intentList.shift();
|
|
8460
|
+
}
|
|
8461
|
+
nlp.intent.intents = intentList;
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8464
|
+
if (Object.keys(nlp.intent).length > 0) {
|
|
8465
|
+
debug$4(`found response nlp: ${util.inspect(nlp)}`);
|
|
8466
|
+
} else {
|
|
8467
|
+
nlp = null;
|
|
8468
|
+
}
|
|
8386
8469
|
let hasMessageText = false;
|
|
8387
8470
|
const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
|
|
8388
8471
|
for (const jsonPath of jsonPathsTexts) {
|
|
@@ -8398,7 +8481,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8398
8481
|
messageText,
|
|
8399
8482
|
media,
|
|
8400
8483
|
buttons,
|
|
8401
|
-
|
|
8484
|
+
nlp
|
|
8402
8485
|
};
|
|
8403
8486
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
8404
8487
|
botMsg,
|
|
@@ -8414,7 +8497,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8414
8497
|
sourceData: body,
|
|
8415
8498
|
media,
|
|
8416
8499
|
buttons,
|
|
8417
|
-
cards
|
|
8500
|
+
cards,
|
|
8501
|
+
nlp
|
|
8418
8502
|
};
|
|
8419
8503
|
const beforeHookKeys = Object.keys(botMsg);
|
|
8420
8504
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
@@ -8422,7 +8506,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8422
8506
|
botMsgRoot: jsonPathRoot
|
|
8423
8507
|
}, this.view));
|
|
8424
8508
|
const afterHookKeys = Object.keys(botMsg);
|
|
8425
|
-
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8509
|
+
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || botMsg.nlp || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8426
8510
|
result.push(botMsg);
|
|
8427
8511
|
}
|
|
8428
8512
|
}
|