wingbot 3.40.2 → 3.41.1

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.1",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,3 +1,4 @@
1
+ const { compileWithState } = require('../../src/utils');
1
2
  const { StepState, getNextStep } = require('../../src/utils/slots');
2
3
 
3
4
  /** @typedef {import('../../src/Router').Resolver} Resolver */
@@ -7,9 +8,13 @@ const { StepState, getNextStep } = require('../../src/utils/slots');
7
8
  /** @typedef {import('../../src/utils/slots').SlotsRequest} SlotsRequest */
8
9
 
9
10
  /**
11
+ * @param {object} params
12
+ * @param {string} [params.skip]
10
13
  * @returns {SlotsResolver}
11
14
  */
12
- function slotContinue () {
15
+ function slotsContinue ({
16
+ skip
17
+ }) {
13
18
 
14
19
  /**
15
20
  * @param {SlotsRequest} req
@@ -17,7 +22,7 @@ function slotContinue () {
17
22
  * @param {Function} postBack
18
23
  * @returns {Promise}
19
24
  */
20
- async function slotContinuePlugin (req, res, postBack) {
25
+ async function slotsContinuePlugin (req, res, postBack) {
21
26
  const state = { ...req.state, ...res.newState };
22
27
 
23
28
  const { _slotStep: step } = state;
@@ -28,16 +33,27 @@ function slotContinue () {
28
33
  res.text(msg);
29
34
  throw new Error(msg);
30
35
  }
31
- slotState = slotState.map((s) => (s.e === step.entity
32
- ? { ...s, s: StepState.FILLED }
33
- : s));
36
+
37
+ const skipEntities = compileWithState(req, res, skip)
38
+ .split(',')
39
+ .map((e) => e.trim());
40
+
41
+ slotState = slotState.map((s) => {
42
+ if (skipEntities.includes(s.e)) {
43
+ return { ...s, s: StepState.INITIALIZED };
44
+ }
45
+
46
+ return s.e === step.entity
47
+ ? { ...s, s: StepState.FILLED }
48
+ : s;
49
+ });
34
50
 
35
51
  res.setState({ _slotState: slotState });
36
52
 
37
53
  return getNextStep(req, res, postBack);
38
54
  }
39
55
 
40
- return slotContinuePlugin;
56
+ return slotsContinuePlugin;
41
57
  }
42
58
 
43
- module.exports = slotContinue;
59
+ 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 back 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
  ]
@@ -14,9 +14,6 @@ const VAR_TYPES = {
14
14
  EXPIRES_AFTER
15
15
  };
16
16
 
17
- /**
18
- * @type {object} Helpers for `res.setState()` method
19
- */
20
17
  const vars = {
21
18
 
22
19
  /**