wingbot 3.40.2 → 3.41.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.40.2",
3
+ "version": "3.41.0",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,3 +1,5 @@
1
+
2
+ const { compileWithState } = require('../../src/utils');
1
3
  const { StepState, getNextStep } = require('../../src/utils/slots');
2
4
 
3
5
  /** @typedef {import('../../src/Router').Resolver} Resolver */
@@ -7,9 +9,13 @@ const { StepState, getNextStep } = require('../../src/utils/slots');
7
9
  /** @typedef {import('../../src/utils/slots').SlotsRequest} SlotsRequest */
8
10
 
9
11
  /**
12
+ * @param {object} params
13
+ * @param {string} [params.skip]
10
14
  * @returns {SlotsResolver}
11
15
  */
12
- function slotContinue () {
16
+ function slotsContinue ({
17
+ skip
18
+ }) {
13
19
 
14
20
  /**
15
21
  * @param {SlotsRequest} req
@@ -17,7 +23,7 @@ function slotContinue () {
17
23
  * @param {Function} postBack
18
24
  * @returns {Promise}
19
25
  */
20
- async function slotContinuePlugin (req, res, postBack) {
26
+ async function slotsContinuePlugin (req, res, postBack) {
21
27
  const state = { ...req.state, ...res.newState };
22
28
 
23
29
  const { _slotStep: step } = state;
@@ -28,16 +34,27 @@ function slotContinue () {
28
34
  res.text(msg);
29
35
  throw new Error(msg);
30
36
  }
31
- slotState = slotState.map((s) => (s.e === step.entity
32
- ? { ...s, s: StepState.FILLED }
33
- : s));
37
+
38
+ const skipEntities = compileWithState(req, res, skip)
39
+ .split(',')
40
+ .map((e) => e.trim());
41
+
42
+ slotState = slotState.map((s) => {
43
+ if (skipEntities.includes(s.e)) {
44
+ return { ...s, s: StepState.INITIALIZED }
45
+ }
46
+
47
+ return s.e === step.entity
48
+ ? { ...s, s: StepState.FILLED }
49
+ : s;
50
+ });
34
51
 
35
52
  res.setState({ _slotState: slotState });
36
53
 
37
54
  return getNextStep(req, res, postBack);
38
55
  }
39
56
 
40
- return slotContinuePlugin;
57
+ return slotsContinuePlugin;
41
58
  }
42
59
 
43
- module.exports = slotContinue;
60
+ module.exports = slotsContinue;
@@ -442,11 +442,19 @@
442
442
  {
443
443
  "id": "ai.wingbot.slotsContinue",
444
444
  "name": "Slot filling: continue",
445
- "description": "move the slot filling to the next step",
445
+ "description": "Move the slot filling to the next step",
446
446
  "availableSince": 3.39,
447
447
  "editable": false,
448
448
  "isFactory": true,
449
449
  "inputs": [
450
+ {
451
+ "name": "skip",
452
+ "label": "Skip to entity (reset entities)",
453
+ "type": "text",
454
+ "validations": [
455
+ { "type": "regexp", "value": "^\\s*@[a-zA-Z0-9-]+\\s*(,\\s*@[a-zA-Z0-9-]+\\s*)*$", "message": "the entity for the slot filling should be valid" }
456
+ ]
457
+ }
450
458
  ],
451
459
  "items": [
452
460
  ]