wingbot 3.44.3 → 3.44.5

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.44.3",
3
+ "version": "3.44.5",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,16 +61,28 @@ function slotsRegister ({
61
61
  };
62
62
  });
63
63
 
64
- res.setState({
65
- _slotState: slotState,
66
- _slotSteps: steps,
67
- _slotDone: doneAction,
64
+ const setStateEntities = {
68
65
  ...Object.fromEntries(
69
66
  steps.map(({ entity, type }) => (type === StepType.MULTI
70
67
  ? [entity.replace(/^@/, '+'), []]
71
68
  : [entity, null]))
72
69
  ),
73
70
  ...setEntities.reduce((o, r) => Object.assign(o, r), {})
71
+ };
72
+
73
+ Object.assign(
74
+ req.state,
75
+ Object.fromEntries(
76
+ Object.entries(setStateEntities)
77
+ .filter(([k]) => !k.startsWith('_'))
78
+ )
79
+ );
80
+
81
+ res.setState({
82
+ _slotState: slotState,
83
+ _slotSteps: steps,
84
+ _slotDone: doneAction,
85
+ ...setStateEntities
74
86
  });
75
87
 
76
88
  return getNextStep(req, res, postBack);
@@ -36,7 +36,8 @@ function getVoiceControlFromParams (params, lang = null) {
36
36
 
37
37
  voiceControlProps.forEach((prop) => {
38
38
  if (params[prop]) {
39
- voiceControl[prop] = getLanguageText(params[prop], lang);
39
+ // for voice control do not default to other languages
40
+ voiceControl[prop] = getLanguageText(params[prop], lang, true);
40
41
  }
41
42
  });
42
43
 
@@ -61,9 +61,10 @@ function isTextObjectEmpty (text) {
61
61
  /**
62
62
  * @param {Translations} translations
63
63
  * @param {string} [lang]
64
+ * @param {boolean} [disableDefaulting] - it will try to find translation for other language
64
65
  * @returns {null|string}
65
66
  */
66
- function getLanguageText (translations, lang = null) {
67
+ function getLanguageText (translations, lang = null, disableDefaulting = false) {
67
68
  let foundText;
68
69
 
69
70
  if (isArrayOfObjects(translations)) {
@@ -71,7 +72,7 @@ function getLanguageText (translations, lang = null) {
71
72
  // @ts-ignore
72
73
  foundText = translations.find((t) => t.l === lang);
73
74
  }
74
- if (isTextObjectEmpty(foundText)) {
75
+ if (isTextObjectEmpty(foundText) && !disableDefaulting) {
75
76
  // @ts-ignore
76
77
  foundText = translations.find((t) => !isTextObjectEmpty(t));
77
78
  }