@tiledesk/tiledesk-tybot-connector 2.0.10-rc2 → 2.0.10-rc20
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/Logger.js +6 -1
- package/logs/app.log +28600 -21124
- package/logs/app1.log +41129 -0
- package/logs/app2.log +16449 -45594
- package/logs/app6.log +44412 -0
- package/logs/app7.log +4726 -0
- package/package.json +2 -2
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +7 -0
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +333 -0
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +13 -19
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +17 -17
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +2 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +19 -16
- package/tiledeskChatbotPlugs/directives/DirAssign.js +0 -6
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -6
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +13 -2
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +11 -6
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +10 -0
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirClose.js +8 -7
- package/tiledeskChatbotPlugs/directives/DirCode.js +9 -0
- package/tiledeskChatbotPlugs/directives/DirCondition.js +13 -0
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +11 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -6
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +14 -0
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +14 -8
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +3 -7
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +22 -10
- package/tiledeskChatbotPlugs/directives/DirForm.js +4 -9
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +19 -6
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +12 -2
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +4 -8
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +12 -8
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +11 -0
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +4 -8
- package/tiledeskChatbotPlugs/directives/DirIntent.js +5 -6
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +14 -3
- package/tiledeskChatbotPlugs/directives/DirMake.js +6 -0
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -6
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +5 -7
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -7
- package/tiledeskChatbotPlugs/directives/DirQapla.js +7 -2
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -6
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirReply.js +9 -11
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -8
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +7 -7
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +7 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +7 -0
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +2 -7
- package/tiledeskChatbotPlugs/directives/DirWait.js +6 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +16 -13
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +7 -0
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +3 -1
|
@@ -24,14 +24,14 @@ class DirAskGPTV2 {
|
|
|
24
24
|
this.requestId = this.context.requestId;
|
|
25
25
|
this.projectId = this.context.projectId;
|
|
26
26
|
this.token = this.context.token;
|
|
27
|
-
this.intentDir = new DirIntent(context);
|
|
28
27
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
29
|
-
|
|
30
|
-
this.
|
|
28
|
+
|
|
29
|
+
this.intentDir = new DirIntent(context);
|
|
30
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
execute(directive, callback) {
|
|
34
|
-
this.logger.
|
|
34
|
+
this.logger.info("[Ask Knowledge Base] Executing action");
|
|
35
35
|
winston.debug("DirAskGPTV2 directive: ", directive);
|
|
36
36
|
let action;
|
|
37
37
|
if (directive.action) {
|
|
@@ -44,7 +44,7 @@ class DirAskGPTV2 {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
this.go(action, (stop) => {
|
|
47
|
-
this.logger.info("
|
|
47
|
+
this.logger.info("[Ask Knowledge Base] Action completed");
|
|
48
48
|
callback(stop);
|
|
49
49
|
})
|
|
50
50
|
}
|
|
@@ -86,13 +86,16 @@ class DirAskGPTV2 {
|
|
|
86
86
|
"gpt-4": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
87
87
|
"gpt-4-turbo-preview": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
88
88
|
"gpt-4o": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
89
|
-
"gpt-4o-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end=="
|
|
89
|
+
"gpt-4o-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
90
|
+
"gpt-4.1": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
91
|
+
"gpt-4.1-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
92
|
+
"gpt-4.1-nano": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end=="
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
let source = null;
|
|
93
96
|
|
|
94
97
|
if (!action.question || action.question === '') {
|
|
95
|
-
this.logger.error("
|
|
98
|
+
this.logger.error("[Ask Knowledge Base] question attribute is mandatory");
|
|
96
99
|
winston.error("DirAskGPTV2 Error: question attribute is mandatory. Executing condition false...");
|
|
97
100
|
await this.#assignAttributes(action, answer, source);
|
|
98
101
|
if (falseIntent) {
|
|
@@ -136,7 +139,7 @@ class DirAskGPTV2 {
|
|
|
136
139
|
const filled_context = filler.fill(action.context, requestVariables)
|
|
137
140
|
|
|
138
141
|
if (action.history) {
|
|
139
|
-
this.logger.info("
|
|
142
|
+
this.logger.info("[Ask Knowledge Base] use chat transcript")
|
|
140
143
|
let transcript_string = await TiledeskChatbot.getParameterStatic(
|
|
141
144
|
this.context.tdcache,
|
|
142
145
|
this.context.requestId,
|
|
@@ -148,7 +151,7 @@ class DirAskGPTV2 {
|
|
|
148
151
|
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
149
152
|
winston.debug("DirAskGPTV2 transcript ", transcript)
|
|
150
153
|
} else {
|
|
151
|
-
this.logger.warn("
|
|
154
|
+
this.logger.warn("[Ask Knowledge Base] chat transcript is undefined. Skip JSON translation for chat history.");
|
|
152
155
|
winston.verbose("DirAskGPT transcript_string is undefined. Skip JSON translation for chat history")
|
|
153
156
|
}
|
|
154
157
|
}
|
|
@@ -158,7 +161,7 @@ class DirAskGPTV2 {
|
|
|
158
161
|
|
|
159
162
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
160
163
|
if (!key) {
|
|
161
|
-
this.logger.debug("
|
|
164
|
+
this.logger.debug("[Ask Knowledge Base] OpenAI key not found in Integration. Using shared OpenAI key");
|
|
162
165
|
winston.verbose("DirAskGPTV2 - Key not found in Integrations. Searching in kb settings...");
|
|
163
166
|
key = await this.getKeyFromKbSettings();
|
|
164
167
|
}
|
|
@@ -168,7 +171,7 @@ class DirAskGPTV2 {
|
|
|
168
171
|
key = process.env.GPTKEY;
|
|
169
172
|
publicKey = true;
|
|
170
173
|
} else {
|
|
171
|
-
this.logger.debug("
|
|
174
|
+
this.logger.debug("[Ask Knowledge Base] use your own OpenAI key")
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
if (!key) {
|
|
@@ -186,7 +189,7 @@ class DirAskGPTV2 {
|
|
|
186
189
|
if (publicKey === true) {
|
|
187
190
|
let keep_going = await this.checkQuoteAvailability();
|
|
188
191
|
if (keep_going === false) {
|
|
189
|
-
this.logger.warn("
|
|
192
|
+
this.logger.warn("[Ask Knowledge Base] Tokens quota exceeded. Skip the action")
|
|
190
193
|
winston.verbose("DirAskGPTV2 - Quota exceeded for tokens. Skip the action")
|
|
191
194
|
await this.chatbot.addParameter("flowError", "AskGPT Error: tokens quota exceeded");
|
|
192
195
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -200,17 +203,17 @@ class DirAskGPTV2 {
|
|
|
200
203
|
if (action.namespaceAsName) {
|
|
201
204
|
// Namespace could be an attribute
|
|
202
205
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
203
|
-
this.logger.debug("
|
|
206
|
+
this.logger.debug("[Ask Knowledge Base] Searching namespace by name ", filled_namespace);
|
|
204
207
|
ns = await this.getNamespace(filled_namespace, null);
|
|
205
208
|
namespace = ns?.id;
|
|
206
209
|
winston.verbose("DirAskGPTV2 - Retrieved namespace id from name " + namespace);
|
|
207
210
|
} else {
|
|
208
|
-
this.logger.debug("
|
|
211
|
+
this.logger.debug("[Ask Knowledge Base] Searching namespace by id ", namespace);
|
|
209
212
|
ns = await this.getNamespace(null, namespace);
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
if (!ns) {
|
|
213
|
-
this.logger.error("
|
|
216
|
+
this.logger.error("[Ask Knowledge Base] Namespace not found")
|
|
214
217
|
await this.#assignAttributes(action, answer);
|
|
215
218
|
await this.chatbot.addParameter("flowError", "AskGPT Error: namespace not found");
|
|
216
219
|
if (falseIntent) {
|
|
@@ -229,7 +232,7 @@ class DirAskGPTV2 {
|
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
if (!namespace) {
|
|
232
|
-
this.logger.error("
|
|
235
|
+
this.logger.error("[Ask Knowledge Base] Namespace is undefined")
|
|
233
236
|
winston.verbose("DirAskGPTV2 - Error: namespace is undefined")
|
|
234
237
|
if (falseIntent) {
|
|
235
238
|
await this.chatbot.addParameter("flowError", "AskGPT Error: namespace is undefined");
|
|
@@ -62,12 +62,6 @@ class DirAssign {
|
|
|
62
62
|
const value = new TiledeskExpression().evaluateExpression(expression, variables);
|
|
63
63
|
winston.debug("(DirAssign) executed expression: " + expression + " value: " + value);
|
|
64
64
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, variableName, value);
|
|
65
|
-
winston.debug("(DirAssign) Assigned: " + variableName + " = " + value);
|
|
66
|
-
const all_parameters = await TiledeskChatbot.allParametersStatic(this.context.tdcache, this.context.requestId);
|
|
67
|
-
for (const [key, value] of Object.entries(all_parameters)) {
|
|
68
|
-
const value_type = typeof value;
|
|
69
|
-
winston.debug("(DirAssign) request parameter: " + key + " value: " + value + " type: " + value_type)
|
|
70
|
-
}
|
|
71
65
|
|
|
72
66
|
callback();
|
|
73
67
|
}
|
|
@@ -13,12 +13,7 @@ class DirAssignFromFunction {
|
|
|
13
13
|
this.tdcache = context.tdcache;
|
|
14
14
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
15
15
|
|
|
16
|
-
this.tdClient = new TiledeskClient({
|
|
17
|
-
projectId: this.context.projectId,
|
|
18
|
-
token: this.context.token,
|
|
19
|
-
APIURL: this.API_ENDPOINT,
|
|
20
|
-
APIKEY: "___"
|
|
21
|
-
});
|
|
16
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
async execute(directive, callback) {
|
|
@@ -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) {
|
|
@@ -17,22 +18,27 @@ class DirAssistant {
|
|
|
17
18
|
this.requestId = context.requestId;
|
|
18
19
|
this.projectId = this.context.projectId;
|
|
19
20
|
this.token = this.context.token;
|
|
20
|
-
this.intentDir = new DirIntent(context);
|
|
21
21
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
22
|
+
|
|
23
|
+
this.intentDir = new DirIntent(context);
|
|
24
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
execute(directive, callback) {
|
|
28
|
+
this.logger.info("[ChatGPT Assistant] Executing action");
|
|
25
29
|
winston.verbose("Execute Assistant directive");
|
|
26
30
|
let action;
|
|
27
31
|
if (directive.action) {
|
|
28
32
|
action = directive.action;
|
|
29
33
|
}
|
|
30
34
|
else {
|
|
31
|
-
|
|
35
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
36
|
+
winston.debug("Incorrect directive: ", directive);
|
|
32
37
|
callback();
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
40
|
this.go(action, (stop) => {
|
|
41
|
+
this.logger.info("[ChatGPT Assistant] Action completed");
|
|
36
42
|
callback(stop);
|
|
37
43
|
});
|
|
38
44
|
}
|
|
@@ -77,6 +83,7 @@ class DirAssistant {
|
|
|
77
83
|
}
|
|
78
84
|
else {
|
|
79
85
|
// TODO: LOG SETTINGS ERROR
|
|
86
|
+
this.logger.error("[ChatGPT Assistant] No assistantId provided");
|
|
80
87
|
winston.error("(DirAssistant) Error: no assistantId.");
|
|
81
88
|
callback();
|
|
82
89
|
return;
|
|
@@ -88,6 +95,7 @@ class DirAssistant {
|
|
|
88
95
|
}
|
|
89
96
|
else {
|
|
90
97
|
// TODO: LOG SETTINGS ERROR
|
|
98
|
+
this.logger.error("[ChatGPT Assistant] No prompt provided");
|
|
91
99
|
winston.error("(DirAssistant) Error: no prompt.");
|
|
92
100
|
callback();
|
|
93
101
|
return;
|
|
@@ -98,6 +106,7 @@ class DirAssistant {
|
|
|
98
106
|
assistantId = filler.fill(_assistantId, requestAttributes);
|
|
99
107
|
}
|
|
100
108
|
catch(error) {
|
|
109
|
+
this.logger.error("[ChatGPT Assistant] Error while filling assistantId");
|
|
101
110
|
winston.error("(DirAssistant) Error while filling assistantId:", error);
|
|
102
111
|
}
|
|
103
112
|
|
|
@@ -106,6 +115,7 @@ class DirAssistant {
|
|
|
106
115
|
prompt = filler.fill(_prompt, requestAttributes);
|
|
107
116
|
}
|
|
108
117
|
catch(error) {
|
|
118
|
+
this.logger.error("[ChatGPT Assistant] Error while filling prompt");
|
|
109
119
|
winston.error("(DirAssistant) Error while filling prompt:", error);
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -128,6 +138,7 @@ class DirAssistant {
|
|
|
128
138
|
let apikey = await this.getGPT_APIKEY();
|
|
129
139
|
if (!apikey) {
|
|
130
140
|
const reply = "OpenAI APIKEY is mandatory for ChatGPT Assistants. Add your personal OpenAI APIKEY in Settings > Integrations";
|
|
141
|
+
this.logger.error("[ChatGPT Assistant] OpenAI APIKEY is mandatory for ChatGPT Assistants. Add your personal OpenAI APIKEY in Settings > Integrations");
|
|
131
142
|
winston.error("(DirAssistant) Error: " + reply)
|
|
132
143
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, assignErrorTo, reply);
|
|
133
144
|
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
|
|
|
@@ -18,22 +19,27 @@ class DirBrevo {
|
|
|
18
19
|
this.requestId = this.context.requestId;
|
|
19
20
|
this.projectId = this.context.projectId;
|
|
20
21
|
this.token = this.context.token;
|
|
21
|
-
this.intentDir = new DirIntent(context);
|
|
22
22
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
23
|
+
|
|
24
|
+
this.intentDir = new DirIntent(context);
|
|
25
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
execute(directive, callback) {
|
|
29
|
+
this.logger.info("[Brevo] Executing action");
|
|
26
30
|
winston.verbose("Execute DirBrevo directive");
|
|
27
31
|
let action;
|
|
28
32
|
if (directive.action) {
|
|
29
33
|
action = directive.action;
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
36
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
32
37
|
winston.warn("(DirBrevo) Incorrect directive: ", directive);
|
|
33
38
|
callback();
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
41
|
this.go(action, (stop) => {
|
|
42
|
+
this.logger.info("[Brevo] Action completed");
|
|
37
43
|
callback(stop);
|
|
38
44
|
})
|
|
39
45
|
}
|
|
@@ -68,6 +74,7 @@ class DirBrevo {
|
|
|
68
74
|
winston.debug("(DirBrevo) bodyParameters: ", bodyParameters);
|
|
69
75
|
|
|
70
76
|
if (!bodyParameters || bodyParameters === '') {
|
|
77
|
+
this.logger.error("[Brevo] bodyParameters is undefined or null or empty string");
|
|
71
78
|
winston.error("(DirBrevo) Error: bodyParameters is undefined or null or empty string");
|
|
72
79
|
callback();
|
|
73
80
|
return;
|
|
@@ -79,6 +86,7 @@ class DirBrevo {
|
|
|
79
86
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'Brevo', this.token);
|
|
80
87
|
winston.debug("(DirBrevo) key: ", key)
|
|
81
88
|
if (!key) {
|
|
89
|
+
this.logger.error("[Brevo] Key not found in Integrations");
|
|
82
90
|
winston.debug("(DirBrevo) - Key not found in Integrations.");
|
|
83
91
|
if (falseIntent) {
|
|
84
92
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -139,6 +147,7 @@ class DirBrevo {
|
|
|
139
147
|
BREVO_HTTPREQUEST, async (err, resbody) => {
|
|
140
148
|
if (err) {
|
|
141
149
|
if (callback) {
|
|
150
|
+
this.logger.error("[Brevo] Error response: ", err.response);
|
|
142
151
|
winston.debug("(DirBrevo) err response: ", err.response)
|
|
143
152
|
winston.debug("(DirBrevo) err data:", err.response.data)
|
|
144
153
|
|
|
@@ -157,11 +166,6 @@ class DirBrevo {
|
|
|
157
166
|
error = err.response.data.message;
|
|
158
167
|
}
|
|
159
168
|
|
|
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
169
|
await this.#assignAttributes(action, status, result, error);
|
|
166
170
|
if (falseIntent) {
|
|
167
171
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -177,6 +181,7 @@ class DirBrevo {
|
|
|
177
181
|
let status = 201;
|
|
178
182
|
let error = null;
|
|
179
183
|
let result = JSON.stringify(resbody, null, 2).slice(2, -1);
|
|
184
|
+
this.logger.error("[Brevo] Result: ", result);
|
|
180
185
|
await this.#assignAttributes(action, status, result, error);
|
|
181
186
|
if (trueIntent) {
|
|
182
187
|
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) {
|
|
@@ -15,16 +16,20 @@ class DirCaptureUserReply {
|
|
|
15
16
|
this.chatbot = context.chatbot;
|
|
16
17
|
this.tdcache = context.tdcache;
|
|
17
18
|
this.requestId = context.requestId;
|
|
19
|
+
|
|
18
20
|
this.intentDir = new DirIntent(context);
|
|
21
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
execute(directive, callback) {
|
|
25
|
+
this.logger.info("[Capture User Reply] Executing action");
|
|
22
26
|
winston.verbose("Execute CaptureUserReply directive");
|
|
23
27
|
let action;
|
|
24
28
|
if (directive.action) {
|
|
25
29
|
action = directive.action;
|
|
26
30
|
}
|
|
27
31
|
else {
|
|
32
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
28
33
|
winston.warn("DirCaptureUserReply Incorrect directive: ", directive);
|
|
29
34
|
callback();
|
|
30
35
|
return;
|
|
@@ -43,6 +48,7 @@ class DirCaptureUserReply {
|
|
|
43
48
|
const actionId = action["_tdActionId"];;
|
|
44
49
|
await this.chatbot.lockIntent(this.requestId, intent_name);
|
|
45
50
|
await this.chatbot.lockAction(this.requestId, actionId);
|
|
51
|
+
this.logger.info("[Capture User Reply] Waiting for user reply...");
|
|
46
52
|
callback();
|
|
47
53
|
return;
|
|
48
54
|
} else {
|
|
@@ -57,6 +63,7 @@ class DirCaptureUserReply {
|
|
|
57
63
|
}
|
|
58
64
|
try {
|
|
59
65
|
const user_reply = this.message.text;
|
|
66
|
+
this.logger.info("[Capture User Reply] User replied with: ", user_reply);
|
|
60
67
|
if (this.context.tdcache) {
|
|
61
68
|
if (action.assignResultTo) {
|
|
62
69
|
winston.debug("(DirCaptureUserReply) assign assignResultTo: " + action.assignResultTo);
|
|
@@ -67,16 +74,19 @@ class DirCaptureUserReply {
|
|
|
67
74
|
if (callback) {
|
|
68
75
|
if (goToIntent) {
|
|
69
76
|
this.#executeGoTo(goToIntent, () => {
|
|
77
|
+
this.logger.info("[Capture User Reply] Action completed");
|
|
70
78
|
callback(); // continue the flow
|
|
71
79
|
});
|
|
72
80
|
}
|
|
73
81
|
else {
|
|
82
|
+
this.logger.info("[Capture User Reply] Action completed");
|
|
74
83
|
callback(); // continue the flow
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
catch(error) {
|
|
89
|
+
this.logger.error("[Capture User Reply] Error: ", error);
|
|
80
90
|
winston.error("(DirCaptureUserReply) error: ", error);
|
|
81
91
|
}
|
|
82
92
|
}
|
|
@@ -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,14 @@ class DirClearTranscript {
|
|
|
9
10
|
}
|
|
10
11
|
this.context = context;
|
|
11
12
|
this.requestId = context.requestId;
|
|
13
|
+
|
|
14
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
execute(directive, callback) {
|
|
18
|
+
this.logger.info("[Clear Transcript] Executing action");
|
|
15
19
|
TiledeskChatbotUtil.clearConversationTranscript(this.context.chatbot, () => {
|
|
20
|
+
this.logger.info("[Clear Transcript] Action completed");
|
|
16
21
|
callback();
|
|
17
22
|
});
|
|
18
23
|
}
|
|
@@ -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,24 @@ class DirClose {
|
|
|
13
14
|
this.requestId = context.requestId;
|
|
14
15
|
this.chatbot = context.chatbot;
|
|
15
16
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
token: this.context.token,
|
|
20
|
-
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___",
|
|
22
|
-
});
|
|
17
|
+
|
|
18
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
19
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
execute(directive, callback) {
|
|
23
|
+
this.logger.info("[Close] Executing action");
|
|
26
24
|
winston.verbose("Execute Close directive");
|
|
27
25
|
this.tdClient.closeRequest(this.requestId, async (err) => {
|
|
28
26
|
if (err) {
|
|
27
|
+
this.logger.error("[Close] Closing request");
|
|
29
28
|
winston.error("(DirClose) Error: ", err);
|
|
30
29
|
}
|
|
31
30
|
else {
|
|
31
|
+
this.logger.info("[Close] Request closed");
|
|
32
32
|
await this.chatbot.deleteParameter(TiledeskChatbotConst.USER_INPUT);
|
|
33
33
|
}
|
|
34
|
+
this.logger.info("[Close] Action completed");
|
|
34
35
|
callback();
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -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,26 @@ 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
|
+
|
|
16
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
execute(directive, callback) {
|
|
20
|
+
this.logger.info("[Code] Executing action");
|
|
16
21
|
winston.verbose("Execute Code directive");
|
|
17
22
|
let action;
|
|
18
23
|
if (directive.action) {
|
|
19
24
|
action = directive.action
|
|
20
25
|
}
|
|
21
26
|
else {
|
|
27
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
22
28
|
winston.warn("DirCode Incorrect directive: ", directive);
|
|
23
29
|
callback();
|
|
24
30
|
return;
|
|
25
31
|
}
|
|
26
32
|
this.go(action, (stop) => {
|
|
33
|
+
this.logger.info("[Code] Action completed");
|
|
27
34
|
callback(stop);
|
|
28
35
|
});
|
|
29
36
|
|
|
@@ -33,6 +40,7 @@ class DirCode {
|
|
|
33
40
|
winston.debug("(DirCode) Action: ", action);
|
|
34
41
|
const source_code = action.source;
|
|
35
42
|
if (!source_code || source_code.trim() === "") {
|
|
43
|
+
this.logger.warn("[Code] Invalid source_code");
|
|
36
44
|
winston.error("(DirCode) Invalid source_code");
|
|
37
45
|
callback();
|
|
38
46
|
return;
|
|
@@ -73,6 +81,7 @@ class DirCode {
|
|
|
73
81
|
|
|
74
82
|
}
|
|
75
83
|
catch(err) {
|
|
84
|
+
this.logger.error("[Code] An error occurred: ", err);
|
|
76
85
|
winston.error("(DirCode) An error occurred: ", err);
|
|
77
86
|
}
|
|
78
87
|
callback();
|
|
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
3
3
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
4
4
|
const ms = require('minimist-string');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
|
+
const { Logger } = require('../../Logger');
|
|
6
7
|
|
|
7
8
|
class DirCondition {
|
|
8
9
|
|
|
@@ -11,10 +12,14 @@ class DirCondition {
|
|
|
11
12
|
throw new Error('context object is mandatory.');
|
|
12
13
|
}
|
|
13
14
|
this.context = context;
|
|
15
|
+
this.requestId = this.context.requestId;
|
|
16
|
+
|
|
14
17
|
this.intentDir = new DirIntent(context);
|
|
18
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
execute(directive, callback) {
|
|
22
|
+
this.logger.info("[Condition] Executing action");
|
|
18
23
|
winston.verbose("Execute Condition directive");
|
|
19
24
|
let action;
|
|
20
25
|
if (directive.action) {
|
|
@@ -34,11 +39,13 @@ class DirCondition {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
else {
|
|
42
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
37
43
|
winston.warn("DirCondition Incorrect directive: ", directive);
|
|
38
44
|
callback();
|
|
39
45
|
return;
|
|
40
46
|
}
|
|
41
47
|
this.go(action, (stop) => {
|
|
48
|
+
this.logger.info("[Condition] Action completed");
|
|
42
49
|
callback(stop);
|
|
43
50
|
});
|
|
44
51
|
|
|
@@ -63,21 +70,25 @@ class DirCondition {
|
|
|
63
70
|
}
|
|
64
71
|
winston.debug("(DirCondition) condition action: ", action);
|
|
65
72
|
if (!trueIntent && !falseIntent) {
|
|
73
|
+
this.logger.error("[Condition] Invalid condition, no intents specified");
|
|
66
74
|
winston.error("(DirCondition) Invalid condition, no intents specified");
|
|
67
75
|
callback();
|
|
68
76
|
return;
|
|
69
77
|
}
|
|
70
78
|
if (scriptCondition === null && jsonCondition === null) {
|
|
79
|
+
this.logger.error("[Condition] Invalid condition, scriptCondition & jsonCondition null");
|
|
71
80
|
winston.error("(DirCondition) Invalid condition, scriptCondition & jsonCondition null");
|
|
72
81
|
callback();
|
|
73
82
|
return;
|
|
74
83
|
}
|
|
75
84
|
if (scriptCondition !== null && scriptCondition.trim === "") {
|
|
85
|
+
this.logger.error("[Condition] Invalid condition, scriptCondition is empty");
|
|
76
86
|
winston.error("(DirCondition) Invalid condition, scriptCondition is empty");
|
|
77
87
|
callback();
|
|
78
88
|
return;
|
|
79
89
|
}
|
|
80
90
|
else if (jsonCondition && jsonCondition.groups === null) {
|
|
91
|
+
this.logger.error("[Condition] Invalid jsonCondition, no groups");
|
|
81
92
|
winston.error("(DirCondition) Invalid jsonCondition, no groups:", jsonCondition);
|
|
82
93
|
callback();
|
|
83
94
|
return;
|
|
@@ -120,6 +131,7 @@ class DirCondition {
|
|
|
120
131
|
});
|
|
121
132
|
}
|
|
122
133
|
else {
|
|
134
|
+
this.logger.debug("[Condition] No trueIntentDirective specified");
|
|
123
135
|
winston.debug("(DirCondition) No trueIntentDirective specified");
|
|
124
136
|
callback();
|
|
125
137
|
return;
|
|
@@ -132,6 +144,7 @@ class DirCondition {
|
|
|
132
144
|
});
|
|
133
145
|
}
|
|
134
146
|
else {
|
|
147
|
+
this.logger.debug("[Condition] No falseIntentDirective specified");
|
|
135
148
|
winston.debug("(DirCondition) No falseIntentDirective specified");
|
|
136
149
|
callback();
|
|
137
150
|
return;
|
|
@@ -5,6 +5,7 @@ let axios = require('axios');
|
|
|
5
5
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
6
6
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const { Logger } = require('../../Logger');
|
|
8
9
|
|
|
9
10
|
class DirContactUpdate {
|
|
10
11
|
|
|
@@ -19,16 +20,13 @@ class DirContactUpdate {
|
|
|
19
20
|
this.token = context.token;
|
|
20
21
|
this.tdcache = context.tdcache;
|
|
21
22
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
token: this.context.token,
|
|
26
|
-
APIURL: this.API_ENDPOINT,
|
|
27
|
-
APIKEY: "___"
|
|
28
|
-
});
|
|
23
|
+
|
|
24
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
25
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
execute(directive, callback) {
|
|
29
|
+
this.logger.info("[Lead Update] Executing action");
|
|
32
30
|
winston.verbose("Execute ContactUpdate directive")
|
|
33
31
|
let action;
|
|
34
32
|
if (directive.action) {
|
|
@@ -39,11 +37,13 @@ class DirContactUpdate {
|
|
|
39
37
|
action.attributes.fillParams = true;
|
|
40
38
|
}
|
|
41
39
|
else {
|
|
40
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
42
41
|
winston.warn("DirContactUpdate Incorrect directive: ", directive);
|
|
43
42
|
callback();
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
this.go(action, () => {
|
|
46
|
+
this.logger.info("[Lead Update] Action completed");
|
|
47
47
|
callback();
|
|
48
48
|
});
|
|
49
49
|
}
|