wingbot 3.68.4 → 3.68.7
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
package/src/Responder.js
CHANGED
|
@@ -251,7 +251,7 @@ class Responder {
|
|
|
251
251
|
* @returns {Promise<Transcript[]>}
|
|
252
252
|
*/
|
|
253
253
|
async getTranscript (limit = 10, onlyFlag = null, skipThisTurnaround = false) {
|
|
254
|
-
const { chatLogStorage } = this._messageSender;
|
|
254
|
+
const { chatLogStorage, timestamp } = this._messageSender;
|
|
255
255
|
if (!chatLogStorage) {
|
|
256
256
|
return [];
|
|
257
257
|
}
|
|
@@ -265,10 +265,10 @@ class Responder {
|
|
|
265
265
|
if (!skipThisTurnaround) {
|
|
266
266
|
const { responseTexts = [], requestTexts = [] } = this._messageSender;
|
|
267
267
|
transcript.push(...requestTexts.map((text) => ({
|
|
268
|
-
fromBot: false, text
|
|
268
|
+
fromBot: false, text, timestamp
|
|
269
269
|
})));
|
|
270
270
|
transcript.push(...responseTexts.map((text) => ({
|
|
271
|
-
fromBot: true, text
|
|
271
|
+
fromBot: true, text, timestamp
|
|
272
272
|
})));
|
|
273
273
|
}
|
|
274
274
|
return transcript;
|
package/src/ReturnSender.js
CHANGED
|
@@ -103,6 +103,8 @@ class ReturnSender {
|
|
|
103
103
|
|
|
104
104
|
this._features = Array.isArray(incommingMessage.features) ? incommingMessage.features : ['text'];
|
|
105
105
|
|
|
106
|
+
this.timestamp = incommingMessage.timestamp;
|
|
107
|
+
|
|
106
108
|
this._sendLastMessageWithFinish = this._features.includes(FEATURE_PHRASES)
|
|
107
109
|
|| this._features.includes(FEATURE_TRACKING);
|
|
108
110
|
|
|
@@ -48,7 +48,7 @@ function conversationTestApi (testsSource, botFactory, options, acl) {
|
|
|
48
48
|
|
|
49
49
|
await ctx.audit('conversationTest', args);
|
|
50
50
|
|
|
51
|
-
return test.test(validationRequestBody, step, lang);
|
|
51
|
+
return test.test(validationRequestBody, step, lang, ctx.params.snapshot);
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
@@ -102,7 +102,7 @@ function validateBotApi (botFactory, postBackTest = null, textTest = null, acl =
|
|
|
102
102
|
validationRequestBody = decompress(validationRequestBody);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
const bot = await Promise.resolve(botFactory(true, ctx.snapshot));
|
|
105
|
+
const bot = await Promise.resolve(botFactory(true, ctx.params.snapshot));
|
|
106
106
|
|
|
107
107
|
await ctx.audit('validateBot');
|
|
108
108
|
return validate(bot, validationRequestBody, postBackTest, textTest);
|
|
@@ -5,16 +5,52 @@
|
|
|
5
5
|
|
|
6
6
|
/** @typedef {import('./transcriptFromHistory').Transcript} Transcript */
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} Options
|
|
10
|
+
* @prop {string} [timezone]
|
|
11
|
+
* @prop {string} [locale]
|
|
12
|
+
*/
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* @param {Transcript[]} transcript
|
|
10
16
|
* @param {string} [userSide]
|
|
11
17
|
* @param {string} [botSide]
|
|
18
|
+
* @param {Options} [options]
|
|
12
19
|
* @returns {string}
|
|
13
20
|
*/
|
|
14
|
-
function htmlBodyFromTranscript (transcript, userSide = 'User', botSide = 'Bot') {
|
|
21
|
+
function htmlBodyFromTranscript (transcript, userSide = 'User', botSide = 'Bot', options = {}) {
|
|
22
|
+
|
|
23
|
+
let lastDate = null;
|
|
24
|
+
let lastTime = null;
|
|
25
|
+
const showDate = options.locale && options.timezone;
|
|
15
26
|
|
|
16
27
|
return transcript
|
|
17
|
-
.
|
|
28
|
+
.flatMap((msg) => {
|
|
29
|
+
const line = `<b>${msg.fromBot ? botSide : userSide}:</b> ${msg.text}`;
|
|
30
|
+
|
|
31
|
+
if (!showDate || !msg.timestamp) {
|
|
32
|
+
return [line];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const d = new Date(msg.timestamp);
|
|
36
|
+
|
|
37
|
+
const date = d.toLocaleDateString(options.locale, {
|
|
38
|
+
year: 'numeric', month: 'numeric', day: 'numeric', timeZone: options.timezone
|
|
39
|
+
});
|
|
40
|
+
const time = d.toLocaleTimeString(options.locale, {
|
|
41
|
+
hour: 'numeric', minute: 'numeric', timeZone: options.timezone
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (lastTime === time && lastDate === time) {
|
|
45
|
+
return [line];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const timeLine = `<i>(${lastDate === date ? '' : `${date} `}${time})</i></small>`;
|
|
49
|
+
lastDate = date;
|
|
50
|
+
lastTime = time;
|
|
51
|
+
|
|
52
|
+
return [timeLine, line];
|
|
53
|
+
})
|
|
18
54
|
.join('<br />');
|
|
19
55
|
}
|
|
20
56
|
|
|
@@ -22,6 +22,7 @@ const extractText = require('./extractText');
|
|
|
22
22
|
* @typedef {object} Transcript
|
|
23
23
|
* @prop {string} text
|
|
24
24
|
* @prop {boolean} fromBot
|
|
25
|
+
* @prop {number} [timestamp]
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -51,12 +52,17 @@ async function transcriptFromHistory (
|
|
|
51
52
|
|
|
52
53
|
return data
|
|
53
54
|
.map((turn) => {
|
|
55
|
+
let { timestamp } = turn;
|
|
54
56
|
const { request, responses = [] } = turn;
|
|
55
57
|
|
|
58
|
+
if (!timestamp) {
|
|
59
|
+
timestamp = request.timestamp || null;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
return [
|
|
57
|
-
{ fromBot: false, text: extractText(request) },
|
|
63
|
+
{ fromBot: false, text: extractText(request), timestamp },
|
|
58
64
|
...responses
|
|
59
|
-
.map((response) => ({ fromBot: true, text: extractText(response) }))
|
|
65
|
+
.map((response) => ({ fromBot: true, text: extractText(response), timestamp }))
|
|
60
66
|
];
|
|
61
67
|
})
|
|
62
68
|
.reduce((ret, arr) => [...ret, ...arr], [])
|