wingbot 3.41.2 → 3.42.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.41.2",
3
+ "version": "3.42.0",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  const { compileWithState } = require('../../src/utils');
2
- const { StepState, getNextStep } = require('../../src/utils/slots');
2
+ const { StepState, getNextStep, StepType } = require('../../src/utils/slots');
3
+ const { vars } = require('../../src/utils/stateVariables');
3
4
 
4
5
  /** @typedef {import('../../src/Router').Resolver} Resolver */
5
6
  /** @typedef {import('../../src/Responder')} Responder */
@@ -36,10 +37,18 @@ function slotsContinue ({
36
37
 
37
38
  const skipEntities = compileWithState(req, res, skip)
38
39
  .split(',')
39
- .map((e) => e.trim().replace(/^@/, ''));
40
+ .map((e) => e.trim());
41
+
42
+ const clear = {};
40
43
 
41
44
  slotState = slotState.map((s) => {
42
45
  if (skipEntities.includes(s.e)) {
46
+ if (s.t === StepType.MULTI) {
47
+ const entity = step.entity.replace(/^@/, '+');
48
+ Object.assign(clear, vars.dialogContext(entity, [], true));
49
+ } else {
50
+ Object.assign(clear, vars.dialogContext(s.e, null, true));
51
+ }
43
52
  return { ...s, s: StepState.INITIALIZED };
44
53
  }
45
54
 
@@ -48,7 +57,7 @@ function slotsContinue ({
48
57
  : s;
49
58
  });
50
59
 
51
- res.setState({ _slotState: slotState });
60
+ res.setState({ ...clear, _slotState: slotState });
52
61
 
53
62
  return getNextStep(req, res, postBack);
54
63
  }
@@ -40,6 +40,7 @@ function slotsRegister ({
40
40
 
41
41
  if (entities.length === 0) {
42
42
  return {
43
+ t: step.type,
43
44
  e: step.entity,
44
45
  s: step.type === StepType.ADDITIONAL
45
46
  ? StepState.FILLED
@@ -54,6 +55,7 @@ function slotsRegister ({
54
55
  }
55
56
 
56
57
  return {
58
+ t: step.type,
57
59
  e: step.entity,
58
60
  s: step.validateAction ? StepState.FILLED : StepState.VALID
59
61
  };
package/src/Responder.js CHANGED
@@ -148,6 +148,11 @@ class Responder {
148
148
  */
149
149
  this.startedOutput = false;
150
150
 
151
+ /**
152
+ * @type {VoiceControl}
153
+ */
154
+ this.voiceControl = {};
155
+
151
156
  this._trackAsAction = null;
152
157
 
153
158
  // both vars are package protected
@@ -471,9 +476,12 @@ class Responder {
471
476
  }
472
477
  }
473
478
 
474
- if (voice && this._features.includes(FEATURE_VOICE)) {
479
+ if (this._features.includes(FEATURE_VOICE)
480
+ && (voice || Object.keys(this.voiceControl).length)) {
481
+
475
482
  Object.assign(messageData.message, {
476
483
  voice: {
484
+ ...this.voiceControl,
477
485
  ...voice
478
486
  }
479
487
  });
@@ -40,6 +40,7 @@ const StepState = {
40
40
  * @typedef {object} SlotState
41
41
  * @prop {string} e
42
42
  * @prop {StepState} s
43
+ * @prop {StepType} t
43
44
  */
44
45
 
45
46
  /**