@tiledesk/tiledesk-tybot-connector 2.0.10 → 2.0.12-rc1
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 +28 -16
- package/logs/app2.log +1882 -0
- package/package.json +3 -2
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +7 -0
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +17 -11
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +18 -2
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +21 -5
- package/tiledeskChatbotPlugs/directives/DirAssign.js +0 -9
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -8
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +13 -3
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +11 -8
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +10 -1
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +5 -0
- package/tiledeskChatbotPlugs/directives/DirClose.js +8 -9
- package/tiledeskChatbotPlugs/directives/DirCode.js +9 -1
- package/tiledeskChatbotPlugs/directives/DirCondition.js +13 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +11 -2
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -7
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +14 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -9
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +2 -8
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +88 -0
- package/tiledeskChatbotPlugs/directives/DirForm.js +3 -10
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +19 -7
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +2 -1
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +12 -3
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +3 -9
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +12 -10
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +11 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +3 -9
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +14 -4
- package/tiledeskChatbotPlugs/directives/DirMake.js +6 -1
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -7
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +5 -9
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -9
- package/tiledeskChatbotPlugs/directives/DirQapla.js +7 -3
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -7
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirReply.js +9 -16
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -10
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +7 -9
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +7 -2
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +7 -1
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +2 -8
- package/tiledeskChatbotPlugs/directives/DirWait.js +6 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +20 -5
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +2 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +8 -40
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +7 -1
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +2 -2
|
@@ -9,6 +9,7 @@ require('dotenv').config();
|
|
|
9
9
|
const winston = require('../../utils/winston');
|
|
10
10
|
const httpUtils = require("../../utils/HttpUtils");
|
|
11
11
|
const integrationService = require("../../services/IntegrationService");
|
|
12
|
+
const { Logger } = require("../../Logger");
|
|
12
13
|
|
|
13
14
|
class DirGptTask {
|
|
14
15
|
|
|
@@ -22,23 +23,27 @@ class DirGptTask {
|
|
|
22
23
|
this.requestId = this.context.requestId;
|
|
23
24
|
this.projectId = this.context.projectId;
|
|
24
25
|
this.token = this.context.token;
|
|
25
|
-
this.intentDir = new DirIntent(context);
|
|
26
26
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
this.intentDir = new DirIntent(context);
|
|
29
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
execute(directive, callback) {
|
|
33
|
+
this.logger.info("[ChatGPT Task] Executing action");
|
|
31
34
|
winston.verbose("Execute GptTask directive");
|
|
32
35
|
let action;
|
|
33
36
|
if (directive.action) {
|
|
34
37
|
action = directive.action;
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
40
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
37
41
|
winston.warn("DirGptTask Incorrect directive: ", directive);
|
|
38
42
|
callback();
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
41
45
|
this.go(action, (stop) => {
|
|
46
|
+
this.logger.info("[ChatGPT Task] Action completed");
|
|
42
47
|
callback(stop);
|
|
43
48
|
})
|
|
44
49
|
}
|
|
@@ -68,6 +73,7 @@ class DirGptTask {
|
|
|
68
73
|
let model = "gpt-3.5-turbo";
|
|
69
74
|
|
|
70
75
|
if (!action.question || action.question === '') {
|
|
76
|
+
this.logger.warn("[ChatGPT Task] question attribute is mandatory");
|
|
71
77
|
winston.debug("(DirGptTask) Error: question attribute is mandatory. Executing condition false...")
|
|
72
78
|
if (falseIntent) {
|
|
73
79
|
await this.chatbot.addParameter("flowError", "GPT Error: question attribute is undefined");
|
|
@@ -104,13 +110,13 @@ class DirGptTask {
|
|
|
104
110
|
this.context.tdcache,
|
|
105
111
|
this.context.requestId,
|
|
106
112
|
TiledeskChatbotConst.REQ_TRANSCRIPT_KEY);
|
|
107
|
-
winston.debug("(DirGptTask)
|
|
113
|
+
winston.debug("(DirGptTask) transcript string: " + transcript_string)
|
|
108
114
|
|
|
109
115
|
if (transcript_string) {
|
|
110
116
|
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
111
|
-
winston.debug("(DirGptTask)
|
|
117
|
+
winston.debug("(DirGptTask) transcript: ", transcript)
|
|
112
118
|
} else {
|
|
113
|
-
winston.debug("(DirGptTask)
|
|
119
|
+
winston.debug("(DirGptTask) transcript_string is undefined. Skip JSON translation for chat history");
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
|
|
@@ -119,17 +125,20 @@ class DirGptTask {
|
|
|
119
125
|
|
|
120
126
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
121
127
|
if (!key) {
|
|
128
|
+
this.logger.debug("[ChatGPT Task] Key not found in Integrations.");
|
|
122
129
|
winston.debug("(DirGptTask) - Key not found in Integrations. Searching in kb settings...");
|
|
123
130
|
key = await this.getKeyFromKbSettings();
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
if (!key) {
|
|
127
|
-
|
|
134
|
+
this.logger.debug("[ChatGPT Task] Retrieve shared gptkey.");
|
|
135
|
+
winston.debug("(DirGptTask) - Retrieve public gptkey")
|
|
128
136
|
key = process.env.GPTKEY;
|
|
129
137
|
publicKey = true;
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
if (!key) {
|
|
141
|
+
this.logger.error("[ChatGPT Task] OpenAI key is mandatory");
|
|
133
142
|
winston.error("(DirGptTask) gptkey is mandatory");
|
|
134
143
|
await this.#assignAttributes(action, answer);
|
|
135
144
|
if (falseIntent) {
|
|
@@ -145,7 +154,7 @@ class DirGptTask {
|
|
|
145
154
|
if (publicKey === true) {
|
|
146
155
|
let keep_going = await this.checkQuoteAvailability();
|
|
147
156
|
if (keep_going === false) {
|
|
148
|
-
|
|
157
|
+
this.logger.warn("[ChatGPT Task] OpenAI tokens quota exceeded");
|
|
149
158
|
await this.chatbot.addParameter("flowError", "GPT Error: tokens quota exceeded");
|
|
150
159
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
151
160
|
callback();
|
|
@@ -202,6 +211,7 @@ class DirGptTask {
|
|
|
202
211
|
if (err) {
|
|
203
212
|
winston.debug("(DirGptTask) openai err: ", err);
|
|
204
213
|
winston.debug("(DirGptTask) openai err: " + err.response?.data?.error?.message);
|
|
214
|
+
this.logger.error("[ChatGPT Task] Completions error: ", err.response?.data?.error?.message);
|
|
205
215
|
await this.#assignAttributes(action, answer);
|
|
206
216
|
if (falseIntent) {
|
|
207
217
|
await this.chatbot.addParameter("flowError", "GPT Error: " + err.response?.data?.error?.message);
|
|
@@ -219,6 +229,8 @@ class DirGptTask {
|
|
|
219
229
|
answer = await this.convertToJson(answer);
|
|
220
230
|
}
|
|
221
231
|
|
|
232
|
+
this.logger.debug("[ChatGPT Task] Completions answer: ", answer);
|
|
233
|
+
|
|
222
234
|
await this.#assignAttributes(action, answer);
|
|
223
235
|
|
|
224
236
|
if (publicKey === true) {
|
|
@@ -15,9 +15,10 @@ class DirGptTask {
|
|
|
15
15
|
this.context = context;
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
|
-
this.intentDir = new DirIntent(context);
|
|
19
18
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
20
19
|
this.log = context.log;
|
|
20
|
+
|
|
21
|
+
this.intentDir = new DirIntent(context);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
execute(directive, callback) {
|
|
@@ -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 DirHubspot {
|
|
11
12
|
|
|
@@ -18,23 +19,27 @@ class DirHubspot {
|
|
|
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
|
-
|
|
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 });
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
execute(directive, callback) {
|
|
29
|
+
this.logger.info("[Hubspot] Executing action");
|
|
27
30
|
winston.verbose("Execute Hubspot directive");
|
|
28
31
|
let action;
|
|
29
32
|
if (directive.action) {
|
|
30
33
|
action = directive.action;
|
|
31
34
|
}
|
|
32
35
|
else {
|
|
36
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
33
37
|
winston.warn("DirHubspot Incorrect directive: ", directive);
|
|
34
38
|
callback();
|
|
35
39
|
return;
|
|
36
40
|
}
|
|
37
41
|
this.go(action, (stop) => {
|
|
42
|
+
this.logger.info("[Hubspot] Action completed");
|
|
38
43
|
callback(stop);
|
|
39
44
|
})
|
|
40
45
|
}
|
|
@@ -68,6 +73,7 @@ class DirHubspot {
|
|
|
68
73
|
winston.debug("(DirHubspot) bodyParameters: ", bodyParameters);
|
|
69
74
|
|
|
70
75
|
if (!bodyParameters || bodyParameters === '') {
|
|
76
|
+
this.logger.error("[Hubspot] bodyParameters is undefined or null or empty string");
|
|
71
77
|
winston.error("(DirHubspot) Error: bodyParameters is undefined or null or empty string");
|
|
72
78
|
callback();
|
|
73
79
|
return;
|
|
@@ -78,7 +84,8 @@ class DirHubspot {
|
|
|
78
84
|
|
|
79
85
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'hubspot', this.token);
|
|
80
86
|
if (!key) {
|
|
81
|
-
|
|
87
|
+
this.logger.error("[Hubspot] Key not found in Integrations");
|
|
88
|
+
winston.debug("(DirHubspot) - Key not found in Integrations.");
|
|
82
89
|
if (falseIntent) {
|
|
83
90
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
84
91
|
callback(true);
|
|
@@ -113,6 +120,7 @@ class DirHubspot {
|
|
|
113
120
|
HUBSPOT_HTTPREQUEST, async (err, resbody) => {
|
|
114
121
|
if (err) {
|
|
115
122
|
if (callback) {
|
|
123
|
+
this.logger.error("[Hubspot] Error response: ", err.response);
|
|
116
124
|
winston.error("(DirHubspot) err response: ", err.response.data)
|
|
117
125
|
let result = null;
|
|
118
126
|
let status = null;
|
|
@@ -148,6 +156,7 @@ class DirHubspot {
|
|
|
148
156
|
let status = 201;
|
|
149
157
|
let error = null;
|
|
150
158
|
let result = resbody;
|
|
159
|
+
this.logger.error("[Hubspot] Result: ", result);
|
|
151
160
|
await this.#assignAttributes(action, status, result, error);
|
|
152
161
|
if (trueIntent) {
|
|
153
162
|
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes)
|
|
@@ -12,17 +12,11 @@ class DirIfOnlineAgents {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
this.context = context;
|
|
15
|
-
this.intentDir = new DirIntent(context);
|
|
16
15
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
16
|
this.log = context.log;
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
token: this.context.token,
|
|
22
|
-
APIURL: this.API_ENDPOINT,
|
|
23
|
-
APIKEY: "___",
|
|
24
|
-
log: this.log
|
|
25
|
-
});
|
|
17
|
+
|
|
18
|
+
this.intentDir = new DirIntent(context);
|
|
19
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
execute(directive, callback) {
|
|
@@ -6,6 +6,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
6
6
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const httpUtils = require('../../utils/HttpUtils');
|
|
9
|
+
const { Logger } = require('../../Logger');
|
|
9
10
|
|
|
10
11
|
class DirIfOnlineAgentsV2 {
|
|
11
12
|
|
|
@@ -15,32 +16,30 @@ class DirIfOnlineAgentsV2 {
|
|
|
15
16
|
}
|
|
16
17
|
this.context = context;
|
|
17
18
|
this.chatbot = context.chatbot;
|
|
18
|
-
this.
|
|
19
|
+
this.requestId = this.context.requestId;
|
|
19
20
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
token: this.context.token,
|
|
25
|
-
APIURL: this.API_ENDPOINT,
|
|
26
|
-
APIKEY: "___",
|
|
27
|
-
log: this.log
|
|
28
|
-
});
|
|
21
|
+
|
|
22
|
+
this.intentDir = new DirIntent(context);
|
|
23
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
24
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
29
25
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
execute(directive, callback) {
|
|
29
|
+
this.logger.info("[If Online Agents] Executing action");
|
|
33
30
|
winston.verbose("Execute IfOnlineAgentsV2 directive");
|
|
34
31
|
let action;
|
|
35
32
|
if (directive.action) {
|
|
36
33
|
action = directive.action
|
|
37
34
|
}
|
|
38
35
|
else {
|
|
36
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
39
37
|
winston.warn("DirIfOnlineAgentsV2 Incorrect directive: ", directive);
|
|
40
38
|
callback();
|
|
41
39
|
return;
|
|
42
40
|
}
|
|
43
41
|
this.go(action, (stop) => {
|
|
42
|
+
this.logger.info("[If Online Agents] Action completed");
|
|
44
43
|
callback(stop);
|
|
45
44
|
});
|
|
46
45
|
}
|
|
@@ -49,6 +48,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
49
48
|
winston.debug("(DirIfOnlineAgentsV2) Action: ", action);
|
|
50
49
|
|
|
51
50
|
if (!action.trueIntent && !action.falseIntent) {
|
|
51
|
+
this.logger.error("[If Online Agents] missing both action.trueIntent & action.falseIntent");
|
|
52
52
|
winston.error("(DirIfOnlineAgentsV2) Error: missing both action.trueIntent & action.falseIntent");
|
|
53
53
|
callback();
|
|
54
54
|
return;
|
|
@@ -93,6 +93,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
93
93
|
if (departmentId) {
|
|
94
94
|
agents = await this.getProjectAvailableAgents(departmentId, true);
|
|
95
95
|
} else {
|
|
96
|
+
this.logger.error("[If Online Agents] No departmentId found in attributes");
|
|
96
97
|
winston.error("(DirIfOnlineAgentsV2) no departmentId found in attributes");
|
|
97
98
|
await this.chatbot.addParameter("flowError", "(If online Agents) No departmentId found in attributes.");
|
|
98
99
|
if (falseIntent) { // no agents available
|
|
@@ -156,6 +157,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
catch(err) {
|
|
160
|
+
this.logger.error("[If Online Agents] An error occurred: ", err);
|
|
159
161
|
winston.error("(DirIfOnlineAgentsV2) An error occurred: ", err);
|
|
160
162
|
this.chatbot.addParameter("flowError", "(If online Agents) An error occurred: " + err);
|
|
161
163
|
callback();
|
|
@@ -5,6 +5,7 @@ let https = require("https");
|
|
|
5
5
|
const ms = require('minimist-string');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
7
|
const httpUtils = require('../../utils/HttpUtils');
|
|
8
|
+
const { Logger } = require('../../Logger');
|
|
8
9
|
|
|
9
10
|
class DirIfOpenHours {
|
|
10
11
|
|
|
@@ -14,12 +15,15 @@ class DirIfOpenHours {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
this.context = context;
|
|
18
|
+
this.requestId = this.context.requestId;
|
|
17
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
|
+
|
|
18
21
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.
|
|
22
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
execute(directive, callback) {
|
|
26
|
+
this.logger.info("[If Operating Hours] Executing action");
|
|
23
27
|
winston.verbose("Execute IfOpenHours directive");
|
|
24
28
|
let action;
|
|
25
29
|
if (directive.action) {
|
|
@@ -39,11 +43,13 @@ class DirIfOpenHours {
|
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
46
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
42
47
|
winston.warn("DirIfOpenHours Incorrect directive: ", directive);
|
|
43
48
|
callback();
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
51
|
this.go(action, (stop) => {
|
|
52
|
+
this.logger.info("[If Operating Hours] Action complteted");
|
|
47
53
|
callback(stop);
|
|
48
54
|
});
|
|
49
55
|
}
|
|
@@ -65,6 +71,7 @@ class DirIfOpenHours {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
if (!trueIntent && !falseIntent) {
|
|
74
|
+
this.logger.error("[If Operating Hours] Invalid condition, no intents specified");
|
|
68
75
|
winston.error("(DirIfOpenHours) Invalid condition, no intents specified");
|
|
69
76
|
callback();
|
|
70
77
|
return;
|
|
@@ -96,6 +103,7 @@ class DirIfOpenHours {
|
|
|
96
103
|
winston.debug("(DirIfOpenHours) resbody:", resbody);
|
|
97
104
|
|
|
98
105
|
if (err) {
|
|
106
|
+
this.logger.error("[If Operating Hours] Error response: ", err.response);
|
|
99
107
|
winston.debug("(DirIfOpenHours) error: ", err);
|
|
100
108
|
if (callback) {
|
|
101
109
|
if (falseIntent) {
|
|
@@ -108,6 +116,7 @@ class DirIfOpenHours {
|
|
|
108
116
|
}
|
|
109
117
|
} else {
|
|
110
118
|
if (resbody.isopen && resbody.isopen === true) {
|
|
119
|
+
this.logger.debug("[If Operating Hours] is open: true")
|
|
111
120
|
if (trueIntent) {
|
|
112
121
|
let intentDirective = DirIntent.intentDirectiveFor(trueIntent);
|
|
113
122
|
winston.debug("(DirIfOpenHours) agents (openHours) => trueIntent");
|
|
@@ -118,6 +127,7 @@ class DirIfOpenHours {
|
|
|
118
127
|
callback();
|
|
119
128
|
return;
|
|
120
129
|
} else {
|
|
130
|
+
this.logger.debug("[If Operating Hours] is open: false")
|
|
121
131
|
if (falseIntent) {
|
|
122
132
|
let intentDirective = DirIntent.intentDirectiveFor(falseIntent);
|
|
123
133
|
winston.debug("(DirIfOpenHours) !agents (openHours) => falseIntent", falseIntent);
|
|
@@ -10,17 +10,11 @@ class DirIfOpenHours {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
this.context = context;
|
|
13
|
-
this.intentDir = new DirIntent(context);
|
|
14
13
|
this.log = context.log;
|
|
15
|
-
|
|
16
14
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___",
|
|
22
|
-
log: this.log
|
|
23
|
-
});
|
|
15
|
+
|
|
16
|
+
this.intentDir = new DirIntent(context);
|
|
17
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
execute(directive, callback) {
|
|
@@ -2,6 +2,7 @@ const { DirIntent } = require('./DirIntent');
|
|
|
2
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
|
+
const { Logger } = require('../../Logger');
|
|
5
6
|
|
|
6
7
|
class DirJSONCondition {
|
|
7
8
|
|
|
@@ -11,23 +12,27 @@ class DirJSONCondition {
|
|
|
11
12
|
}
|
|
12
13
|
this.context = context;
|
|
13
14
|
this.chatbot = context.chatbot;
|
|
14
|
-
this.
|
|
15
|
+
this.requestId = this.context.requestId;
|
|
16
|
+
|
|
15
17
|
this.intentDir = new DirIntent(context);
|
|
16
|
-
this.
|
|
18
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
execute(directive, callback) {
|
|
22
|
+
this.logger.info("[Condition] Executing action");
|
|
20
23
|
winston.verbose("Execute JSONCondition directive");
|
|
21
24
|
let action;
|
|
22
25
|
if (directive.action) {
|
|
23
26
|
action = directive.action
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
29
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
26
30
|
winston.warn("DirJSONCondition Incorrect directive: ", directive);
|
|
27
31
|
callback();
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
30
34
|
this.go(action, (stop) => {
|
|
35
|
+
this.logger.info("[Condition] Action completed");
|
|
31
36
|
callback(stop);
|
|
32
37
|
});
|
|
33
38
|
|
|
@@ -50,11 +55,13 @@ class DirJSONCondition {
|
|
|
50
55
|
falseIntent = null;
|
|
51
56
|
}
|
|
52
57
|
if (!trueIntent && !falseIntent) {
|
|
58
|
+
this.logger.warn("[Condition] Invalid jsonCondition, no intents specified");
|
|
53
59
|
winston.warn("(DirJSONCondition) Invalid jsonCondition, no intents specified");
|
|
54
60
|
callback();
|
|
55
61
|
return;
|
|
56
62
|
}
|
|
57
63
|
else if (groups === null) {
|
|
64
|
+
this.logger.warn("[Condition] Invalid jsonCondition, no groups");
|
|
58
65
|
winston.warn("(DirJSONCondition) Invalid jsonCondition, no groups.");
|
|
59
66
|
callback();
|
|
60
67
|
return;
|
|
@@ -81,9 +88,9 @@ class DirJSONCondition {
|
|
|
81
88
|
// const result = await this.evaluateCondition(scriptCondition, variables);
|
|
82
89
|
let result;
|
|
83
90
|
const expression = TiledeskExpression.JSONGroupsToExpression(groups, variables);
|
|
84
|
-
|
|
91
|
+
this.logger.debug("[Condition] Evaluating expression: ", expression);
|
|
85
92
|
result = new TiledeskExpression().evaluateStaticExpression(expression, variables);
|
|
86
|
-
winston.debug("(DirJSONCondition)
|
|
93
|
+
winston.debug("(DirJSONCondition) Evaluation result: ", result);
|
|
87
94
|
if (result === true) {
|
|
88
95
|
if (trueIntentDirective) {
|
|
89
96
|
this.intentDir.execute(trueIntentDirective, () => {
|
|
@@ -91,6 +98,7 @@ class DirJSONCondition {
|
|
|
91
98
|
});
|
|
92
99
|
}
|
|
93
100
|
else {
|
|
101
|
+
this.logger.debug("[Condition] No trueIntentDirective specified");
|
|
94
102
|
winston.debug("(DirJSONCondition) No trueIntentDirective specified");
|
|
95
103
|
callback();
|
|
96
104
|
return;
|
|
@@ -98,6 +106,7 @@ class DirJSONCondition {
|
|
|
98
106
|
}
|
|
99
107
|
else {
|
|
100
108
|
if (result === null) {
|
|
109
|
+
this.logger.error("[Condition] An error occurred evaluating the condition");
|
|
101
110
|
await this.chatbot.addParameter("flowError", "An error occurred evaluating condition: result === null");
|
|
102
111
|
}
|
|
103
112
|
if (falseIntentDirective) {
|
|
@@ -106,6 +115,7 @@ class DirJSONCondition {
|
|
|
106
115
|
});
|
|
107
116
|
}
|
|
108
117
|
else {
|
|
118
|
+
this.logger.debug("[Condition] No falseIntentDirective specified");
|
|
109
119
|
winston.debug("(DirJSONCondition) No falseIntentDirective specified");
|
|
110
120
|
callback();
|
|
111
121
|
return;
|
|
@@ -5,6 +5,7 @@ const { DirIntent } = require("./DirIntent");
|
|
|
5
5
|
let https = require("https");
|
|
6
6
|
require('dotenv').config();
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const { Logger } = require("../../Logger");
|
|
8
9
|
|
|
9
10
|
class DirMake {
|
|
10
11
|
|
|
@@ -15,22 +16,26 @@ class DirMake {
|
|
|
15
16
|
this.context = context;
|
|
16
17
|
this.tdcache = this.context.tdcache;
|
|
17
18
|
this.requestId = this.context.requestId;
|
|
19
|
+
|
|
18
20
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.
|
|
21
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
execute(directive, callback) {
|
|
25
|
+
this.logger.info("[Make] Executing action");
|
|
23
26
|
winston.verbose("Execute Make directive");
|
|
24
27
|
let action;
|
|
25
28
|
if (directive.action) {
|
|
26
29
|
action = directive.action;
|
|
27
30
|
}
|
|
28
31
|
else {
|
|
32
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
29
33
|
winston.warn("DirMake Incorrect directive: ", directive);
|
|
30
34
|
callback();
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
37
|
this.go(action, (stop) => {
|
|
38
|
+
this.logger.info("[Make] Action completed");
|
|
34
39
|
callback(stop);
|
|
35
40
|
})
|
|
36
41
|
}
|
|
@@ -19,13 +19,7 @@ class DirMessage {
|
|
|
19
19
|
this.log = this.context.log;
|
|
20
20
|
this.supportRequest = this.context.supportRequest
|
|
21
21
|
|
|
22
|
-
this.tdClient = new TiledeskClient({
|
|
23
|
-
projectId: this.context.projectId,
|
|
24
|
-
token: this.context.token,
|
|
25
|
-
APIURL: this.API_ENDPOINT,
|
|
26
|
-
APIKEY: "___",
|
|
27
|
-
log: this.log
|
|
28
|
-
});
|
|
22
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
execute(directive, callback) {
|
|
@@ -4,6 +4,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
4
4
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
|
+
const { Logger } = require('../../Logger');
|
|
7
8
|
|
|
8
9
|
class DirMoveToAgent {
|
|
9
10
|
|
|
@@ -14,23 +15,18 @@ class DirMoveToAgent {
|
|
|
14
15
|
this.context = context;
|
|
15
16
|
this.tdcache = context.tdcache;
|
|
16
17
|
this.requestId = context.requestId;
|
|
17
|
-
this.log = context.log;
|
|
18
|
-
|
|
19
18
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
|
-
this.tdClient = new TiledeskClient({
|
|
21
|
-
projectId: this.context.projectId,
|
|
22
|
-
token: this.context.token,
|
|
23
|
-
APIURL: this.API_ENDPOINT,
|
|
24
|
-
APIKEY: "___",
|
|
25
|
-
log: this.log
|
|
26
|
-
});
|
|
27
19
|
|
|
20
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
21
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
execute(directive, callback) {
|
|
25
|
+
this.logger.info("[Transfer to a Human] Executing action");
|
|
31
26
|
winston.verbose("Execute MoveToAgent directive");
|
|
32
27
|
directive.action = {};
|
|
33
28
|
this.go(directive.action, () => {
|
|
29
|
+
this.logger.info("[Transfer to a Human] Action completed");
|
|
34
30
|
callback();
|
|
35
31
|
});
|
|
36
32
|
}
|
|
@@ -4,6 +4,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
4
4
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
|
+
const { Logger } = require('../../Logger');
|
|
7
8
|
|
|
8
9
|
class DirMoveToUnassigned {
|
|
9
10
|
|
|
@@ -13,22 +14,18 @@ class DirMoveToUnassigned {
|
|
|
13
14
|
}
|
|
14
15
|
this.context = context;
|
|
15
16
|
this.requestId = context.requestId;
|
|
16
|
-
this.log = context.log;
|
|
17
|
-
|
|
18
17
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
APIURL: this.API_ENDPOINT,
|
|
23
|
-
APIKEY: "___",
|
|
24
|
-
log: this.log
|
|
25
|
-
});
|
|
18
|
+
|
|
19
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
20
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
execute(directive, callback) {
|
|
24
|
+
this.logger.info("[Move to Unassigned] Executing action");
|
|
29
25
|
winston.verbose("Execute MoveToUnassigned directive");
|
|
30
26
|
directive.action = {};
|
|
31
27
|
this.go(directive.action, () => {
|
|
28
|
+
this.logger.info("[Move to Unassigned] Action completed");
|
|
32
29
|
callback();
|
|
33
30
|
});
|
|
34
31
|
}
|
|
@@ -7,6 +7,7 @@ require('dotenv').config();
|
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const httpUtils = require("../../utils/HttpUtils");
|
|
9
9
|
const integrationService = require("../../services/IntegrationService");
|
|
10
|
+
const { Logger } = require("../../Logger");
|
|
10
11
|
|
|
11
12
|
class DirQapla {
|
|
12
13
|
|
|
@@ -19,23 +20,26 @@ class DirQapla {
|
|
|
19
20
|
this.requestId = this.context.requestId;
|
|
20
21
|
this.projectId = this.context.projectId;
|
|
21
22
|
this.token = this.context.token;
|
|
22
|
-
this.intentDir = new DirIntent(context);
|
|
23
23
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
this.intentDir = new DirIntent(context);
|
|
26
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
execute(directive, callback) {
|
|
28
|
-
|
|
30
|
+
this.logger.info("[Qapla] Executing action");
|
|
29
31
|
let action;
|
|
30
32
|
if (directive.action) {
|
|
31
33
|
action = directive.action;
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
36
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
34
37
|
winston.warn("DirQapla Incorrect directive: ", directive);
|
|
35
38
|
callback();
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
41
|
this.go(action, (stop) => {
|
|
42
|
+
this.logger.info("[Qapla] Action completed");
|
|
39
43
|
callback(stop);
|
|
40
44
|
})
|
|
41
45
|
}
|
|
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
3
3
|
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
4
4
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
|
+
const { Logger } = require('../../Logger');
|
|
6
7
|
|
|
7
8
|
class DirRandomReply {
|
|
8
9
|
|
|
@@ -15,19 +16,14 @@ class DirRandomReply {
|
|
|
15
16
|
this.requestId = context.requestId;
|
|
16
17
|
this.token = context.token;
|
|
17
18
|
this.tdcache = context.tdcache;
|
|
18
|
-
this.log = context.log;
|
|
19
|
-
|
|
20
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___",
|
|
26
|
-
log: this.log
|
|
27
|
-
});
|
|
20
|
+
|
|
21
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
22
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
execute(directive, callback) {
|
|
26
|
+
this.logger.info("[Random Reply] Executing action");
|
|
31
27
|
winston.verbose("Execute RandomReply directive");
|
|
32
28
|
let action;
|
|
33
29
|
if (directive.action) {
|
|
@@ -38,11 +34,13 @@ class DirRandomReply {
|
|
|
38
34
|
action.attributes.fillParams = true;
|
|
39
35
|
}
|
|
40
36
|
else {
|
|
37
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
41
38
|
winston.warn("DirRandomReply Incorrect directive: ", directive);
|
|
42
39
|
callback();
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
42
|
this.go(action, () => {
|
|
43
|
+
this.logger.info("[Random Reply] Action completed");
|
|
46
44
|
callback();
|
|
47
45
|
});
|
|
48
46
|
}
|