wingbot 3.54.0 → 3.55.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.54.0",
3
+ "version": "3.55.0",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Processor.js CHANGED
@@ -58,6 +58,8 @@ const { prepareState, mergeState, isUserInteraction } = require('./utils/stateVa
58
58
  * @prop {object} state
59
59
  * @prop {object} data
60
60
  * @prop {string|null} skill
61
+ * @prop {string|null} prevSkill
62
+ * @prop {string|null} pathname
61
63
  * @prop {TrackingObject} tracking - deprecated
62
64
  * @prop {TrackingEvent[]} events
63
65
  * @prop {ResponseFlag|null} flag
@@ -423,11 +425,14 @@ class Processor extends EventEmitter {
423
425
  */
424
426
  _emitInteractionEvent (req, res, messageSender, state, data) {
425
427
  const doNotTrack = data._initialEventShouldNotBeTracked === true;
426
- const { _lastAction: lastAction = null } = req.state;
428
+ const { _lastAction: lastAction = null, '§pathname': pathname = null } = req.state;
427
429
  const actions = messageSender.visitedInteractions;
428
430
  const skill = typeof res.newState._trackAsSkill === 'undefined'
429
431
  ? (req.state._trackAsSkill || null)
430
432
  : res.newState._trackAsSkill;
433
+ const prevSkill = typeof res.newState._trackPrevSkill === 'undefined'
434
+ ? (req.state._trackPrevSkill || null)
435
+ : res.newState._trackPrevSkill;
431
436
  const { events = [] } = messageSender.tracking;
432
437
 
433
438
  const event = {
@@ -439,6 +444,8 @@ class Processor extends EventEmitter {
439
444
  state,
440
445
  data,
441
446
  skill,
447
+ prevSkill,
448
+ pathname,
442
449
  tracking: messageSender.tracking,
443
450
  events,
444
451
  flag: res.senderMeta.flag,
package/src/Responder.js CHANGED
@@ -1262,7 +1262,15 @@ class Responder {
1262
1262
  * @returns {this}
1263
1263
  */
1264
1264
  trackAsSkill (skill) {
1265
- this.setState({ _trackAsSkill: skill });
1265
+ // @ts-ignore
1266
+ const { _trackAsSkill: currentSkill } = this.options.state;
1267
+ const setState = { _trackAsSkill: skill };
1268
+ if (currentSkill && currentSkill !== skill) {
1269
+ Object.assign(setState, {
1270
+ _trackPrevSkill: currentSkill
1271
+ });
1272
+ }
1273
+ this.setState(setState);
1266
1274
  return this;
1267
1275
  }
1268
1276
 
@@ -40,6 +40,8 @@ const {
40
40
  * @typedef {object} ConversationEventExtension
41
41
  * @prop {string} [lastAction]
42
42
  * @prop {string} [skill]
43
+ * @prop {string} [prevSkill]
44
+ * @prop {string} [pathname]
43
45
  * @prop {string} [text]
44
46
  * @prop {string} [expected]
45
47
  * @prop {boolean} expectedTaken
@@ -268,6 +270,8 @@ function onInteractionHandler (
268
270
  // state,
269
271
  // data,
270
272
  skill,
273
+ prevSkill,
274
+ pathname,
271
275
  events,
272
276
  flag,
273
277
  nonInteractive,
@@ -371,6 +375,7 @@ function onInteractionHandler (
371
375
  replaceDiacritics(req.text()).replace(/\s+/g, ' ').toLowerCase().trim()
372
376
  );
373
377
  const useSkill = (skill && webalize(skill)) || noneAction;
378
+ const usePrevSkill = (prevSkill && webalize(prevSkill)) || noneAction;
374
379
 
375
380
  let winnerAction = '';
376
381
  let winnerScore = 0;
@@ -425,6 +430,8 @@ function onInteractionHandler (
425
430
  withUser,
426
431
  feedback,
427
432
  skill: useSkill,
433
+ prevSkill: usePrevSkill,
434
+ pathname: pathname || noneAction,
428
435
  winnerAction,
429
436
  winnerIntent,
430
437
  winnerEntities: asArray(winnerEntities.map((e) => e.entity)),