wingbot 3.67.16 → 3.67.18

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.67.16",
3
+ "version": "3.67.18",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/src/Ai.js CHANGED
@@ -339,6 +339,7 @@ class Ai {
339
339
  * @param {string} name
340
340
  * @param {object} options
341
341
  * @param {boolean} [options.anonymize]
342
+ * @param {boolean} [options.clearOverlaps] - set true to override entities from NLP
342
343
  * @returns {this}
343
344
  * @example
344
345
  *
@@ -465,6 +465,28 @@ class ReturnSender {
465
465
  throw new Error('#upload() not supported by this channel');
466
466
  }
467
467
 
468
+ _isVisibleMessage (event, needTitle = true) {
469
+ // @todo is also in orchestrator
470
+
471
+ if (event.message) {
472
+ return !!(event.message.text
473
+ || event.message.attachment
474
+ || event.message.attachments);
475
+ }
476
+
477
+ if (event.sender_action) {
478
+ return true;
479
+ }
480
+
481
+ if (event.postback
482
+ && (!needTitle || event.postback.title)) {
483
+
484
+ return true;
485
+ }
486
+
487
+ return false;
488
+ }
489
+
468
490
  send (payload) {
469
491
  if (this._finished) {
470
492
  throw new Error('Cannot send message after sender is finished');
@@ -483,6 +505,29 @@ class ReturnSender {
483
505
  return;
484
506
  }
485
507
 
508
+ const lastInQueue = this._queue[this._queue.length - 1];
509
+
510
+ if (payload.set_context
511
+ && !this._isVisibleMessage(payload, false)
512
+ && lastInQueue
513
+ && this._isVisibleMessage(lastInQueue)) {
514
+
515
+ const { set_context: setContext, ...rest } = payload;
516
+
517
+ Object.assign(
518
+ lastInQueue,
519
+ rest,
520
+ lastInQueue,
521
+ {
522
+ set_context: {
523
+ ...lastInQueue.set_context,
524
+ ...setContext
525
+ }
526
+ }
527
+ );
528
+ return;
529
+ }
530
+
486
531
  const text = extractText(payload);
487
532
  if (text) {
488
533
  this._responseTexts.push(text);