@tiledesk/tiledesk-tybot-connector 2.0.10-rc10 → 2.0.10-rc12
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/logs/app.log +43071 -4803
- package/logs/app1.log +41129 -0
- package/logs/app2.log +4140 -46280
- package/logs/app6.log +29039 -0
- package/logs/app7.log +4726 -0
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +11 -12
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +15 -16
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +13 -14
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +11 -1
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +9 -5
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirClose.js +7 -1
- package/tiledeskChatbotPlugs/directives/DirCode.js +8 -0
- package/tiledeskChatbotPlugs/directives/DirCondition.js +12 -0
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +9 -0
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +13 -0
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +12 -1
- package/tiledeskChatbotPlugs/directives/DirForm.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +17 -5
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +10 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +10 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +10 -0
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +13 -3
- package/tiledeskChatbotPlugs/directives/DirMake.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +5 -1
- package/tiledeskChatbotPlugs/directives/DirQapla.js +5 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +9 -0
- package/tiledeskChatbotPlugs/directives/DirWait.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +10 -9
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +5 -4
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +6 -0
package/package.json
CHANGED
|
@@ -24,8 +24,7 @@ class DirAddTags {
|
|
|
24
24
|
this.tdcache = this.context.tdcache;
|
|
25
25
|
this.requestId = this.context.requestId;
|
|
26
26
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
27
|
-
this.
|
|
28
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
27
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
29
28
|
|
|
30
29
|
this.tdClient = new TiledeskClient({
|
|
31
30
|
projectId: this.context.projectId,
|
|
@@ -36,8 +35,8 @@ class DirAddTags {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
execute(directive, callback) {
|
|
38
|
+
this.logger.info("[Add Tag] Executing action")
|
|
39
39
|
winston.verbose("Execute AddTags action");
|
|
40
|
-
this.logger.error("Execute AddTags directive")
|
|
41
40
|
let action;
|
|
42
41
|
if (directive.action) {
|
|
43
42
|
action = directive.action;
|
|
@@ -49,7 +48,7 @@ class DirAddTags {
|
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
50
|
this.go(action, (stop) => {
|
|
52
|
-
this.logger.info("
|
|
51
|
+
this.logger.info("[Add Tag] Action completed");
|
|
53
52
|
callback(stop);
|
|
54
53
|
})
|
|
55
54
|
}
|
|
@@ -70,7 +69,7 @@ class DirAddTags {
|
|
|
70
69
|
pushToList = action.pushToList
|
|
71
70
|
|
|
72
71
|
if (!action.tags || action.tags === '') {
|
|
73
|
-
this.logger.error("Add
|
|
72
|
+
this.logger.error("[Add Tag] tags attribute is mandatory");
|
|
74
73
|
winston.error("(DirAddTags) Error: tags attribute is mandatory")
|
|
75
74
|
await this.chatbot.addParameter("flowError", "Add tags Error: tags attribute is mandatory");
|
|
76
75
|
callback();
|
|
@@ -91,7 +90,7 @@ class DirAddTags {
|
|
|
91
90
|
if(target === 'request'){
|
|
92
91
|
|
|
93
92
|
let newTags = filled_tags.split(',').filter(tag => tag !== '').map(el => el.trim())
|
|
94
|
-
this.logger.debug("Adding following tags to conversation: ", newTags)
|
|
93
|
+
this.logger.debug("[Add Tag] Adding following tags to conversation: ", newTags)
|
|
95
94
|
|
|
96
95
|
if(action.pushToList){
|
|
97
96
|
newTags.forEach(async (tag) => {
|
|
@@ -105,7 +104,7 @@ class DirAddTags {
|
|
|
105
104
|
|
|
106
105
|
winston.debug('(DirAddTags) UPDATE request with newTags', newTags)
|
|
107
106
|
let updatedRequest = await this.updateRequestWithTags(newTags)
|
|
108
|
-
this.logger.info("Tags added to conversation")
|
|
107
|
+
this.logger.info("[Add Tag] Tags added to conversation")
|
|
109
108
|
if(!updatedRequest){
|
|
110
109
|
callback();
|
|
111
110
|
return;
|
|
@@ -116,7 +115,7 @@ class DirAddTags {
|
|
|
116
115
|
/** use case: LEAD */
|
|
117
116
|
if(target === 'lead'){
|
|
118
117
|
let newTags = filled_tags.split(',').filter(tag => tag !== '').map(el => el.trim())
|
|
119
|
-
this.logger.debug("Adding following tags to lead: ", newTags)
|
|
118
|
+
this.logger.debug("[Add Tag] Adding following tags to lead: ", newTags)
|
|
120
119
|
|
|
121
120
|
let request = await this.tdClient.getRequestById(this.requestId);
|
|
122
121
|
winston.debug('(DirAddTags) request detail: ', request)
|
|
@@ -138,7 +137,7 @@ class DirAddTags {
|
|
|
138
137
|
|
|
139
138
|
winston.debug('(DirAddTags) UPDATE lead with newTags ', newTags)
|
|
140
139
|
let updatedLead = await this.updateLeadWithTags(request.lead._id, newTags)
|
|
141
|
-
this.logger.info("Tags added to lead")
|
|
140
|
+
this.logger.info("[Add Tag] Tags added to lead")
|
|
142
141
|
if(!updatedLead){
|
|
143
142
|
callback();
|
|
144
143
|
return;
|
|
@@ -183,7 +182,7 @@ class DirAddTags {
|
|
|
183
182
|
httpUtils.request(
|
|
184
183
|
HTTPREQUEST, async (err, resbody) => {
|
|
185
184
|
if (err) {
|
|
186
|
-
this.logger.error("Add tags to list error ", err?.response?.data)
|
|
185
|
+
this.logger.error("[Add Tag] Add tags to list error ", err?.response?.data)
|
|
187
186
|
winston.error("(httprequest) DirAddTags add tags to list err: ", err);
|
|
188
187
|
resolve(true)
|
|
189
188
|
} else {
|
|
@@ -218,7 +217,7 @@ class DirAddTags {
|
|
|
218
217
|
httpUtils.request(
|
|
219
218
|
HTTPREQUEST, async (err, resbody) => {
|
|
220
219
|
if (err) {
|
|
221
|
-
this.logger.error("Add tag to conversation error ", err?.response?.data);
|
|
220
|
+
this.logger.error("[Add Tag] Add tag to conversation error ", err?.response?.data);
|
|
222
221
|
winston.error("(httprequest) DirAddTags patch request with new tags err: ", err);
|
|
223
222
|
resolve(true)
|
|
224
223
|
} else {
|
|
@@ -248,7 +247,7 @@ class DirAddTags {
|
|
|
248
247
|
httpUtils.request(
|
|
249
248
|
HTTPREQUEST, async (err, resbody) => {
|
|
250
249
|
if (err) {
|
|
251
|
-
this.logger.error("Add tag to lead error ", err?.response?.data);
|
|
250
|
+
this.logger.error("[Add Tag] Add tag to lead error ", err?.response?.data);
|
|
252
251
|
winston.error("(httprequest) DirAddTags put lead with new tags err: ", err);
|
|
253
252
|
resolve(true)
|
|
254
253
|
} else {
|
|
@@ -28,25 +28,24 @@ class DirAiPrompt {
|
|
|
28
28
|
this.token = this.context.token;
|
|
29
29
|
this.intentDir = new DirIntent(context);
|
|
30
30
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
31
|
-
this.
|
|
32
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
31
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
execute(directive, callback) {
|
|
35
|
+
this.logger.info("[AI Prompt] Executing action");
|
|
36
36
|
winston.verbose("Execute AiPrompt directive");
|
|
37
|
-
this.logger.error("AiPrompt: executing action");
|
|
38
37
|
let action;
|
|
39
38
|
if (directive.action) {
|
|
40
39
|
action = directive.action;
|
|
41
40
|
}
|
|
42
41
|
else {
|
|
43
|
-
this.logger.error("
|
|
42
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
44
43
|
winston.debug("DirAiPrompt Incorrect directive: ", directive);
|
|
45
44
|
callback();
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
this.go(action, (stop) => {
|
|
49
|
-
this.logger.info("
|
|
48
|
+
this.logger.info("[AI Prompt] Action completed");
|
|
50
49
|
callback(stop);
|
|
51
50
|
})
|
|
52
51
|
}
|
|
@@ -70,7 +69,7 @@ class DirAiPrompt {
|
|
|
70
69
|
winston.debug("DirAskGPTV2 falseIntent", falseIntent)
|
|
71
70
|
|
|
72
71
|
await this.checkMandatoryParameters(action).catch( async (missing_param) => {
|
|
73
|
-
this.logger.error(`
|
|
72
|
+
this.logger.error(`[AI Prompt] missing attribute '${missing_param}'`);
|
|
74
73
|
await this.chatbot.addParameter("flowError", "AiPrompt Error: '" + missing_param + "' attribute is undefined");
|
|
75
74
|
if (falseIntent) {
|
|
76
75
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -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.info("
|
|
94
|
+
this.logger.info("[AI Prompt] using chat transcript");
|
|
96
95
|
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
97
96
|
this.context.tdcache,
|
|
98
97
|
this.context.requestId,
|
|
@@ -103,7 +102,7 @@ class DirAiPrompt {
|
|
|
103
102
|
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
104
103
|
winston.debug("DirAiPrompt transcript: ", transcript)
|
|
105
104
|
} else {
|
|
106
|
-
this.logger.warn("
|
|
105
|
+
this.logger.warn("[AI Prompt] no chat transcript found, skipping history translation");
|
|
107
106
|
winston.verbose("DirAiPrompt transcript_string is undefined. Skip JSON translation for chat history")
|
|
108
107
|
}
|
|
109
108
|
}
|
|
@@ -120,7 +119,7 @@ class DirAiPrompt {
|
|
|
120
119
|
|
|
121
120
|
if (action.llm === 'ollama') {
|
|
122
121
|
ollama_integration = await integrationService.getIntegration(this.projectId, action.llm, this.token).catch( async (err) => {
|
|
123
|
-
this.logger.error("
|
|
122
|
+
this.logger.error("[AI Prompt] Error getting ollama integration.")
|
|
124
123
|
winston.error("DirAiPrompt Error getting ollama integration: ", err);
|
|
125
124
|
await this.chatbot.addParameter("flowError", "Ollama integration not found");
|
|
126
125
|
if (falseIntent) {
|
|
@@ -136,7 +135,7 @@ class DirAiPrompt {
|
|
|
136
135
|
key = await integrationService.getKeyFromIntegrations(this.projectId, action.llm, this.token);
|
|
137
136
|
|
|
138
137
|
if (!key) {
|
|
139
|
-
this.logger.error("
|
|
138
|
+
this.logger.error("[AI Prompt] llm key not found in integrations");
|
|
140
139
|
winston.error("Error: DirAiPrompt llm key not found in integrations");
|
|
141
140
|
await this.chatbot.addParameter("flowError", "AiPrompt Error: missing key for llm " + action.llm);
|
|
142
141
|
if (falseIntent) {
|
|
@@ -199,7 +198,7 @@ class DirAiPrompt {
|
|
|
199
198
|
} else {
|
|
200
199
|
error = JSON.stringify(err.response.data);
|
|
201
200
|
}
|
|
202
|
-
this.logger.error("
|
|
201
|
+
this.logger.error("[AI Prompt] error executing action: ", error);
|
|
203
202
|
if (falseIntent) {
|
|
204
203
|
await this.chatbot.addParameter("flowError", "AiPrompt Error: " + error);
|
|
205
204
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -212,7 +211,7 @@ class DirAiPrompt {
|
|
|
212
211
|
|
|
213
212
|
winston.debug("DirAiPrompt resbody: ", resbody);
|
|
214
213
|
answer = resbody.answer;
|
|
215
|
-
this.logger.info("
|
|
214
|
+
this.logger.info("[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.info("
|
|
302
|
+
this.logger.info("[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.info("
|
|
310
|
+
this.logger.info("[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.info("
|
|
319
|
+
this.logger.info("[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.info("
|
|
327
|
+
this.logger.info("[AI Prompt] no block connected to false condition");
|
|
329
328
|
winston.debug("DirAiPrompt No falseIntentDirective specified");
|
|
330
329
|
if (callback) {
|
|
331
330
|
callback();
|
|
@@ -26,12 +26,11 @@ class DirAskGPTV2 {
|
|
|
26
26
|
this.token = this.context.token;
|
|
27
27
|
this.intentDir = new DirIntent(context);
|
|
28
28
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
29
|
-
this.
|
|
30
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
29
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
execute(directive, callback) {
|
|
34
|
-
this.logger.info("
|
|
33
|
+
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.info("
|
|
46
|
+
this.logger.info("[Ask Knowledge Base] Action completed");
|
|
48
47
|
callback(stop);
|
|
49
48
|
})
|
|
50
49
|
}
|
|
@@ -92,7 +91,7 @@ class DirAskGPTV2 {
|
|
|
92
91
|
let source = null;
|
|
93
92
|
|
|
94
93
|
if (!action.question || action.question === '') {
|
|
95
|
-
this.logger.error("
|
|
94
|
+
this.logger.error("[Ask Knowledge Base] question attribute is mandatory");
|
|
96
95
|
winston.error("DirAskGPTV2 Error: question attribute is mandatory. Executing condition false...");
|
|
97
96
|
await this.#assignAttributes(action, answer, source);
|
|
98
97
|
if (falseIntent) {
|
|
@@ -136,7 +135,7 @@ class DirAskGPTV2 {
|
|
|
136
135
|
const filled_context = filler.fill(action.context, requestVariables)
|
|
137
136
|
|
|
138
137
|
if (action.history) {
|
|
139
|
-
this.logger.info("
|
|
138
|
+
this.logger.info("[Ask Knowledge Base] use chat transcript")
|
|
140
139
|
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
141
140
|
this.context.tdcache,
|
|
142
141
|
this.context.requestId,
|
|
@@ -148,7 +147,7 @@ class DirAskGPTV2 {
|
|
|
148
147
|
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
149
148
|
winston.debug("DirAskGPTV2 transcript ", transcript)
|
|
150
149
|
} else {
|
|
151
|
-
this.logger.warn("
|
|
150
|
+
this.logger.warn("[Ask Knowledge Base] chat transcript is undefined. Skip JSON translation for chat history.");
|
|
152
151
|
winston.verbose("DirAskGPT transcript_string is undefined. Skip JSON translation for chat history")
|
|
153
152
|
}
|
|
154
153
|
}
|
|
@@ -158,7 +157,7 @@ class DirAskGPTV2 {
|
|
|
158
157
|
|
|
159
158
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
160
159
|
if (!key) {
|
|
161
|
-
this.logger.debug("
|
|
160
|
+
this.logger.debug("[Ask Knowledge Base] OpenAI key not found in Integration. Using shared OpenAI key");
|
|
162
161
|
winston.verbose("DirAskGPTV2 - Key not found in Integrations. Searching in kb settings...");
|
|
163
162
|
key = await this.getKeyFromKbSettings();
|
|
164
163
|
}
|
|
@@ -168,7 +167,7 @@ class DirAskGPTV2 {
|
|
|
168
167
|
key = process.env.GPTKEY;
|
|
169
168
|
publicKey = true;
|
|
170
169
|
} else {
|
|
171
|
-
this.logger.debug("
|
|
170
|
+
this.logger.debug("[Ask Knowledge Base] use your own OpenAI key")
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
if (!key) {
|
|
@@ -186,7 +185,7 @@ class DirAskGPTV2 {
|
|
|
186
185
|
if (publicKey === true) {
|
|
187
186
|
let keep_going = await this.checkQuoteAvailability();
|
|
188
187
|
if (keep_going === false) {
|
|
189
|
-
this.logger.warn("
|
|
188
|
+
this.logger.warn("[Ask Knowledge Base] Tokens quota exceeded. Skip the action")
|
|
190
189
|
winston.verbose("DirAskGPTV2 - Quota exceeded for tokens. Skip the action")
|
|
191
190
|
await this.chatbot.addParameter("flowError", "AskGPT Error: tokens quota exceeded");
|
|
192
191
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -200,17 +199,17 @@ class DirAskGPTV2 {
|
|
|
200
199
|
if (action.namespaceAsName) {
|
|
201
200
|
// Namespace could be an attribute
|
|
202
201
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
203
|
-
this.logger.debug("
|
|
202
|
+
this.logger.debug("[Ask Knowledge Base] Searching namespace by name ", filled_namespace);
|
|
204
203
|
ns = await this.getNamespace(filled_namespace, null);
|
|
205
204
|
namespace = ns?.id;
|
|
206
205
|
winston.verbose("DirAskGPTV2 - Retrieved namespace id from name " + namespace);
|
|
207
206
|
} else {
|
|
208
|
-
this.logger.debug("
|
|
207
|
+
this.logger.debug("[Ask Knowledge Base] Searching namespace by id ", namespace);
|
|
209
208
|
ns = await this.getNamespace(null, namespace);
|
|
210
209
|
}
|
|
211
210
|
|
|
212
211
|
if (!ns) {
|
|
213
|
-
this.logger.error("
|
|
212
|
+
this.logger.error("[Ask Knowledge Base] Namespace not found")
|
|
214
213
|
await this.#assignAttributes(action, answer);
|
|
215
214
|
await this.chatbot.addParameter("flowError", "AskGPT Error: namespace not found");
|
|
216
215
|
if (falseIntent) {
|
|
@@ -229,7 +228,7 @@ class DirAskGPTV2 {
|
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
if (!namespace) {
|
|
232
|
-
this.logger.error("
|
|
231
|
+
this.logger.error("[Ask Knowledge Base] Namespace is undefined")
|
|
233
232
|
winston.verbose("DirAskGPTV2 - Error: namespace is undefined")
|
|
234
233
|
if (falseIntent) {
|
|
235
234
|
await this.chatbot.addParameter("flowError", "AskGPT Error: namespace is undefined");
|
|
@@ -6,6 +6,7 @@ const { DirIntent } = require('./DirIntent');
|
|
|
6
6
|
const winston = require('../../utils/winston')
|
|
7
7
|
const httpUtils = require('../../utils/HttpUtils');
|
|
8
8
|
const integrationService = require('../../services/IntegrationService');
|
|
9
|
+
const { Logger } = require('../../Logger');
|
|
9
10
|
|
|
10
11
|
class DirAssistant {
|
|
11
12
|
constructor(context) {
|
|
@@ -19,20 +20,24 @@ class DirAssistant {
|
|
|
19
20
|
this.token = this.context.token;
|
|
20
21
|
this.intentDir = new DirIntent(context);
|
|
21
22
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
23
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
execute(directive, callback) {
|
|
27
|
+
this.logger.info("[ChatGPT Assistant] Executing action");
|
|
25
28
|
winston.verbose("Execute Assistant directive");
|
|
26
29
|
let action;
|
|
27
30
|
if (directive.action) {
|
|
28
31
|
action = directive.action;
|
|
29
32
|
}
|
|
30
33
|
else {
|
|
31
|
-
|
|
34
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
35
|
+
winston.debug("Incorrect directive: ", directive);
|
|
32
36
|
callback();
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
39
|
this.go(action, (stop) => {
|
|
40
|
+
this.logger.info("[ChatGPT Assistant] Action completed");
|
|
36
41
|
callback(stop);
|
|
37
42
|
});
|
|
38
43
|
}
|
|
@@ -77,6 +82,7 @@ class DirAssistant {
|
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
79
84
|
// TODO: LOG SETTINGS ERROR
|
|
85
|
+
this.logger.error("[ChatGPT Assistant] No assistantId provided");
|
|
80
86
|
winston.error("(DirAssistant) Error: no assistantId.");
|
|
81
87
|
callback();
|
|
82
88
|
return;
|
|
@@ -88,6 +94,7 @@ class DirAssistant {
|
|
|
88
94
|
}
|
|
89
95
|
else {
|
|
90
96
|
// TODO: LOG SETTINGS ERROR
|
|
97
|
+
this.logger.error("[ChatGPT Assistant] No prompt provided");
|
|
91
98
|
winston.error("(DirAssistant) Error: no prompt.");
|
|
92
99
|
callback();
|
|
93
100
|
return;
|
|
@@ -98,6 +105,7 @@ class DirAssistant {
|
|
|
98
105
|
assistantId = filler.fill(_assistantId, requestAttributes);
|
|
99
106
|
}
|
|
100
107
|
catch(error) {
|
|
108
|
+
this.logger.error("[ChatGPT Assistant] Error while filling assistantId");
|
|
101
109
|
winston.error("(DirAssistant) Error while filling assistantId:", error);
|
|
102
110
|
}
|
|
103
111
|
|
|
@@ -106,6 +114,7 @@ class DirAssistant {
|
|
|
106
114
|
prompt = filler.fill(_prompt, requestAttributes);
|
|
107
115
|
}
|
|
108
116
|
catch(error) {
|
|
117
|
+
this.logger.error("[ChatGPT Assistant] Error while filling prompt");
|
|
109
118
|
winston.error("(DirAssistant) Error while filling prompt:", error);
|
|
110
119
|
}
|
|
111
120
|
|
|
@@ -128,6 +137,7 @@ class DirAssistant {
|
|
|
128
137
|
let apikey = await this.getGPT_APIKEY();
|
|
129
138
|
if (!apikey) {
|
|
130
139
|
const reply = "OpenAI APIKEY is mandatory for ChatGPT Assistants. Add your personal OpenAI APIKEY in Settings > Integrations";
|
|
140
|
+
this.logger.error("[ChatGPT Assistant] OpenAI APIKEY is mandatory for ChatGPT Assistants. Add your personal OpenAI APIKEY in Settings > Integrations");
|
|
131
141
|
winston.error("(DirAssistant) Error: " + reply)
|
|
132
142
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, assignErrorTo, reply);
|
|
133
143
|
if (falseIntent) {
|
|
@@ -6,6 +6,7 @@ let https = require("https");
|
|
|
6
6
|
require('dotenv').config();
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const integrationService = require("../../services/IntegrationService");
|
|
9
|
+
const { Logger } = require("../../Logger");
|
|
9
10
|
|
|
10
11
|
class DirBrevo {
|
|
11
12
|
|
|
@@ -20,20 +21,24 @@ class DirBrevo {
|
|
|
20
21
|
this.token = this.context.token;
|
|
21
22
|
this.intentDir = new DirIntent(context);
|
|
22
23
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
24
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
execute(directive, callback) {
|
|
28
|
+
this.logger.info("[Brevo] Executing action");
|
|
26
29
|
winston.verbose("Execute DirBrevo directive");
|
|
27
30
|
let action;
|
|
28
31
|
if (directive.action) {
|
|
29
32
|
action = directive.action;
|
|
30
33
|
}
|
|
31
34
|
else {
|
|
35
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
32
36
|
winston.warn("(DirBrevo) Incorrect directive: ", directive);
|
|
33
37
|
callback();
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
this.go(action, (stop) => {
|
|
41
|
+
this.logger.info("[Brevo] Action completed");
|
|
37
42
|
callback(stop);
|
|
38
43
|
})
|
|
39
44
|
}
|
|
@@ -68,6 +73,7 @@ class DirBrevo {
|
|
|
68
73
|
winston.debug("(DirBrevo) bodyParameters: ", bodyParameters);
|
|
69
74
|
|
|
70
75
|
if (!bodyParameters || bodyParameters === '') {
|
|
76
|
+
this.logger.error("[Brevo] bodyParameters is undefined or null or empty string");
|
|
71
77
|
winston.error("(DirBrevo) Error: bodyParameters is undefined or null or empty string");
|
|
72
78
|
callback();
|
|
73
79
|
return;
|
|
@@ -79,6 +85,7 @@ class DirBrevo {
|
|
|
79
85
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'Brevo', this.token);
|
|
80
86
|
winston.debug("(DirBrevo) key: ", key)
|
|
81
87
|
if (!key) {
|
|
88
|
+
this.logger.error("[Brevo] Key not found in Integrations");
|
|
82
89
|
winston.debug("(DirBrevo) - Key not found in Integrations.");
|
|
83
90
|
if (falseIntent) {
|
|
84
91
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -139,6 +146,7 @@ class DirBrevo {
|
|
|
139
146
|
BREVO_HTTPREQUEST, async (err, resbody) => {
|
|
140
147
|
if (err) {
|
|
141
148
|
if (callback) {
|
|
149
|
+
this.logger.error("[Brevo] Error response: ", err.response);
|
|
142
150
|
winston.debug("(DirBrevo) err response: ", err.response)
|
|
143
151
|
winston.debug("(DirBrevo) err data:", err.response.data)
|
|
144
152
|
|
|
@@ -157,11 +165,6 @@ class DirBrevo {
|
|
|
157
165
|
error = err.response.data.message;
|
|
158
166
|
}
|
|
159
167
|
|
|
160
|
-
winston.error("(DirBrevo) DirBrevo err data result:", result); // CONTROLLA IL VALORE
|
|
161
|
-
winston.error("(DirBrevo) DirBrevo err data status:", status);
|
|
162
|
-
winston.error("(DirBrevo) DirBrevo err data error:", error);
|
|
163
|
-
|
|
164
|
-
|
|
165
168
|
await this.#assignAttributes(action, status, result, error);
|
|
166
169
|
if (falseIntent) {
|
|
167
170
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -177,6 +180,7 @@ class DirBrevo {
|
|
|
177
180
|
let status = 201;
|
|
178
181
|
let error = null;
|
|
179
182
|
let result = JSON.stringify(resbody, null, 2).slice(2, -1);
|
|
183
|
+
this.logger.error("[Brevo] Result: ", result);
|
|
180
184
|
await this.#assignAttributes(action, status, result, error);
|
|
181
185
|
if (trueIntent) {
|
|
182
186
|
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes)
|
|
@@ -2,6 +2,7 @@ const { Filler } = require('../Filler');
|
|
|
2
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { DirIntent } = require('./DirIntent');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
|
+
const { Logger } = require('../../Logger');
|
|
5
6
|
|
|
6
7
|
class DirCaptureUserReply {
|
|
7
8
|
constructor(context) {
|
|
@@ -16,20 +17,24 @@ class DirCaptureUserReply {
|
|
|
16
17
|
this.tdcache = context.tdcache;
|
|
17
18
|
this.requestId = context.requestId;
|
|
18
19
|
this.intentDir = new DirIntent(context);
|
|
20
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
execute(directive, callback) {
|
|
24
|
+
this.logger.info("[Capture User Reply] Executing action");
|
|
22
25
|
winston.verbose("Execute CaptureUserReply directive");
|
|
23
26
|
let action;
|
|
24
27
|
if (directive.action) {
|
|
25
28
|
action = directive.action;
|
|
26
29
|
}
|
|
27
30
|
else {
|
|
31
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
28
32
|
winston.warn("DirCaptureUserReply Incorrect directive: ", directive);
|
|
29
33
|
callback();
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
36
|
this.go(action, () => {
|
|
37
|
+
this.logger.info("[Capture User Reply] Action completed");
|
|
33
38
|
callback();
|
|
34
39
|
});
|
|
35
40
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
const { Logger } = require('../../Logger');
|
|
2
3
|
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
3
4
|
|
|
4
5
|
class DirClearTranscript {
|
|
@@ -9,10 +10,13 @@ class DirClearTranscript {
|
|
|
9
10
|
}
|
|
10
11
|
this.context = context;
|
|
11
12
|
this.requestId = context.requestId;
|
|
13
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
execute(directive, callback) {
|
|
17
|
+
this.logger.info("[Clear Transcript] Executing action");
|
|
15
18
|
TiledeskChatbotUtil.clearConversationTranscript(this.context.chatbot, () => {
|
|
19
|
+
this.logger.info("[Clear Transcript] Action completed");
|
|
16
20
|
callback();
|
|
17
21
|
});
|
|
18
22
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const { TiledeskClient } = require("@tiledesk/tiledesk-client");
|
|
3
3
|
const { TiledeskChatbotConst } = require("../../engine/TiledeskChatbotConst");
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
|
+
const { Logger } = require("../../Logger");
|
|
5
6
|
|
|
6
7
|
class DirClose {
|
|
7
8
|
|
|
@@ -13,24 +14,29 @@ class DirClose {
|
|
|
13
14
|
this.requestId = context.requestId;
|
|
14
15
|
this.chatbot = context.chatbot;
|
|
15
16
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
16
18
|
|
|
17
19
|
this.tdClient = new TiledeskClient({
|
|
18
20
|
projectId: this.context.projectId,
|
|
19
21
|
token: this.context.token,
|
|
20
22
|
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___"
|
|
23
|
+
APIKEY: "___"
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
execute(directive, callback) {
|
|
28
|
+
this.logger.info("[Close] Executing action");
|
|
26
29
|
winston.verbose("Execute Close directive");
|
|
27
30
|
this.tdClient.closeRequest(this.requestId, async (err) => {
|
|
28
31
|
if (err) {
|
|
32
|
+
this.logger.error("[Close] Closing request");
|
|
29
33
|
winston.error("(DirClose) Error: ", err);
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
36
|
+
this.logger.verbose("[Close] Request closed");
|
|
32
37
|
await this.chatbot.deleteParameter(TiledeskChatbotConst.USER_INPUT);
|
|
33
38
|
}
|
|
39
|
+
this.logger.info("[Close] Action completed");
|
|
34
40
|
callback();
|
|
35
41
|
});
|
|
36
42
|
}
|
|
@@ -2,6 +2,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
2
2
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
3
3
|
const { TiledeskRequestVariables } = require('../TiledeskRequestVariables');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
|
+
const { Logger } = require('../../Logger');
|
|
5
6
|
|
|
6
7
|
class DirCode {
|
|
7
8
|
|
|
@@ -10,20 +11,25 @@ class DirCode {
|
|
|
10
11
|
throw new Error('context object is mandatory.');
|
|
11
12
|
}
|
|
12
13
|
this.context = context;
|
|
14
|
+
this.requestId = this.context.requestId;
|
|
15
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
execute(directive, callback) {
|
|
19
|
+
this.logger.info("[Code] Executing action");
|
|
16
20
|
winston.verbose("Execute Code directive");
|
|
17
21
|
let action;
|
|
18
22
|
if (directive.action) {
|
|
19
23
|
action = directive.action
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
26
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
22
27
|
winston.warn("DirCode Incorrect directive: ", directive);
|
|
23
28
|
callback();
|
|
24
29
|
return;
|
|
25
30
|
}
|
|
26
31
|
this.go(action, (stop) => {
|
|
32
|
+
this.logger.info("[Code] Action completed");
|
|
27
33
|
callback(stop);
|
|
28
34
|
});
|
|
29
35
|
|
|
@@ -33,6 +39,7 @@ class DirCode {
|
|
|
33
39
|
winston.debug("(DirCode) Action: ", action);
|
|
34
40
|
const source_code = action.source;
|
|
35
41
|
if (!source_code || source_code.trim() === "") {
|
|
42
|
+
this.logger.warn("[Code] Invalid source_code");
|
|
36
43
|
winston.error("(DirCode) Invalid source_code");
|
|
37
44
|
callback();
|
|
38
45
|
return;
|
|
@@ -73,6 +80,7 @@ class DirCode {
|
|
|
73
80
|
|
|
74
81
|
}
|
|
75
82
|
catch(err) {
|
|
83
|
+
this.logger.error("[Code] An error occurred: ", err);
|
|
76
84
|
winston.error("(DirCode) An error occurred: ", err);
|
|
77
85
|
}
|
|
78
86
|
callback();
|