@tiledesk/tiledesk-tybot-connector 2.0.7 → 2.0.8-rc2
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/CHANGELOG.md +34 -0
- package/ExtApi.js +1 -8
- package/ExtUtil.js +5 -6
- package/Logger.js +30 -13
- 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/engine/mock/MockBotsDataSource.js +1 -2
- package/index.js +22 -25
- package/logs/app.log +20243 -7549
- package/logs/app1.log +12807 -0
- package/package.json +3 -2
- package/services/AIService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +24 -18
- 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/DirAddTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAssign.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +4 -6
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirCode.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +2 -5
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirForm.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +36 -55
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +8 -12
- package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -5
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +0 -3
- package/tiledeskChatbotPlugs/directives/DirQapla.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReply.js +7 -18
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -13
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWait.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +0 -39
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +19 -57
- package/TdCache copy.js +0 -242
- package/logs/app2.log +0 -46280
- package/logs/app3.log +0 -31686
- package/logs/app4.log +0 -46163
- package/logs/app5.log +0 -39983
- package/logs/app6.log +0 -5964
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +0 -417
|
@@ -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
|
|
|
@@ -17,17 +18,16 @@ class DirGptTask {
|
|
|
17
18
|
this.requestId = this.context.requestId;
|
|
18
19
|
this.intentDir = new DirIntent(context);
|
|
19
20
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
20
|
-
this.log = context.log;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
execute(directive, callback) {
|
|
24
|
-
|
|
24
|
+
winston.verbose("Execute GptTask directive");
|
|
25
25
|
let action;
|
|
26
26
|
if (directive.action) {
|
|
27
27
|
action = directive.action;
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
|
|
30
|
+
winston.warn("DirGptTask Incorrect directive: ", directive);
|
|
31
31
|
callback();
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
@@ -37,9 +37,9 @@ class DirGptTask {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async go(action, callback) {
|
|
40
|
-
|
|
40
|
+
winston.debug("(DirGptTask) Action: ", action);
|
|
41
41
|
if (!this.tdcache) {
|
|
42
|
-
|
|
42
|
+
winston.error("(DirGptTask) Error: tdcache is mandatory");
|
|
43
43
|
callback();
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -49,18 +49,16 @@ class DirGptTask {
|
|
|
49
49
|
let trueIntentAttributes = action.trueIntentAttributes;
|
|
50
50
|
let falseIntentAttributes = action.falseIntentAttributes;
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log("DirGptTask falseIntentAttributes", falseIntentAttributes)
|
|
57
|
-
}
|
|
52
|
+
winston.debug("(DirGptTask) trueIntent " + trueIntent)
|
|
53
|
+
winston.debug("(DirGptTask) falseIntent " + falseIntent)
|
|
54
|
+
winston.debug("(DirGptTask) trueIntentAttributes " + trueIntentAttributes)
|
|
55
|
+
winston.debug("(DirGptTask) falseIntentAttributes " + falseIntentAttributes)
|
|
58
56
|
|
|
59
57
|
// default value
|
|
60
58
|
let answer = "No answer.";
|
|
61
59
|
|
|
62
60
|
if (!action.question || action.question === '') {
|
|
63
|
-
|
|
61
|
+
winston.debug("(DirGptTask) Error: question attribute is mandatory. Executing condition false...")
|
|
64
62
|
if (falseIntent) {
|
|
65
63
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
66
64
|
callback(true);
|
|
@@ -82,13 +80,11 @@ class DirGptTask {
|
|
|
82
80
|
let max_tokens = action.max_tokens;
|
|
83
81
|
let temperature = action.temperature;
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.log("DirGptTask temperature: ", temperature);
|
|
88
|
-
}
|
|
83
|
+
winston.debug("(DirGptTask) max_tokens: " + max_tokens);
|
|
84
|
+
winston.debug("(DirGptTask) temperature: " + temperature);
|
|
89
85
|
|
|
90
86
|
const openai_url = process.env.OPENAI_ENDPOINT + "/chat/completions";
|
|
91
|
-
|
|
87
|
+
winston.debug("(DirGptTask) openai_url ", openai_url);
|
|
92
88
|
|
|
93
89
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
94
90
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
@@ -98,7 +94,7 @@ class DirGptTask {
|
|
|
98
94
|
},
|
|
99
95
|
method: "GET"
|
|
100
96
|
}
|
|
101
|
-
|
|
97
|
+
winston.debug("(DirGptTask) INTEGRATIONS_HTTPREQUEST ", INTEGRATIONS_HTTPREQUEST);
|
|
102
98
|
|
|
103
99
|
httpUtils.request(
|
|
104
100
|
INTEGRATIONS_HTTPREQUEST, async (err, integration) => {
|
|
@@ -110,7 +106,7 @@ class DirGptTask {
|
|
|
110
106
|
// return;
|
|
111
107
|
}
|
|
112
108
|
} else if (callback) {
|
|
113
|
-
|
|
109
|
+
winston.debug("(DirGptTask) get integration resbody: ", integration);
|
|
114
110
|
|
|
115
111
|
let key;
|
|
116
112
|
if (integration &&
|
|
@@ -121,8 +117,7 @@ class DirGptTask {
|
|
|
121
117
|
// key not present in integrations - for retro compatibility search in kbsettings
|
|
122
118
|
if (!key) {
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
if (this.log) { console.log("DirGptTask - Key not found in Integrations. Searching in kb settings..."); }
|
|
120
|
+
winston.debug("(DirGptTask) Key not found in Integrations. Searching in kb settings...");
|
|
126
121
|
|
|
127
122
|
const KB_HTTPREQUEST = {
|
|
128
123
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kbsettings",
|
|
@@ -132,16 +127,15 @@ class DirGptTask {
|
|
|
132
127
|
},
|
|
133
128
|
method: "GET"
|
|
134
129
|
}
|
|
135
|
-
|
|
130
|
+
winston.debug("(DirGptTask) KB_HTTPREQUEST", KB_HTTPREQUEST);
|
|
136
131
|
|
|
137
132
|
httpUtils.request(
|
|
138
133
|
KB_HTTPREQUEST, async (err, resbody) => {
|
|
139
134
|
if (err) {
|
|
140
135
|
if (callback) {
|
|
141
136
|
console.error("(httprequest) DirGptTask Get KnowledgeBase err:", err.message);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
137
|
+
console.error("(httprequest) DirGptTask Get KnowledgeBase full err", err);
|
|
138
|
+
|
|
145
139
|
await this.#assignAttributes(action, answer);
|
|
146
140
|
if (falseIntent) {
|
|
147
141
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -152,7 +146,7 @@ class DirGptTask {
|
|
|
152
146
|
return;
|
|
153
147
|
}
|
|
154
148
|
} else if (callback) {
|
|
155
|
-
|
|
149
|
+
winston.debug("(DirGptTask) Get KnowledgeBase settings resbody:", resbody);
|
|
156
150
|
|
|
157
151
|
if (!resbody.gptkey) {
|
|
158
152
|
await this.#assignAttributes(action, answer);
|
|
@@ -166,7 +160,7 @@ class DirGptTask {
|
|
|
166
160
|
|
|
167
161
|
} else {
|
|
168
162
|
|
|
169
|
-
|
|
163
|
+
winston.debug("(DirGptTask) Key found in KbSettings");
|
|
170
164
|
|
|
171
165
|
key = resbody.gptkey;
|
|
172
166
|
|
|
@@ -188,7 +182,7 @@ class DirGptTask {
|
|
|
188
182
|
message.content = action.context;
|
|
189
183
|
json.messages.unshift(message);
|
|
190
184
|
}
|
|
191
|
-
|
|
185
|
+
winston.debug("(DirGptTask) json: ", json);
|
|
192
186
|
|
|
193
187
|
const HTTPREQUEST = {
|
|
194
188
|
url: openai_url,
|
|
@@ -199,14 +193,12 @@ class DirGptTask {
|
|
|
199
193
|
json: json,
|
|
200
194
|
method: 'POST'
|
|
201
195
|
}
|
|
202
|
-
|
|
196
|
+
winston.debug("(DirGptTask) HTTPREQUEST: ", HTTPREQUEST);
|
|
203
197
|
httpUtils.request(
|
|
204
198
|
HTTPREQUEST, async (err, resbody) => {
|
|
205
199
|
if (err) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
209
|
-
}
|
|
200
|
+
console.error("(httprequest) DirGptTask openai err:", err);
|
|
201
|
+
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
210
202
|
await this.#assignAttributes(action, answer);
|
|
211
203
|
if (falseIntent) {
|
|
212
204
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -216,7 +208,7 @@ class DirGptTask {
|
|
|
216
208
|
callback();
|
|
217
209
|
return;
|
|
218
210
|
} else {
|
|
219
|
-
|
|
211
|
+
winston.debug("(DirGptTask) resbody: ", JSON.stringify(resbody));
|
|
220
212
|
answer = resbody.choices[0].message.content;
|
|
221
213
|
let answer_json = await this.convertToJson(answer);
|
|
222
214
|
await this.#assignAttributes(action, answer_json);
|
|
@@ -236,7 +228,7 @@ class DirGptTask {
|
|
|
236
228
|
)
|
|
237
229
|
} else {
|
|
238
230
|
|
|
239
|
-
|
|
231
|
+
winston.debug("(DirGptTask) Key found in Integrations");
|
|
240
232
|
|
|
241
233
|
let json = {
|
|
242
234
|
"model": action.model,
|
|
@@ -256,7 +248,7 @@ class DirGptTask {
|
|
|
256
248
|
message.content = action.context;
|
|
257
249
|
json.messages.unshift(message);
|
|
258
250
|
}
|
|
259
|
-
|
|
251
|
+
winston.debug("(DirGptTask) json: ", json);
|
|
260
252
|
|
|
261
253
|
const HTTPREQUEST = {
|
|
262
254
|
url: openai_url,
|
|
@@ -267,14 +259,12 @@ class DirGptTask {
|
|
|
267
259
|
json: json,
|
|
268
260
|
method: 'POST'
|
|
269
261
|
}
|
|
270
|
-
|
|
262
|
+
winston.debug("(DirGptTask) HTTPREQUEST: ", HTTPREQUEST);
|
|
271
263
|
httpUtils.request(
|
|
272
264
|
HTTPREQUEST, async (err, resbody) => {
|
|
273
265
|
if (err) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
277
|
-
}
|
|
266
|
+
console.error("(httprequest) DirGptTask openai err:", err);
|
|
267
|
+
console.error("(httprequest) DirGptTask openai err:", err.response.data);
|
|
278
268
|
await this.#assignAttributes(action, answer);
|
|
279
269
|
if (falseIntent) {
|
|
280
270
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -284,7 +274,7 @@ class DirGptTask {
|
|
|
284
274
|
callback();
|
|
285
275
|
return;
|
|
286
276
|
} else {
|
|
287
|
-
|
|
277
|
+
winston.debug("(DirGptTask) resbody: ", JSON.stringify(resbody));
|
|
288
278
|
answer = resbody.choices[0].message.content;
|
|
289
279
|
// check if answer is a json
|
|
290
280
|
let answer_json = await this.convertToJson(answer);
|
|
@@ -338,7 +328,7 @@ class DirGptTask {
|
|
|
338
328
|
})
|
|
339
329
|
}
|
|
340
330
|
else {
|
|
341
|
-
|
|
331
|
+
winston.debug("(DirGptTask) No trueIntentDirective specified");
|
|
342
332
|
if (callback) {
|
|
343
333
|
callback();
|
|
344
334
|
}
|
|
@@ -353,7 +343,7 @@ class DirGptTask {
|
|
|
353
343
|
});
|
|
354
344
|
}
|
|
355
345
|
else {
|
|
356
|
-
|
|
346
|
+
winston.debug("(DirGptTask) No falseIntentDirective specified");
|
|
357
347
|
if (callback) {
|
|
358
348
|
callback();
|
|
359
349
|
}
|
|
@@ -362,10 +352,8 @@ class DirGptTask {
|
|
|
362
352
|
}
|
|
363
353
|
|
|
364
354
|
async #assignAttributes(action, answer) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
console.log("assignAttributes answer:", answer)
|
|
368
|
-
}
|
|
355
|
+
winston.debug("(DirGptTask) assignAttributes action:", action)
|
|
356
|
+
winston.debug("(DirGptTask) assignAttributes answer:", answer)
|
|
369
357
|
if (this.context.tdcache) {
|
|
370
358
|
if (action.assignReplyTo && answer) {
|
|
371
359
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, action.assignReplyTo, answer);
|
|
@@ -373,13 +361,6 @@ class DirGptTask {
|
|
|
373
361
|
// if (action.assignSourceTo && source) {
|
|
374
362
|
// await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, action.assignSourceTo, source);
|
|
375
363
|
// }
|
|
376
|
-
// Debug log
|
|
377
|
-
if (this.log) {
|
|
378
|
-
const all_parameters = await TiledeskChatbot.allParametersStatic(this.context.tdcache, this.context.requestId);
|
|
379
|
-
for (const [key, value] of Object.entries(all_parameters)) {
|
|
380
|
-
if (this.log) { console.log("(gpttask) request parameter:", key, "value:", value, "type:", typeof value) }
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
364
|
}
|
|
384
365
|
}
|
|
385
366
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
3
2
|
const { DirIntent } = require('./DirIntent');
|
|
4
3
|
const ms = require('minimist-string');
|
|
@@ -14,14 +13,12 @@ class DirIfOnlineAgents {
|
|
|
14
13
|
this.context = context;
|
|
15
14
|
this.intentDir = new DirIntent(context);
|
|
16
15
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
|
-
this.log = context.log;
|
|
18
16
|
|
|
19
17
|
this.tdClient = new TiledeskClient({
|
|
20
18
|
projectId: this.context.projectId,
|
|
21
19
|
token: this.context.token,
|
|
22
20
|
APIURL: this.API_ENDPOINT,
|
|
23
|
-
APIKEY: "___"
|
|
24
|
-
log: this.log
|
|
21
|
+
APIKEY: "___"
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
|
|
@@ -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");
|
|
@@ -17,14 +16,12 @@ class DirIfOnlineAgentsV2 {
|
|
|
17
16
|
this.chatbot = context.chatbot;
|
|
18
17
|
this.intentDir = new DirIntent(context);
|
|
19
18
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
|
-
this.log = context.log;
|
|
21
19
|
|
|
22
20
|
this.tdClient = new TiledeskClient({
|
|
23
21
|
projectId: this.context.projectId,
|
|
24
22
|
token: this.context.token,
|
|
25
23
|
APIURL: this.API_ENDPOINT,
|
|
26
24
|
APIKEY: "___",
|
|
27
|
-
log: this.log
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
}
|
|
@@ -206,7 +203,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
206
203
|
}
|
|
207
204
|
resolve(resbody);
|
|
208
205
|
}
|
|
209
|
-
}
|
|
206
|
+
});
|
|
210
207
|
});
|
|
211
208
|
|
|
212
209
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
let axios = require('axios');
|
|
3
2
|
const { DirIntent } = require('./DirIntent');
|
|
4
3
|
let https = require("https");
|
|
@@ -16,7 +15,6 @@ class DirIfOpenHours {
|
|
|
16
15
|
this.context = context;
|
|
17
16
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
18
17
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.log = context.log;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
execute(directive, callback) {
|
|
@@ -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
|
|
|
@@ -11,15 +12,13 @@ class DirIfOpenHours {
|
|
|
11
12
|
|
|
12
13
|
this.context = context;
|
|
13
14
|
this.intentDir = new DirIntent(context);
|
|
14
|
-
this.log = context.log;
|
|
15
15
|
|
|
16
16
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
17
|
this.tdClient = new TiledeskClient({
|
|
18
18
|
projectId: this.context.projectId,
|
|
19
19
|
token: this.context.token,
|
|
20
20
|
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___"
|
|
22
|
-
log: this.log
|
|
21
|
+
APIKEY: "___"
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -32,9 +31,6 @@ class DirIfOpenHours {
|
|
|
32
31
|
let params;
|
|
33
32
|
params = this.parseParams(directive.parameter);
|
|
34
33
|
if (!params.trueIntent && !params.falseIntent) {
|
|
35
|
-
if (this.log) {
|
|
36
|
-
console.log("missing both params.trueIntent & params.falseIntent");
|
|
37
|
-
}
|
|
38
34
|
callback();
|
|
39
35
|
return;
|
|
40
36
|
}
|
|
@@ -66,14 +62,14 @@ class DirIfOpenHours {
|
|
|
66
62
|
if (falseIntent && falseIntent.trim() === "") {
|
|
67
63
|
falseIntent = null;
|
|
68
64
|
}
|
|
69
|
-
|
|
65
|
+
winston.verbose("(DirIfOpenHours) Action:", action);
|
|
70
66
|
if (!trueIntent && !falseIntent) {
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
winston.error("(DirIfOpenHours) Error: missing both action.trueIntent & action.falseIntent");
|
|
68
|
+
callback();
|
|
73
69
|
return;
|
|
74
70
|
}
|
|
75
71
|
this.tdClient.openNow((err, result) => {
|
|
76
|
-
|
|
72
|
+
winston.error("(DirIfOpenHours) openNow():", result)
|
|
77
73
|
if (err) {
|
|
78
74
|
console.error("*** DirIfOpenHours Error:", err);
|
|
79
75
|
callback();
|
|
@@ -81,7 +77,7 @@ class DirIfOpenHours {
|
|
|
81
77
|
else if (result && result.isopen) {
|
|
82
78
|
if (trueIntent) {
|
|
83
79
|
let intentDirective = DirIntent.intentDirectiveFor(trueIntent);
|
|
84
|
-
|
|
80
|
+
winston.debug("(DirIfOpenHours) (openHours) => trueIntent ");
|
|
85
81
|
this.intentDir.execute(intentDirective, () => {
|
|
86
82
|
callback(stopOnConditionMet);
|
|
87
83
|
});
|
|
@@ -93,7 +89,7 @@ class DirIfOpenHours {
|
|
|
93
89
|
}
|
|
94
90
|
else if (falseIntent) {
|
|
95
91
|
let intentDirective = DirIntent.intentDirectiveFor(falseIntent);
|
|
96
|
-
|
|
92
|
+
winston.debug("(DirIfOpenHours) (openHours) => falseIntent ");
|
|
97
93
|
this.intentDir.execute(intentDirective, () => {
|
|
98
94
|
callback(stopOnConditionMet);
|
|
99
95
|
});
|
|
@@ -16,7 +16,6 @@ class DirIntent {
|
|
|
16
16
|
this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
|
|
17
17
|
this.supportRequest = context.supportRequest;
|
|
18
18
|
this.token = context.token;
|
|
19
|
-
this.log = context.log;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
execute(directive, callback) {
|
|
@@ -62,10 +61,12 @@ class DirIntent {
|
|
|
62
61
|
"recipient": requestId,
|
|
63
62
|
"text": intent_command,
|
|
64
63
|
"id_project": projectId,
|
|
65
|
-
"request":
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
"request": this.supportRequest,
|
|
65
|
+
// "request": {
|
|
66
|
+
// "request_id": requestId,
|
|
67
|
+
// "id_project": projectId
|
|
68
|
+
// // "bot_id": botId
|
|
69
|
+
// }
|
|
69
70
|
},
|
|
70
71
|
"token": this.token
|
|
71
72
|
}
|
|
@@ -16,7 +16,6 @@ class DirMake {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.log = context.log;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
execute(directive, callback) {
|
|
@@ -199,21 +198,7 @@ class DirMake {
|
|
|
199
198
|
|
|
200
199
|
})
|
|
201
200
|
.catch((err) => {
|
|
202
|
-
|
|
203
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - START
|
|
204
|
-
let cache = [];
|
|
205
|
-
let error_log = JSON.stringify(err, function (key, value) { // try to use a separate function
|
|
206
|
-
if (typeof value === 'object' && value != null) {
|
|
207
|
-
if (cache.indexOf(value) !== -1) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
cache.push(value);
|
|
211
|
-
}
|
|
212
|
-
return value;
|
|
213
|
-
});
|
|
214
|
-
winston.error("(DirMake) An error occurred: ", error_log);
|
|
215
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END;
|
|
216
|
-
}
|
|
201
|
+
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END;
|
|
217
202
|
if (callback) {
|
|
218
203
|
let status = 1000;
|
|
219
204
|
let cache = [];
|
|
@@ -16,15 +16,13 @@ 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({
|
|
23
22
|
projectId: this.context.projectId,
|
|
24
23
|
token: this.context.token,
|
|
25
24
|
APIURL: this.API_ENDPOINT,
|
|
26
|
-
APIKEY: "___"
|
|
27
|
-
log: this.log
|
|
25
|
+
APIKEY: "___"
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { Directives } = require('./Directives');
|
|
3
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
3
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
@@ -14,15 +13,13 @@ class DirMoveToAgent {
|
|
|
14
13
|
this.context = context;
|
|
15
14
|
this.tdcache = context.tdcache;
|
|
16
15
|
this.requestId = context.requestId;
|
|
17
|
-
this.log = context.log;
|
|
18
16
|
|
|
19
17
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
18
|
this.tdClient = new TiledeskClient({
|
|
21
19
|
projectId: this.context.projectId,
|
|
22
20
|
token: this.context.token,
|
|
23
21
|
APIURL: this.API_ENDPOINT,
|
|
24
|
-
APIKEY: "___"
|
|
25
|
-
log: this.log
|
|
22
|
+
APIKEY: "___"
|
|
26
23
|
});
|
|
27
24
|
|
|
28
25
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { Directives } = require('./Directives');
|
|
3
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
3
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
@@ -13,7 +12,6 @@ class DirMoveToUnassigned {
|
|
|
13
12
|
}
|
|
14
13
|
this.context = context;
|
|
15
14
|
this.requestId = context.requestId;
|
|
16
|
-
this.log = context.log;
|
|
17
15
|
|
|
18
16
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
19
17
|
this.tdClient = new TiledeskClient({
|
|
@@ -21,7 +19,6 @@ class DirMoveToUnassigned {
|
|
|
21
19
|
token: this.context.token,
|
|
22
20
|
APIURL: this.API_ENDPOINT,
|
|
23
21
|
APIKEY: "___",
|
|
24
|
-
log: this.log
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
|
|
@@ -15,15 +15,13 @@ class DirRandomReply {
|
|
|
15
15
|
this.requestId = context.requestId;
|
|
16
16
|
this.token = context.token;
|
|
17
17
|
this.tdcache = context.tdcache;
|
|
18
|
-
this.log = context.log;
|
|
19
18
|
|
|
20
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
21
20
|
this.tdClient = new TiledeskClient({
|
|
22
21
|
projectId: this.context.projectId,
|
|
23
22
|
token: this.context.token,
|
|
24
23
|
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___"
|
|
26
|
-
log: this.log
|
|
24
|
+
APIKEY: "___"
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -11,15 +11,13 @@ class DirReplaceBot {
|
|
|
11
11
|
}
|
|
12
12
|
this.context = context;
|
|
13
13
|
this.requestId = context.requestId;
|
|
14
|
-
this.log = context.log;
|
|
15
14
|
|
|
16
15
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
16
|
this.tdClient = new TiledeskClient({
|
|
18
17
|
projectId: this.context.projectId,
|
|
19
18
|
token: this.context.token,
|
|
20
19
|
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___"
|
|
22
|
-
log: this.log
|
|
20
|
+
APIKEY: "___"
|
|
23
21
|
});
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -15,15 +15,13 @@ class DirReplaceBotV2 {
|
|
|
15
15
|
}
|
|
16
16
|
this.context = context;
|
|
17
17
|
this.requestId = context.requestId;
|
|
18
|
-
this.log = context.log;
|
|
19
18
|
|
|
20
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
21
20
|
this.tdClient = new TiledeskClient({
|
|
22
21
|
projectId: this.context.projectId,
|
|
23
22
|
token: this.context.token,
|
|
24
23
|
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___"
|
|
26
|
-
log: this.log
|
|
24
|
+
APIKEY: "___"
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -15,15 +15,13 @@ class DirReplaceBotV3 {
|
|
|
15
15
|
}
|
|
16
16
|
this.context = context;
|
|
17
17
|
this.requestId = context.requestId;
|
|
18
|
-
this.log = context.log;
|
|
19
18
|
|
|
20
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
21
20
|
this.tdClient = new TiledeskClient({
|
|
22
21
|
projectId: this.context.projectId,
|
|
23
22
|
token: this.context.token,
|
|
24
23
|
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___"
|
|
26
|
-
log: this.log
|
|
24
|
+
APIKEY: "___"
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|