wingbot 3.39.1 → 3.40.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
|
@@ -10,7 +10,7 @@ module.exports = async (req, res) => {
|
|
|
10
10
|
if (req.hasAiActionsForDisambiguation(min, local)) {
|
|
11
11
|
max = parseInt(max, 10) || 3;
|
|
12
12
|
const actions = req.aiActionsForQuickReplies(max, req.aiActions(local));
|
|
13
|
-
actions.forEach((a) => res.
|
|
13
|
+
actions.forEach((a) => res.quickReply(a));
|
|
14
14
|
|
|
15
15
|
res.setData({ actions });
|
|
16
16
|
|
package/src/Responder.js
CHANGED
|
@@ -22,6 +22,8 @@ const TYPE_UPDATE = 'UPDATE';
|
|
|
22
22
|
const TYPE_MESSAGE_TAG = 'MESSAGE_TAG';
|
|
23
23
|
const EXCEPTION_HOPCOUNT_THRESHOLD = 5;
|
|
24
24
|
|
|
25
|
+
/** @typedef {import('./Request')} Request */
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* @enum {string}
|
|
27
29
|
*/
|
|
@@ -509,6 +511,7 @@ class Responder {
|
|
|
509
511
|
* @param {object} [data] - additional data
|
|
510
512
|
* @param {boolean} [prepend] - set true to add reply at the beginning
|
|
511
513
|
* @param {boolean} [justToExisting] - add quick reply only to existing replies
|
|
514
|
+
* @deprecated use #quickReply instead
|
|
512
515
|
* @example
|
|
513
516
|
*
|
|
514
517
|
* bot.use((req, res) => {
|
|
@@ -554,6 +557,37 @@ class Responder {
|
|
|
554
557
|
return this;
|
|
555
558
|
}
|
|
556
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Adds quick reply, to be sent by following text message
|
|
562
|
+
*
|
|
563
|
+
* @param {QuickReply} reply
|
|
564
|
+
* @param {boolean} [atStart]
|
|
565
|
+
* @param {boolean} [toLastMessage]
|
|
566
|
+
* @returns {this}
|
|
567
|
+
* @example
|
|
568
|
+
*
|
|
569
|
+
* bot.use((req, res) => {
|
|
570
|
+
* res.quickReply({ action: 'barAction', title: 'last action' });
|
|
571
|
+
*
|
|
572
|
+
* res.text('Text', {
|
|
573
|
+
* fooAction: 'goto foo'
|
|
574
|
+
* }); // will be merged and sent with previously added quick replies
|
|
575
|
+
* });
|
|
576
|
+
*/
|
|
577
|
+
quickReply (reply, atStart = false, toLastMessage = true) {
|
|
578
|
+
const useCa = this.currentAction();
|
|
579
|
+
|
|
580
|
+
this._quickReplyCollector.push({
|
|
581
|
+
...reply,
|
|
582
|
+
action: this.toAbsoluteAction(reply.action),
|
|
583
|
+
useCa,
|
|
584
|
+
...(atStart && { _prepend: true }),
|
|
585
|
+
...(toLastMessage && { _justToExisting: true })
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
return this;
|
|
589
|
+
}
|
|
590
|
+
|
|
557
591
|
/**
|
|
558
592
|
* To be able to keep context of previous interaction (expected action and intents)
|
|
559
593
|
* Just use this method to let user to answer again.
|
package/src/Tester.js
CHANGED