@tiledesk/tiledesk-tybot-connector 2.0.17 → 2.0.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/CHANGELOG.md +1 -1
- package/Logger.js +11 -4
- package/logs/app.log +6791 -44726
- package/logs/app4.log +46163 -0
- package/logs/app5.log +39983 -0
- package/logs/app6.log +50376 -0
- package/logs/app7.log +43568 -0
- package/logs/app8.log +4779 -0
- package/package.json +2 -2
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +20 -21
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +5 -6
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +7 -8
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +50 -21
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +4 -5
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirClose.js +2 -3
- package/tiledeskChatbotPlugs/directives/DirCode.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirCondition.js +3 -4
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +3 -4
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +5 -5
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +4 -5
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +3 -4
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +4 -5
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirQapla.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReply.js +4 -5
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirWait.js +2 -3
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +7 -8
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +2 -3
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -2
- package/logs/app1.log +0 -16653
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-tybot-connector",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
4
4
|
"description": "Tiledesk Tybot connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@tiledesk/tiledesk-chatbot-client": "^0.5.30",
|
|
16
16
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.39",
|
|
17
17
|
"@tiledesk/tiledesk-client": "^0.10.13",
|
|
18
|
-
"@tiledesk/tiledesk-multi-worker": "^0.3.1
|
|
18
|
+
"@tiledesk/tiledesk-multi-worker": "^0.3.1",
|
|
19
19
|
"accept-language-parser": "^1.5.0",
|
|
20
20
|
"app-root-path": "^3.1.0",
|
|
21
21
|
"axios": "^1.7.7",
|
|
@@ -32,20 +32,19 @@ class DirAddKbContent {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
execute(directive, callback) {
|
|
35
|
-
|
|
36
|
-
winston.debug("DirAskGPTV2 directive: ", directive);
|
|
35
|
+
winston.debug("DirAddKbContent directive: ", directive);
|
|
37
36
|
let action;
|
|
38
37
|
if (directive.action) {
|
|
39
38
|
action = directive.action;
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
41
|
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
43
|
-
winston.debug("
|
|
42
|
+
winston.debug("DirAddKbContent Incorrect directive: ", directive);
|
|
44
43
|
callback();
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
this.go(action, (stop) => {
|
|
48
|
-
this.logger.
|
|
47
|
+
this.logger.native("[Add to KnwoledgeBase] Executed");
|
|
49
48
|
callback(stop);
|
|
50
49
|
})
|
|
51
50
|
}
|
|
@@ -86,7 +85,7 @@ class DirAddKbContent {
|
|
|
86
85
|
|
|
87
86
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
88
87
|
if (!key) {
|
|
89
|
-
this.logger.
|
|
88
|
+
this.logger.native("[Add to KnwoledgeBase] OpenAI key not found in Integration. Using shared OpenAI key");
|
|
90
89
|
winston.verbose("[DirAddKbContent] - Key not found in Integrations. Searching in kb settings...");
|
|
91
90
|
key = await this.getKeyFromKbSettings();
|
|
92
91
|
}
|
|
@@ -96,7 +95,7 @@ class DirAddKbContent {
|
|
|
96
95
|
key = process.env.GPTKEY;
|
|
97
96
|
publicKey = true;
|
|
98
97
|
} else {
|
|
99
|
-
this.logger.
|
|
98
|
+
this.logger.native("[Add to KnwoledgeBase] Use your own OpenAI key")
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
if (!key) {
|
|
@@ -109,7 +108,7 @@ class DirAddKbContent {
|
|
|
109
108
|
if (publicKey === true) {
|
|
110
109
|
let keep_going = await this.checkQuoteAvailability();
|
|
111
110
|
if (keep_going === false) {
|
|
112
|
-
this.logger.warn("[
|
|
111
|
+
this.logger.warn("[Add to KnwoledgeBase] Tokens quota exceeded. Skip the action")
|
|
113
112
|
winston.verbose("[DirAddKbContent] - Quota exceeded for tokens. Skip the action")
|
|
114
113
|
await this.chatbot.addParameter("flowError", "[DirAddKbContent] Error: tokens quota exceeded");
|
|
115
114
|
callback(true);
|
|
@@ -122,17 +121,17 @@ class DirAddKbContent {
|
|
|
122
121
|
if (action.namespaceAsName) {
|
|
123
122
|
// Namespace could be an attribute
|
|
124
123
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
125
|
-
this.logger.
|
|
124
|
+
this.logger.native("[Add to KnwoledgeBase] Searching namespace by name ", filled_namespace);
|
|
126
125
|
ns = await this.getNamespace(filled_namespace, null);
|
|
127
126
|
namespace = ns?.id;
|
|
128
127
|
winston.verbose("[DirAddKbContent] - Retrieved namespace id from name " + namespace);
|
|
129
128
|
} else {
|
|
130
|
-
this.logger.
|
|
129
|
+
this.logger.native("[Add to KnwoledgeBase] Searching namespace by id ", namespace);
|
|
131
130
|
ns = await this.getNamespace(null, namespace);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
if (!ns) {
|
|
135
|
-
this.logger.error("[
|
|
134
|
+
this.logger.error("[Add to KnwoledgeBase] Namespace not found");
|
|
136
135
|
await this.chatbot.addParameter("flowError", "[DirAddKbContent] Error: namespace not found");
|
|
137
136
|
callback();
|
|
138
137
|
return;
|
|
@@ -145,7 +144,7 @@ class DirAddKbContent {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
if (!namespace) {
|
|
148
|
-
this.logger.error("[
|
|
147
|
+
this.logger.error("[Add to KnwoledgeBase] Namespace is undefined")
|
|
149
148
|
winston.verbose("[DirAddKbContent] - Error: namespace is undefined")
|
|
150
149
|
await this.chatbot.addParameter("flowError", "[DirAddKbContent] Error: namespace is undefined");
|
|
151
150
|
callback(true);
|
|
@@ -177,7 +176,7 @@ class DirAddKbContent {
|
|
|
177
176
|
HTTPREQUEST, async (err, resbody) => {
|
|
178
177
|
|
|
179
178
|
if (err) {
|
|
180
|
-
this.logger.error("[
|
|
179
|
+
this.logger.error("[Add to KnwoledgeBase] error: " + JSON.stringify(err?.response));
|
|
181
180
|
winston.error("[DirAddKbContent] error: ", err?.response);
|
|
182
181
|
if (callback) {
|
|
183
182
|
callback();
|
|
@@ -207,12 +206,12 @@ class DirAddKbContent {
|
|
|
207
206
|
},
|
|
208
207
|
method: "GET"
|
|
209
208
|
}
|
|
210
|
-
winston.debug("
|
|
209
|
+
winston.debug("DirAddKbContent KB HttpRequest", KB_HTTPREQUEST);
|
|
211
210
|
|
|
212
211
|
httpUtils.request(
|
|
213
212
|
KB_HTTPREQUEST, async (err, resbody) => {
|
|
214
213
|
if (err) {
|
|
215
|
-
winston.error("
|
|
214
|
+
winston.error("DirAddKbContent Get kb settings error ", err?.response?.data);
|
|
216
215
|
resolve(null);
|
|
217
216
|
} else {
|
|
218
217
|
if (!resbody.gptkey) {
|
|
@@ -237,12 +236,12 @@ class DirAddKbContent {
|
|
|
237
236
|
},
|
|
238
237
|
method: "GET"
|
|
239
238
|
}
|
|
240
|
-
winston.debug("
|
|
239
|
+
winston.debug("DirAddKbContent check quote availability HttpRequest", HTTPREQUEST);
|
|
241
240
|
|
|
242
241
|
httpUtils.request(
|
|
243
242
|
HTTPREQUEST, async (err, resbody) => {
|
|
244
243
|
if (err) {
|
|
245
|
-
winston.error("
|
|
244
|
+
winston.error("DirAddKbContent Check quote availability err: ", err);
|
|
246
245
|
resolve(true)
|
|
247
246
|
} else {
|
|
248
247
|
if (resbody.isAvailable === true) {
|
|
@@ -268,12 +267,12 @@ class DirAddKbContent {
|
|
|
268
267
|
json: tokens_usage,
|
|
269
268
|
method: "POST"
|
|
270
269
|
}
|
|
271
|
-
winston.debug("
|
|
270
|
+
winston.debug("DirAddKbContent update quote HttpRequest ", HTTPREQUEST);
|
|
272
271
|
|
|
273
272
|
httpUtils.request(
|
|
274
273
|
HTTPREQUEST, async (err, resbody) => {
|
|
275
274
|
if (err) {
|
|
276
|
-
winston.error("
|
|
275
|
+
winston.error("DirAddKbContent Increment tokens quote err: ", err);
|
|
277
276
|
reject(false)
|
|
278
277
|
} else {
|
|
279
278
|
resolve(true);
|
|
@@ -293,14 +292,14 @@ class DirAddKbContent {
|
|
|
293
292
|
},
|
|
294
293
|
method: "GET"
|
|
295
294
|
}
|
|
296
|
-
winston.debug("
|
|
295
|
+
winston.debug("DirAddKbContent get all namespaces HttpRequest", HTTPREQUEST);
|
|
297
296
|
httpUtils.request(
|
|
298
297
|
HTTPREQUEST, async (err, namespaces) => {
|
|
299
298
|
if (err) {
|
|
300
|
-
winston.error("
|
|
299
|
+
winston.error("DirAddKbContent get all namespaces err: ", err);
|
|
301
300
|
resolve(null)
|
|
302
301
|
} else {
|
|
303
|
-
winston.debug("
|
|
302
|
+
winston.debug("DirAddKbContent get all namespaces resbody: ", namespaces);
|
|
304
303
|
if (name) {
|
|
305
304
|
let namespace = namespaces.find(n => n.name === name);
|
|
306
305
|
resolve(namespace);
|
|
@@ -30,7 +30,6 @@ class DirAddTags {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
execute(directive, callback) {
|
|
33
|
-
this.logger.info("[Add Tag] Executing action")
|
|
34
33
|
winston.verbose("Execute AddTags action");
|
|
35
34
|
let action;
|
|
36
35
|
if (directive.action) {
|
|
@@ -43,7 +42,7 @@ class DirAddTags {
|
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
this.go(action, (stop) => {
|
|
46
|
-
this.logger.
|
|
45
|
+
this.logger.native("[Add Tag] Executed");
|
|
47
46
|
callback(stop);
|
|
48
47
|
})
|
|
49
48
|
}
|
|
@@ -85,7 +84,7 @@ class DirAddTags {
|
|
|
85
84
|
if(target === 'request'){
|
|
86
85
|
|
|
87
86
|
let newTags = filled_tags.split(',').filter(tag => tag !== '').map(el => el.trim())
|
|
88
|
-
this.logger.
|
|
87
|
+
this.logger.native("[Add Tag] Adding following tags to conversation: ", newTags)
|
|
89
88
|
|
|
90
89
|
if(action.pushToList){
|
|
91
90
|
newTags.forEach(async (tag) => {
|
|
@@ -99,7 +98,7 @@ class DirAddTags {
|
|
|
99
98
|
|
|
100
99
|
winston.debug('(DirAddTags) UPDATE request with newTags', newTags)
|
|
101
100
|
let updatedRequest = await this.updateRequestWithTags(newTags)
|
|
102
|
-
this.logger.
|
|
101
|
+
this.logger.native("[Add Tag] Tags added to conversation")
|
|
103
102
|
if(!updatedRequest){
|
|
104
103
|
callback();
|
|
105
104
|
return;
|
|
@@ -110,7 +109,7 @@ class DirAddTags {
|
|
|
110
109
|
/** use case: LEAD */
|
|
111
110
|
if(target === 'lead'){
|
|
112
111
|
let newTags = filled_tags.split(',').filter(tag => tag !== '').map(el => el.trim())
|
|
113
|
-
this.logger.
|
|
112
|
+
this.logger.native("[Add Tag] Adding following tags to lead: ", newTags)
|
|
114
113
|
|
|
115
114
|
let request = await this.tdClient.getRequestById(this.requestId);
|
|
116
115
|
winston.debug('(DirAddTags) request detail: ', request)
|
|
@@ -132,7 +131,7 @@ class DirAddTags {
|
|
|
132
131
|
|
|
133
132
|
winston.debug('(DirAddTags) UPDATE lead with newTags ', newTags)
|
|
134
133
|
let updatedLead = await this.updateLeadWithTags(request.lead._id, newTags)
|
|
135
|
-
this.logger.
|
|
134
|
+
this.logger.native("[Add Tag] Tags added to lead")
|
|
136
135
|
if(!updatedLead){
|
|
137
136
|
callback();
|
|
138
137
|
return;
|
|
@@ -33,7 +33,6 @@ class DirAiPrompt {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
execute(directive, callback) {
|
|
36
|
-
this.logger.info("[AI Prompt] Executing action");
|
|
37
36
|
winston.verbose("Execute AiPrompt directive");
|
|
38
37
|
let action;
|
|
39
38
|
if (directive.action) {
|
|
@@ -46,7 +45,7 @@ class DirAiPrompt {
|
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
this.go(action, (stop) => {
|
|
49
|
-
this.logger.
|
|
48
|
+
this.logger.native("[AI Prompt] Executed");
|
|
50
49
|
callback(stop);
|
|
51
50
|
})
|
|
52
51
|
}
|
|
@@ -92,7 +91,7 @@ class DirAiPrompt {
|
|
|
92
91
|
const filled_context = filler.fill(action.context, requestVariables);
|
|
93
92
|
|
|
94
93
|
if (action.history) {
|
|
95
|
-
this.logger.
|
|
94
|
+
this.logger.native("[AI Prompt] using chat transcript");
|
|
96
95
|
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
97
96
|
this.context.tdcache,
|
|
98
97
|
this.context.requestId,
|
|
@@ -212,7 +211,7 @@ class DirAiPrompt {
|
|
|
212
211
|
|
|
213
212
|
winston.debug("DirAiPrompt resbody: ", resbody);
|
|
214
213
|
answer = resbody.answer;
|
|
215
|
-
this.logger.
|
|
214
|
+
this.logger.native("[AI Prompt] answer: ", answer);
|
|
216
215
|
|
|
217
216
|
await this.#assignAttributes(action, answer);
|
|
218
217
|
|
|
@@ -300,7 +299,7 @@ class DirAiPrompt {
|
|
|
300
299
|
}
|
|
301
300
|
if (result === true) {
|
|
302
301
|
if (trueIntentDirective) {
|
|
303
|
-
this.logger.
|
|
302
|
+
this.logger.native("[AI Prompt] executing true condition");
|
|
304
303
|
this.intentDir.execute(trueIntentDirective, () => {
|
|
305
304
|
if (callback) {
|
|
306
305
|
callback();
|
|
@@ -308,7 +307,7 @@ class DirAiPrompt {
|
|
|
308
307
|
})
|
|
309
308
|
}
|
|
310
309
|
else {
|
|
311
|
-
this.logger.
|
|
310
|
+
this.logger.native("[AI Prompt] no block connected to true condition");
|
|
312
311
|
winston.debug("DirAiPrompt No trueIntentDirective specified");
|
|
313
312
|
if (callback) {
|
|
314
313
|
callback();
|
|
@@ -317,7 +316,7 @@ class DirAiPrompt {
|
|
|
317
316
|
}
|
|
318
317
|
else {
|
|
319
318
|
if (falseIntentDirective) {
|
|
320
|
-
this.logger.
|
|
319
|
+
this.logger.native("[AI Prompt] executing false condition");
|
|
321
320
|
this.intentDir.execute(falseIntentDirective, () => {
|
|
322
321
|
if (callback) {
|
|
323
322
|
callback();
|
|
@@ -325,7 +324,7 @@ class DirAiPrompt {
|
|
|
325
324
|
});
|
|
326
325
|
}
|
|
327
326
|
else {
|
|
328
|
-
this.logger.
|
|
327
|
+
this.logger.native("[AI Prompt] no block connected to false condition");
|
|
329
328
|
winston.debug("DirAiPrompt No falseIntentDirective specified");
|
|
330
329
|
if (callback) {
|
|
331
330
|
callback();
|
|
@@ -31,7 +31,6 @@ class DirAskGPTV2 {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
execute(directive, callback) {
|
|
34
|
-
this.logger.info("[Ask Knowledge Base] Executing action");
|
|
35
34
|
winston.debug("DirAskGPTV2 directive: ", directive);
|
|
36
35
|
let action;
|
|
37
36
|
if (directive.action) {
|
|
@@ -44,7 +43,7 @@ class DirAskGPTV2 {
|
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
this.go(action, (stop) => {
|
|
47
|
-
this.logger.
|
|
46
|
+
this.logger.native("[Ask Knowledge Base] Executed");
|
|
48
47
|
callback(stop);
|
|
49
48
|
})
|
|
50
49
|
}
|
|
@@ -76,8 +75,10 @@ class DirAskGPTV2 {
|
|
|
76
75
|
let temperature;
|
|
77
76
|
let max_tokens;
|
|
78
77
|
let top_k;
|
|
78
|
+
let alpha;
|
|
79
79
|
let transcript;
|
|
80
80
|
let citations = false;
|
|
81
|
+
let chunks_only = false;
|
|
81
82
|
let engine;
|
|
82
83
|
//let default_context = "You are an helpful assistant for question-answering tasks.\nUse ONLY the following pieces of retrieved context to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf none of the retrieved context answer the question, add this word to the end <NOANS>\n\n{context}";
|
|
83
84
|
|
|
@@ -124,10 +125,18 @@ class DirAskGPTV2 {
|
|
|
124
125
|
max_tokens = action.max_tokens;
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
if (action.alpha) {
|
|
129
|
+
alpha = action.alpha;
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
if (action.citations) {
|
|
128
133
|
citations = action.citations;
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
if (action.chunks_only) {
|
|
137
|
+
chunks_only = action.chunks_only;
|
|
138
|
+
}
|
|
139
|
+
|
|
131
140
|
let requestVariables = null;
|
|
132
141
|
requestVariables =
|
|
133
142
|
await TiledeskChatbot.allParametersStatic(
|
|
@@ -139,7 +148,7 @@ class DirAskGPTV2 {
|
|
|
139
148
|
const filled_context = filler.fill(action.context, requestVariables)
|
|
140
149
|
|
|
141
150
|
if (action.history) {
|
|
142
|
-
this.logger.
|
|
151
|
+
this.logger.native("[Ask Knowledge Base] use chat transcript")
|
|
143
152
|
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
144
153
|
this.context.tdcache,
|
|
145
154
|
this.context.requestId,
|
|
@@ -161,7 +170,7 @@ class DirAskGPTV2 {
|
|
|
161
170
|
|
|
162
171
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
163
172
|
if (!key) {
|
|
164
|
-
this.logger.
|
|
173
|
+
this.logger.native("[Ask Knowledge Base] OpenAI key not found in Integration. Using shared OpenAI key");
|
|
165
174
|
winston.verbose("DirAskGPTV2 - Key not found in Integrations. Searching in kb settings...");
|
|
166
175
|
key = await this.getKeyFromKbSettings();
|
|
167
176
|
}
|
|
@@ -171,7 +180,7 @@ class DirAskGPTV2 {
|
|
|
171
180
|
key = process.env.GPTKEY;
|
|
172
181
|
publicKey = true;
|
|
173
182
|
} else {
|
|
174
|
-
this.logger.
|
|
183
|
+
this.logger.native("[Ask Knowledge Base] use your own OpenAI key")
|
|
175
184
|
}
|
|
176
185
|
|
|
177
186
|
if (!key) {
|
|
@@ -186,7 +195,7 @@ class DirAskGPTV2 {
|
|
|
186
195
|
return;
|
|
187
196
|
}
|
|
188
197
|
|
|
189
|
-
if (publicKey === true) {
|
|
198
|
+
if (publicKey === true && !chunks_only) {
|
|
190
199
|
let keep_going = await this.checkQuoteAvailability();
|
|
191
200
|
if (keep_going === false) {
|
|
192
201
|
this.logger.warn("[Ask Knowledge Base] Tokens quota exceeded. Skip the action")
|
|
@@ -203,12 +212,12 @@ class DirAskGPTV2 {
|
|
|
203
212
|
if (action.namespaceAsName) {
|
|
204
213
|
// Namespace could be an attribute
|
|
205
214
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
206
|
-
this.logger.
|
|
215
|
+
this.logger.native("[Ask Knowledge Base] Searching namespace by name ", filled_namespace);
|
|
207
216
|
ns = await this.getNamespace(filled_namespace, null);
|
|
208
217
|
namespace = ns?.id;
|
|
209
218
|
winston.verbose("DirAskGPTV2 - Retrieved namespace id from name " + namespace);
|
|
210
219
|
} else {
|
|
211
|
-
this.logger.
|
|
220
|
+
this.logger.native("[Ask Knowledge Base] Searching namespace by id ", namespace);
|
|
212
221
|
ns = await this.getNamespace(null, namespace);
|
|
213
222
|
}
|
|
214
223
|
|
|
@@ -260,7 +269,15 @@ class DirAskGPTV2 {
|
|
|
260
269
|
if (max_tokens) {
|
|
261
270
|
json.max_tokens = max_tokens;
|
|
262
271
|
}
|
|
263
|
-
|
|
272
|
+
if (chunks_only) {
|
|
273
|
+
json.chunks_only = chunks_only;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (engine.type === 'serverless') {
|
|
277
|
+
json.search_type = 'hybrid';
|
|
278
|
+
json.alpha = alpha;
|
|
279
|
+
}
|
|
280
|
+
|
|
264
281
|
if (!action.advancedPrompt) {
|
|
265
282
|
if (filled_context) {
|
|
266
283
|
json.system_context = filled_context + "\n" + contexts[model];
|
|
@@ -306,22 +323,34 @@ class DirAskGPTV2 {
|
|
|
306
323
|
}
|
|
307
324
|
else if (resbody.success === true) {
|
|
308
325
|
winston.debug("DirAskGPTV2 resbody: ", resbody);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
326
|
+
if (chunks_only) {
|
|
327
|
+
await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.chunks);
|
|
328
|
+
if (trueIntent) {
|
|
329
|
+
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
330
|
+
callback(true);
|
|
331
|
+
return;
|
|
314
332
|
}
|
|
315
|
-
|
|
316
|
-
|
|
333
|
+
callback();
|
|
334
|
+
return;
|
|
317
335
|
|
|
318
|
-
|
|
319
|
-
await this.#
|
|
320
|
-
|
|
336
|
+
} else {
|
|
337
|
+
await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.content_chunks);
|
|
338
|
+
if (publicKey === true) {
|
|
339
|
+
let tokens_usage = {
|
|
340
|
+
tokens: resbody.prompt_token_size,
|
|
341
|
+
model: json.model
|
|
342
|
+
}
|
|
343
|
+
this.updateQuote(tokens_usage);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (trueIntent) {
|
|
347
|
+
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
348
|
+
callback(true);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
callback();
|
|
321
352
|
return;
|
|
322
353
|
}
|
|
323
|
-
callback();
|
|
324
|
-
return;
|
|
325
354
|
} else {
|
|
326
355
|
await this.#assignAttributes(action, answer, source);
|
|
327
356
|
if (falseIntent) {
|
|
@@ -25,7 +25,6 @@ class DirAssistant {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
execute(directive, callback) {
|
|
28
|
-
this.logger.info("[ChatGPT Assistant] Executing action");
|
|
29
28
|
winston.verbose("Execute Assistant directive");
|
|
30
29
|
let action;
|
|
31
30
|
if (directive.action) {
|
|
@@ -38,7 +37,7 @@ class DirAssistant {
|
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
this.go(action, (stop) => {
|
|
41
|
-
this.logger.
|
|
40
|
+
this.logger.native("[ChatGPT Assistant] Executed");
|
|
42
41
|
callback(stop);
|
|
43
42
|
});
|
|
44
43
|
}
|
|
@@ -26,7 +26,6 @@ class DirBrevo {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
execute(directive, callback) {
|
|
29
|
-
this.logger.info("[Brevo] Executing action");
|
|
30
29
|
winston.verbose("Execute DirBrevo directive");
|
|
31
30
|
let action;
|
|
32
31
|
if (directive.action) {
|
|
@@ -39,7 +38,7 @@ class DirBrevo {
|
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
this.go(action, (stop) => {
|
|
42
|
-
this.logger.
|
|
41
|
+
this.logger.native("[Brevo] Executed");
|
|
43
42
|
callback(stop);
|
|
44
43
|
})
|
|
45
44
|
}
|
|
@@ -22,7 +22,6 @@ class DirCaptureUserReply {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
execute(directive, callback) {
|
|
25
|
-
this.logger.info("[Capture User Reply] Executing action");
|
|
26
25
|
winston.verbose("Execute CaptureUserReply directive");
|
|
27
26
|
let action;
|
|
28
27
|
if (directive.action) {
|
|
@@ -48,7 +47,7 @@ class DirCaptureUserReply {
|
|
|
48
47
|
const actionId = action["_tdActionId"];;
|
|
49
48
|
await this.chatbot.lockIntent(this.requestId, intent_name);
|
|
50
49
|
await this.chatbot.lockAction(this.requestId, actionId);
|
|
51
|
-
this.logger.
|
|
50
|
+
this.logger.native("[Capture User Reply] Waiting for user reply...");
|
|
52
51
|
callback();
|
|
53
52
|
return;
|
|
54
53
|
} else {
|
|
@@ -63,7 +62,7 @@ class DirCaptureUserReply {
|
|
|
63
62
|
}
|
|
64
63
|
try {
|
|
65
64
|
const user_reply = this.message.text;
|
|
66
|
-
this.logger.
|
|
65
|
+
this.logger.native("[Capture User Reply] User replied with: ", user_reply);
|
|
67
66
|
if (this.context.tdcache) {
|
|
68
67
|
if (action.assignResultTo) {
|
|
69
68
|
winston.debug("(DirCaptureUserReply) assign assignResultTo: " + action.assignResultTo);
|
|
@@ -74,12 +73,12 @@ class DirCaptureUserReply {
|
|
|
74
73
|
if (callback) {
|
|
75
74
|
if (goToIntent) {
|
|
76
75
|
this.#executeGoTo(goToIntent, () => {
|
|
77
|
-
this.logger.
|
|
76
|
+
this.logger.native("[Capture User Reply] Executed");
|
|
78
77
|
callback(); // continue the flow
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
else {
|
|
82
|
-
this.logger.
|
|
81
|
+
this.logger.native("[Capture User Reply] Executed");
|
|
83
82
|
callback(); // continue the flow
|
|
84
83
|
}
|
|
85
84
|
|
|
@@ -15,9 +15,8 @@ class DirClearTranscript {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
execute(directive, callback) {
|
|
18
|
-
this.logger.info("[Clear Transcript] Executing action");
|
|
19
18
|
TiledeskChatbotUtil.clearConversationTranscript(this.context.chatbot, () => {
|
|
20
|
-
this.logger.
|
|
19
|
+
this.logger.native("[Clear Transcript] Executed");
|
|
21
20
|
callback();
|
|
22
21
|
});
|
|
23
22
|
}
|
|
@@ -20,7 +20,6 @@ class DirClose {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
execute(directive, callback) {
|
|
23
|
-
this.logger.info("[Close] Executing action");
|
|
24
23
|
winston.verbose("Execute Close directive");
|
|
25
24
|
this.tdClient.closeRequest(this.requestId, async (err) => {
|
|
26
25
|
if (err) {
|
|
@@ -28,10 +27,10 @@ class DirClose {
|
|
|
28
27
|
winston.error("(DirClose) Error: ", err);
|
|
29
28
|
}
|
|
30
29
|
else {
|
|
31
|
-
this.logger.
|
|
30
|
+
this.logger.native("[Close] Request closed");
|
|
32
31
|
await this.chatbot.deleteParameter(TiledeskChatbotConst.USER_INPUT);
|
|
33
32
|
}
|
|
34
|
-
this.logger.
|
|
33
|
+
this.logger.native("[Close] Executed");
|
|
35
34
|
callback();
|
|
36
35
|
});
|
|
37
36
|
}
|
|
@@ -17,7 +17,6 @@ class DirCode {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
execute(directive, callback) {
|
|
20
|
-
this.logger.info("[Code] Executing action");
|
|
21
20
|
winston.verbose("Execute Code directive");
|
|
22
21
|
let action;
|
|
23
22
|
if (directive.action) {
|
|
@@ -30,7 +29,7 @@ class DirCode {
|
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
this.go(action, (stop) => {
|
|
33
|
-
this.logger.
|
|
32
|
+
this.logger.native("[Code] Executed");
|
|
34
33
|
callback(stop);
|
|
35
34
|
});
|
|
36
35
|
|
|
@@ -19,7 +19,6 @@ class DirCondition {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
execute(directive, callback) {
|
|
22
|
-
this.logger.info("[Condition] Executing action");
|
|
23
22
|
winston.verbose("Execute Condition directive");
|
|
24
23
|
let action;
|
|
25
24
|
if (directive.action) {
|
|
@@ -45,7 +44,7 @@ class DirCondition {
|
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
this.go(action, (stop) => {
|
|
48
|
-
this.logger.
|
|
47
|
+
this.logger.native("[Condition] Executed");
|
|
49
48
|
callback(stop);
|
|
50
49
|
});
|
|
51
50
|
|
|
@@ -131,7 +130,7 @@ class DirCondition {
|
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
else {
|
|
134
|
-
this.logger.
|
|
133
|
+
this.logger.native("[Condition] No trueIntentDirective specified");
|
|
135
134
|
winston.debug("(DirCondition) No trueIntentDirective specified");
|
|
136
135
|
callback();
|
|
137
136
|
return;
|
|
@@ -144,7 +143,7 @@ class DirCondition {
|
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
else {
|
|
147
|
-
this.logger.
|
|
146
|
+
this.logger.native("[Condition] No falseIntentDirective specified");
|
|
148
147
|
winston.debug("(DirCondition) No falseIntentDirective specified");
|
|
149
148
|
callback();
|
|
150
149
|
return;
|
|
@@ -26,7 +26,6 @@ class DirContactUpdate {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
execute(directive, callback) {
|
|
29
|
-
this.logger.info("[Lead Update] Executing action");
|
|
30
29
|
winston.verbose("Execute ContactUpdate directive")
|
|
31
30
|
let action;
|
|
32
31
|
if (directive.action) {
|
|
@@ -43,7 +42,7 @@ class DirContactUpdate {
|
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
this.go(action, () => {
|
|
46
|
-
this.logger.
|
|
45
|
+
this.logger.native("[Lead Update] Executed");
|
|
47
46
|
callback();
|
|
48
47
|
});
|
|
49
48
|
}
|
|
@@ -26,7 +26,6 @@ class DirCustomerio {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
execute(directive, callback) {
|
|
29
|
-
this.logger.info("[Customer.io] Executing action");
|
|
30
29
|
winston.verbose("Execute Customerio directive");
|
|
31
30
|
let action;
|
|
32
31
|
if (directive.action) {
|
|
@@ -39,7 +38,7 @@ class DirCustomerio {
|
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
this.go(action, (stop) => {
|
|
42
|
-
this.logger.
|
|
41
|
+
this.logger.native("[Customer.io] Executed");
|
|
43
42
|
callback(stop);
|
|
44
43
|
})
|
|
45
44
|
}
|
|
@@ -18,7 +18,6 @@ class DirDeleteVariable {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async execute(directive, callback) {
|
|
21
|
-
this.logger.info("[Delete Attribute] Executing action");
|
|
22
21
|
winston.verbose("Execute DeleteVariable directive");
|
|
23
22
|
let action;
|
|
24
23
|
if (directive.action) {
|
|
@@ -36,7 +35,7 @@ class DirDeleteVariable {
|
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
37
|
this.go(action, () => {
|
|
39
|
-
this.logger.
|
|
38
|
+
this.logger.native("[Delete Attribute] Executed");
|
|
40
39
|
callback();
|
|
41
40
|
});
|
|
42
41
|
}
|