@tiledesk/tiledesk-tybot-connector 2.0.12-rc4 → 2.0.12-rc6
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/ExtApi.js +1 -8
- package/ExtUtil.js +5 -6
- package/engine/IntentForm.js +0 -1
- package/engine/IntentsMachineFactory.js +4 -4
- package/engine/MongodbBotsDataSource.js +0 -1
- package/engine/MongodbIntentsMachine.js +0 -1
- package/engine/TiledeskChatbot.js +11 -16
- package/engine/TiledeskIntentsMachine.js +1 -2
- package/index.js +11 -23
- package/logs/app.log +573 -0
- package/package.json +1 -1
- package/services/AIService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +10 -10
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +1 -2
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +7 -9
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfNotOpenHours.js +3 -10
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfOpenHours.js +2 -9
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +333 -0
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +36 -54
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -15
- package/tiledeskChatbotPlugs/directives/DirMessage.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -10
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -15
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +15 -29
|
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require("../../engine/TiledeskChatbot");
|
|
|
3
3
|
const { Filler } = require("../Filler");
|
|
4
4
|
let https = require("https");
|
|
5
5
|
const { DirIntent } = require("./DirIntent");
|
|
6
|
+
const winston = require('../../utils/winston');
|
|
6
7
|
const httpUtils = require("../../utils/HttpUtils");
|
|
7
8
|
require('dotenv').config();
|
|
8
9
|
|
|
@@ -22,13 +23,13 @@ class DirGptTask {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
execute(directive, callback) {
|
|
25
|
-
|
|
26
|
+
winston.verbose("Execute GptTask directive");
|
|
26
27
|
let action;
|
|
27
28
|
if (directive.action) {
|
|
28
29
|
action = directive.action;
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
|
-
|
|
32
|
+
winston.warn("DirGptTask Incorrect directive: ", directive);
|
|
32
33
|
callback();
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -38,9 +39,9 @@ class DirGptTask {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
async go(action, callback) {
|
|
41
|
-
|
|
42
|
+
winston.debug("(DirGptTask) Action: ", action);
|
|
42
43
|
if (!this.tdcache) {
|
|
43
|
-
|
|
44
|
+
winston.error("(DirGptTask) Error: tdcache is mandatory");
|
|
44
45
|
callback();
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
@@ -50,18 +51,16 @@ class DirGptTask {
|
|
|
50
51
|
let trueIntentAttributes = action.trueIntentAttributes;
|
|
51
52
|
let falseIntentAttributes = action.falseIntentAttributes;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log("DirGptTask falseIntentAttributes", falseIntentAttributes)
|
|
58
|
-
}
|
|
54
|
+
winston.debug("(DirGptTask) trueIntent " + trueIntent)
|
|
55
|
+
winston.debug("(DirGptTask) falseIntent " + falseIntent)
|
|
56
|
+
winston.debug("(DirGptTask) trueIntentAttributes " + trueIntentAttributes)
|
|
57
|
+
winston.debug("(DirGptTask) falseIntentAttributes " + falseIntentAttributes)
|
|
59
58
|
|
|
60
59
|
// default value
|
|
61
60
|
let answer = "No answer.";
|
|
62
61
|
|
|
63
62
|
if (!action.question || action.question === '') {
|
|
64
|
-
|
|
63
|
+
winston.debug("(DirGptTask) Error: question attribute is mandatory. Executing condition false...")
|
|
65
64
|
if (falseIntent) {
|
|
66
65
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
67
66
|
callback(true);
|
|
@@ -83,13 +82,11 @@ class DirGptTask {
|
|
|
83
82
|
let max_tokens = action.max_tokens;
|
|
84
83
|
let temperature = action.temperature;
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.log("DirGptTask temperature: ", temperature);
|
|
89
|
-
}
|
|
85
|
+
winston.debug("(DirGptTask) max_tokens: " + max_tokens);
|
|
86
|
+
winston.debug("(DirGptTask) temperature: " + temperature);
|
|
90
87
|
|
|
91
88
|
const openai_url = process.env.OPENAI_ENDPOINT + "/chat/completions";
|
|
92
|
-
|
|
89
|
+
winston.debug("(DirGptTask) openai_url ", openai_url);
|
|
93
90
|
|
|
94
91
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
95
92
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
@@ -99,7 +96,7 @@ class DirGptTask {
|
|
|
99
96
|
},
|
|
100
97
|
method: "GET"
|
|
101
98
|
}
|
|
102
|
-
|
|
99
|
+
winston.debug("(DirGptTask) INTEGRATIONS_HTTPREQUEST ", INTEGRATIONS_HTTPREQUEST);
|
|
103
100
|
|
|
104
101
|
httpUtils.request(
|
|
105
102
|
INTEGRATIONS_HTTPREQUEST, async (err, integration) => {
|
|
@@ -111,7 +108,7 @@ class DirGptTask {
|
|
|
111
108
|
// return;
|
|
112
109
|
}
|
|
113
110
|
} else if (callback) {
|
|
114
|
-
|
|
111
|
+
winston.debug("(DirGptTask) get integration resbody: ", integration);
|
|
115
112
|
|
|
116
113
|
let key;
|
|
117
114
|
if (integration &&
|
|
@@ -122,8 +119,7 @@ class DirGptTask {
|
|
|
122
119
|
// key not present in integrations - for retro compatibility search in kbsettings
|
|
123
120
|
if (!key) {
|
|
124
121
|
|
|
125
|
-
|
|
126
|
-
if (this.log) { console.log("DirGptTask - Key not found in Integrations. Searching in kb settings..."); }
|
|
122
|
+
winston.debug("(DirGptTask) Key not found in Integrations. Searching in kb settings...");
|
|
127
123
|
|
|
128
124
|
const KB_HTTPREQUEST = {
|
|
129
125
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kbsettings",
|
|
@@ -133,16 +129,15 @@ class DirGptTask {
|
|
|
133
129
|
},
|
|
134
130
|
method: "GET"
|
|
135
131
|
}
|
|
136
|
-
|
|
132
|
+
winston.debug("(DirGptTask) KB_HTTPREQUEST", KB_HTTPREQUEST);
|
|
137
133
|
|
|
138
134
|
httpUtils.request(
|
|
139
135
|
KB_HTTPREQUEST, async (err, resbody) => {
|
|
140
136
|
if (err) {
|
|
141
137
|
if (callback) {
|
|
142
138
|
console.error("(httprequest) DirGptTask Get KnowledgeBase err:", err.message);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
139
|
+
console.error("(httprequest) DirGptTask Get KnowledgeBase full err", err);
|
|
140
|
+
|
|
146
141
|
await this.#assignAttributes(action, answer);
|
|
147
142
|
if (falseIntent) {
|
|
148
143
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -153,7 +148,7 @@ class DirGptTask {
|
|
|
153
148
|
return;
|
|
154
149
|
}
|
|
155
150
|
} else if (callback) {
|
|
156
|
-
|
|
151
|
+
winston.debug("(DirGptTask) Get KnowledgeBase settings resbody:", resbody);
|
|
157
152
|
|
|
158
153
|
if (!resbody.gptkey) {
|
|
159
154
|
await this.#assignAttributes(action, answer);
|
|
@@ -167,7 +162,7 @@ class DirGptTask {
|
|
|
167
162
|
|
|
168
163
|
} else {
|
|
169
164
|
|
|
170
|
-
|
|
165
|
+
winston.debug("(DirGptTask) Key found in KbSettings");
|
|
171
166
|
|
|
172
167
|
key = resbody.gptkey;
|
|
173
168
|
|
|
@@ -189,7 +184,7 @@ class DirGptTask {
|
|
|
189
184
|
message.content = action.context;
|
|
190
185
|
json.messages.unshift(message);
|
|
191
186
|
}
|
|
192
|
-
|
|
187
|
+
winston.debug("(DirGptTask) json: ", json);
|
|
193
188
|
|
|
194
189
|
const HTTPREQUEST = {
|
|
195
190
|
url: openai_url,
|
|
@@ -200,14 +195,12 @@ class DirGptTask {
|
|
|
200
195
|
json: json,
|
|
201
196
|
method: 'POST'
|
|
202
197
|
}
|
|
203
|
-
|
|
198
|
+
winston.debug("(DirGptTask) HTTPREQUEST: ", HTTPREQUEST);
|
|
204
199
|
httpUtils.request(
|
|
205
200
|
HTTPREQUEST, async (err, resbody) => {
|
|
206
201
|
if (err) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
210
|
-
}
|
|
202
|
+
console.error("(httprequest) DirGptTask openai err:", err);
|
|
203
|
+
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
211
204
|
await this.#assignAttributes(action, answer);
|
|
212
205
|
if (falseIntent) {
|
|
213
206
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -217,7 +210,7 @@ class DirGptTask {
|
|
|
217
210
|
callback();
|
|
218
211
|
return;
|
|
219
212
|
} else {
|
|
220
|
-
|
|
213
|
+
winston.debug("(DirGptTask) resbody: ", JSON.stringify(resbody));
|
|
221
214
|
answer = resbody.choices[0].message.content;
|
|
222
215
|
let answer_json = await this.convertToJson(answer);
|
|
223
216
|
await this.#assignAttributes(action, answer_json);
|
|
@@ -237,7 +230,7 @@ class DirGptTask {
|
|
|
237
230
|
)
|
|
238
231
|
} else {
|
|
239
232
|
|
|
240
|
-
|
|
233
|
+
winston.debug("(DirGptTask) Key found in Integrations");
|
|
241
234
|
|
|
242
235
|
let json = {
|
|
243
236
|
"model": action.model,
|
|
@@ -257,7 +250,7 @@ class DirGptTask {
|
|
|
257
250
|
message.content = action.context;
|
|
258
251
|
json.messages.unshift(message);
|
|
259
252
|
}
|
|
260
|
-
|
|
253
|
+
winston.debug("(DirGptTask) json: ", json);
|
|
261
254
|
|
|
262
255
|
const HTTPREQUEST = {
|
|
263
256
|
url: openai_url,
|
|
@@ -268,14 +261,12 @@ class DirGptTask {
|
|
|
268
261
|
json: json,
|
|
269
262
|
method: 'POST'
|
|
270
263
|
}
|
|
271
|
-
|
|
264
|
+
winston.debug("(DirGptTask) HTTPREQUEST: ", HTTPREQUEST);
|
|
272
265
|
httpUtils.request(
|
|
273
266
|
HTTPREQUEST, async (err, resbody) => {
|
|
274
267
|
if (err) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
278
|
-
}
|
|
268
|
+
console.error("(httprequest) DirGptTask openai err:", err);
|
|
269
|
+
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
279
270
|
await this.#assignAttributes(action, answer);
|
|
280
271
|
if (falseIntent) {
|
|
281
272
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -285,7 +276,7 @@ class DirGptTask {
|
|
|
285
276
|
callback();
|
|
286
277
|
return;
|
|
287
278
|
} else {
|
|
288
|
-
|
|
279
|
+
winston.debug("(DirGptTask) resbody: ", JSON.stringify(resbody));
|
|
289
280
|
answer = resbody.choices[0].message.content;
|
|
290
281
|
// check if answer is a json
|
|
291
282
|
let answer_json = await this.convertToJson(answer);
|
|
@@ -339,7 +330,7 @@ class DirGptTask {
|
|
|
339
330
|
})
|
|
340
331
|
}
|
|
341
332
|
else {
|
|
342
|
-
|
|
333
|
+
winston.debug("(DirGptTask) No trueIntentDirective specified");
|
|
343
334
|
if (callback) {
|
|
344
335
|
callback();
|
|
345
336
|
}
|
|
@@ -354,7 +345,7 @@ class DirGptTask {
|
|
|
354
345
|
});
|
|
355
346
|
}
|
|
356
347
|
else {
|
|
357
|
-
|
|
348
|
+
winston.debug("(DirGptTask) No falseIntentDirective specified");
|
|
358
349
|
if (callback) {
|
|
359
350
|
callback();
|
|
360
351
|
}
|
|
@@ -363,10 +354,8 @@ class DirGptTask {
|
|
|
363
354
|
}
|
|
364
355
|
|
|
365
356
|
async #assignAttributes(action, answer) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
console.log("assignAttributes answer:", answer)
|
|
369
|
-
}
|
|
357
|
+
winston.debug("(DirGptTask) assignAttributes action:", action)
|
|
358
|
+
winston.debug("(DirGptTask) assignAttributes answer:", answer)
|
|
370
359
|
if (this.context.tdcache) {
|
|
371
360
|
if (action.assignReplyTo && answer) {
|
|
372
361
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, action.assignReplyTo, answer);
|
|
@@ -374,13 +363,6 @@ class DirGptTask {
|
|
|
374
363
|
// if (action.assignSourceTo && source) {
|
|
375
364
|
// await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, action.assignSourceTo, source);
|
|
376
365
|
// }
|
|
377
|
-
// Debug log
|
|
378
|
-
if (this.log) {
|
|
379
|
-
const all_parameters = await TiledeskChatbot.allParametersStatic(this.context.tdcache, this.context.requestId);
|
|
380
|
-
for (const [key, value] of Object.entries(all_parameters)) {
|
|
381
|
-
if (this.log) { console.log("(gpttask) request parameter:", key, "value:", value, "type:", typeof value) }
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
366
|
}
|
|
385
367
|
}
|
|
386
368
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { DirIntent } = require('./DirIntent');
|
|
3
2
|
const axios = require("axios").default;
|
|
4
3
|
let https = require("https");
|
|
@@ -208,7 +207,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
208
207
|
}
|
|
209
208
|
resolve(resbody);
|
|
210
209
|
}
|
|
211
|
-
}
|
|
210
|
+
});
|
|
212
211
|
});
|
|
213
212
|
|
|
214
213
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { DirIntent } = require('./DirIntent');
|
|
3
3
|
const ms = require('minimist-string');
|
|
4
|
+
const winston = require('../../utils/winston');
|
|
4
5
|
|
|
5
6
|
class DirIfOpenHours {
|
|
6
7
|
|
|
@@ -26,9 +27,6 @@ class DirIfOpenHours {
|
|
|
26
27
|
let params;
|
|
27
28
|
params = this.parseParams(directive.parameter);
|
|
28
29
|
if (!params.trueIntent && !params.falseIntent) {
|
|
29
|
-
if (this.log) {
|
|
30
|
-
console.log("missing both params.trueIntent & params.falseIntent");
|
|
31
|
-
}
|
|
32
30
|
callback();
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
@@ -60,14 +58,14 @@ class DirIfOpenHours {
|
|
|
60
58
|
if (falseIntent && falseIntent.trim() === "") {
|
|
61
59
|
falseIntent = null;
|
|
62
60
|
}
|
|
63
|
-
|
|
61
|
+
winston.verbose("(DirIfOpenHours) Action:", action);
|
|
64
62
|
if (!trueIntent && !falseIntent) {
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
winston.error("(DirIfOpenHours) Error: missing both action.trueIntent & action.falseIntent");
|
|
64
|
+
callback();
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
67
|
this.tdClient.openNow((err, result) => {
|
|
70
|
-
|
|
68
|
+
winston.error("(DirIfOpenHours) openNow():", result)
|
|
71
69
|
if (err) {
|
|
72
70
|
console.error("*** DirIfOpenHours Error:", err);
|
|
73
71
|
callback();
|
|
@@ -75,7 +73,7 @@ class DirIfOpenHours {
|
|
|
75
73
|
else if (result && result.isopen) {
|
|
76
74
|
if (trueIntent) {
|
|
77
75
|
let intentDirective = DirIntent.intentDirectiveFor(trueIntent);
|
|
78
|
-
|
|
76
|
+
winston.debug("(DirIfOpenHours) (openHours) => trueIntent ");
|
|
79
77
|
this.intentDir.execute(intentDirective, () => {
|
|
80
78
|
callback(stopOnConditionMet);
|
|
81
79
|
});
|
|
@@ -87,7 +85,7 @@ class DirIfOpenHours {
|
|
|
87
85
|
}
|
|
88
86
|
else if (falseIntent) {
|
|
89
87
|
let intentDirective = DirIntent.intentDirectiveFor(falseIntent);
|
|
90
|
-
|
|
88
|
+
winston.debug("(DirIfOpenHours) (openHours) => falseIntent ");
|
|
91
89
|
this.intentDir.execute(intentDirective, () => {
|
|
92
90
|
callback(stopOnConditionMet);
|
|
93
91
|
});
|
|
@@ -204,21 +204,7 @@ class DirMake {
|
|
|
204
204
|
|
|
205
205
|
})
|
|
206
206
|
.catch((err) => {
|
|
207
|
-
|
|
208
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - START
|
|
209
|
-
let cache = [];
|
|
210
|
-
let error_log = JSON.stringify(err, function (key, value) { // try to use a separate function
|
|
211
|
-
if (typeof value === 'object' && value != null) {
|
|
212
|
-
if (cache.indexOf(value) !== -1) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
cache.push(value);
|
|
216
|
-
}
|
|
217
|
-
return value;
|
|
218
|
-
});
|
|
219
|
-
winston.error("(DirMake) An error occurred: ", error_log);
|
|
220
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END;
|
|
221
|
-
}
|
|
207
|
+
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END;
|
|
222
208
|
if (callback) {
|
|
223
209
|
let status = 1000;
|
|
224
210
|
let cache = [];
|
|
@@ -16,7 +16,6 @@ class DirMessage {
|
|
|
16
16
|
this.requestId = context.requestId;
|
|
17
17
|
this.tdcache = this.context.tdcache;
|
|
18
18
|
this.token = context.token;
|
|
19
|
-
this.log = this.context.log;
|
|
20
19
|
this.supportRequest = this.context.supportRequest
|
|
21
20
|
|
|
22
21
|
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
@@ -84,7 +84,7 @@ class DirReply {
|
|
|
84
84
|
let command = commands[i];
|
|
85
85
|
if (command.type === 'message' && command.message && command.message.text) {
|
|
86
86
|
command.message.text = filler.fill(command.message.text, requestAttributes);
|
|
87
|
-
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes
|
|
87
|
+
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes);
|
|
88
88
|
winston.debug("DirReply command filled: " + command.message.text);
|
|
89
89
|
}
|
|
90
90
|
if (command.type === 'settings' && command.settings) {
|
|
@@ -21,6 +21,7 @@ class DirReplyV2 {
|
|
|
21
21
|
this.requestId = context.requestId;
|
|
22
22
|
this.token = context.token;
|
|
23
23
|
this.tdcache = context.tdcache;
|
|
24
|
+
this.intentDir = new DirIntent(context);
|
|
24
25
|
this.chatbot = context.chatbot;
|
|
25
26
|
this.reply = context.reply;
|
|
26
27
|
this.originalMessage = context.message;
|
|
@@ -59,11 +60,10 @@ class DirReplyV2 {
|
|
|
59
60
|
const message = action;
|
|
60
61
|
|
|
61
62
|
let current; // debug only
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
current = message.attributes.commands[1].message.text
|
|
65
|
-
}
|
|
63
|
+
if (message.attributes.commands[1].message.text) {
|
|
64
|
+
current = message.attributes.commands[1].message.text
|
|
66
65
|
}
|
|
66
|
+
|
|
67
67
|
let must_stop = false;
|
|
68
68
|
// fill
|
|
69
69
|
let requestAttributes = null;
|
|
@@ -72,11 +72,9 @@ class DirReplyV2 {
|
|
|
72
72
|
await TiledeskChatbot.allParametersStatic(
|
|
73
73
|
this.tdcache, this.requestId
|
|
74
74
|
);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
75
|
+
// for (const [key, value] of Object.entries(requestAttributes)) {
|
|
76
|
+
// const value_type = typeof value;
|
|
77
|
+
// }
|
|
80
78
|
|
|
81
79
|
TiledeskChatbotUtil.replaceJSONButtons(message, requestAttributes);
|
|
82
80
|
|
|
@@ -195,7 +193,7 @@ class DirReplyV2 {
|
|
|
195
193
|
let command = commands[i];
|
|
196
194
|
if (command.type === 'message' && command.message && command.message.text) {
|
|
197
195
|
command.message.text = filler.fill(command.message.text, requestAttributes);
|
|
198
|
-
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes
|
|
196
|
+
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes);
|
|
199
197
|
}
|
|
200
198
|
}
|
|
201
199
|
}
|
|
@@ -205,9 +205,7 @@ class DirSetAttributeV2 {
|
|
|
205
205
|
httpUtils.request(
|
|
206
206
|
HTTPREQUEST, async (err, resbody) => {
|
|
207
207
|
if (err) {
|
|
208
|
-
|
|
209
|
-
winston.error("(DirSetAttributeV2) persistOnTiledesk() error: ", err);
|
|
210
|
-
}
|
|
208
|
+
winston.error("(DirSetAttributeV2) persistOnTiledesk() error: ", err);
|
|
211
209
|
} else {
|
|
212
210
|
winston.debug("(DirSetAttributeV2) Attributes saved: ", resbody);
|
|
213
211
|
}
|
|
@@ -317,21 +317,7 @@ class DirWebRequestV2 {
|
|
|
317
317
|
}
|
|
318
318
|
})
|
|
319
319
|
.catch((err) => {
|
|
320
|
-
|
|
321
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - START
|
|
322
|
-
let cache = [];
|
|
323
|
-
let error_log = JSON.stringify(err, function (key, value) { // try to use a separate function
|
|
324
|
-
if (typeof value === 'object' && value != null) {
|
|
325
|
-
if (cache.indexOf(value) !== -1) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
cache.push(value);
|
|
329
|
-
}
|
|
330
|
-
return value;
|
|
331
|
-
});
|
|
332
|
-
winston.error("(DirWebRequestv2) An error occurred: ", error_log);
|
|
333
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END
|
|
334
|
-
}
|
|
320
|
+
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END
|
|
335
321
|
if (callback) {
|
|
336
322
|
let status = 1000;
|
|
337
323
|
let cache = [];
|
|
@@ -60,6 +60,7 @@ class Directives {
|
|
|
60
60
|
static ADD_TAGS = 'add_tags'
|
|
61
61
|
static WEB_RESPONSE = "web_response";
|
|
62
62
|
static FLOW_LOG = "flow_log";
|
|
63
|
+
static ADD_KB_CONTENT = "add_kb_content";
|
|
63
64
|
|
|
64
65
|
// static WHEN_ONLINE_MOVE_TO_AGENT = "whenonlinemovetoagent"; // DEPRECATED?
|
|
65
66
|
// static WHEN_OFFLINE_HOURS = "whenofflinehours"; // DEPRECATED // adds a message on top of the original message when offline hours opts: --replace
|