@tiledesk/tiledesk-tybot-connector 2.0.10-rc11 → 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 +10 -11
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +14 -15
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +12 -13
- 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/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 +9 -8
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +4 -3
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +6 -0
|
@@ -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,13 @@ class DirCondition {
|
|
|
11
12
|
throw new Error('context object is mandatory.');
|
|
12
13
|
}
|
|
13
14
|
this.context = context;
|
|
15
|
+
this.requestId = this.context.requestId;
|
|
14
16
|
this.intentDir = new DirIntent(context);
|
|
17
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
execute(directive, callback) {
|
|
21
|
+
this.logger.info("[Condition] Executing action");
|
|
18
22
|
winston.verbose("Execute Condition directive");
|
|
19
23
|
let action;
|
|
20
24
|
if (directive.action) {
|
|
@@ -34,11 +38,13 @@ class DirCondition {
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
else {
|
|
41
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
37
42
|
winston.warn("DirCondition Incorrect directive: ", directive);
|
|
38
43
|
callback();
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
46
|
this.go(action, (stop) => {
|
|
47
|
+
this.logger.info("[Condition] Action completed");
|
|
42
48
|
callback(stop);
|
|
43
49
|
});
|
|
44
50
|
|
|
@@ -63,21 +69,25 @@ class DirCondition {
|
|
|
63
69
|
}
|
|
64
70
|
winston.debug("(DirCondition) condition action: ", action);
|
|
65
71
|
if (!trueIntent && !falseIntent) {
|
|
72
|
+
this.logger.error("[Condition] Invalid condition, no intents specified");
|
|
66
73
|
winston.error("(DirCondition) Invalid condition, no intents specified");
|
|
67
74
|
callback();
|
|
68
75
|
return;
|
|
69
76
|
}
|
|
70
77
|
if (scriptCondition === null && jsonCondition === null) {
|
|
78
|
+
this.logger.error("[Condition] Invalid condition, scriptCondition & jsonCondition null");
|
|
71
79
|
winston.error("(DirCondition) Invalid condition, scriptCondition & jsonCondition null");
|
|
72
80
|
callback();
|
|
73
81
|
return;
|
|
74
82
|
}
|
|
75
83
|
if (scriptCondition !== null && scriptCondition.trim === "") {
|
|
84
|
+
this.logger.error("[Condition] Invalid condition, scriptCondition is empty");
|
|
76
85
|
winston.error("(DirCondition) Invalid condition, scriptCondition is empty");
|
|
77
86
|
callback();
|
|
78
87
|
return;
|
|
79
88
|
}
|
|
80
89
|
else if (jsonCondition && jsonCondition.groups === null) {
|
|
90
|
+
this.logger.error("[Condition] Invalid jsonCondition, no groups");
|
|
81
91
|
winston.error("(DirCondition) Invalid jsonCondition, no groups:", jsonCondition);
|
|
82
92
|
callback();
|
|
83
93
|
return;
|
|
@@ -120,6 +130,7 @@ class DirCondition {
|
|
|
120
130
|
});
|
|
121
131
|
}
|
|
122
132
|
else {
|
|
133
|
+
this.logger.debug("[Condition] No trueIntentDirective specified");
|
|
123
134
|
winston.debug("(DirCondition) No trueIntentDirective specified");
|
|
124
135
|
callback();
|
|
125
136
|
return;
|
|
@@ -132,6 +143,7 @@ class DirCondition {
|
|
|
132
143
|
});
|
|
133
144
|
}
|
|
134
145
|
else {
|
|
146
|
+
this.logger.debug("[Condition] No falseIntentDirective specified");
|
|
135
147
|
winston.debug("(DirCondition) No falseIntentDirective specified");
|
|
136
148
|
callback();
|
|
137
149
|
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,6 +20,7 @@ class DirContactUpdate {
|
|
|
19
20
|
this.token = context.token;
|
|
20
21
|
this.tdcache = context.tdcache;
|
|
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
|
this.tdClient = new TiledeskClient({
|
|
24
26
|
projectId: this.context.projectId,
|
|
@@ -29,6 +31,7 @@ class DirContactUpdate {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
execute(directive, callback) {
|
|
34
|
+
this.logger.info("[Lead Update] Executing action");
|
|
32
35
|
winston.verbose("Execute ContactUpdate directive")
|
|
33
36
|
let action;
|
|
34
37
|
if (directive.action) {
|
|
@@ -39,11 +42,13 @@ class DirContactUpdate {
|
|
|
39
42
|
action.attributes.fillParams = true;
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
45
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
42
46
|
winston.warn("DirContactUpdate Incorrect directive: ", directive);
|
|
43
47
|
callback();
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
46
50
|
this.go(action, () => {
|
|
51
|
+
this.logger.info("[Lead Update] Action completed");
|
|
47
52
|
callback();
|
|
48
53
|
});
|
|
49
54
|
}
|
|
@@ -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 DirCustomerio {
|
|
11
12
|
|
|
@@ -20,20 +21,24 @@ class DirCustomerio {
|
|
|
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("[Customer.io] Executing action");
|
|
26
29
|
winston.verbose("Execute Customerio 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("DirCustomerio Incorrect directive: ", directive);
|
|
33
37
|
callback();
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
this.go(action, (stop) => {
|
|
41
|
+
this.logger.info("[Customer.io] Action completed");
|
|
37
42
|
callback(stop);
|
|
38
43
|
})
|
|
39
44
|
}
|
|
@@ -65,6 +70,7 @@ class DirCustomerio {
|
|
|
65
70
|
winston.debug("(DirCustomerio) bodyParameters: ", bodyParameters);
|
|
66
71
|
|
|
67
72
|
if (!bodyParameters || bodyParameters === '') {
|
|
73
|
+
this.logger.error("[Customer.io] bodyParameters is undefined or null or empty string");
|
|
68
74
|
winston.debug("(DirCustomerio) Error: bodyParameters is undefined or null or empty string");
|
|
69
75
|
callback();
|
|
70
76
|
return;
|
|
@@ -75,6 +81,7 @@ class DirCustomerio {
|
|
|
75
81
|
|
|
76
82
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'customerio', this.token);
|
|
77
83
|
if (!key) {
|
|
84
|
+
this.logger.error("[Customer.io] Key not found in Integrations");
|
|
78
85
|
winston.debug("(DirCustomerio) - Key not found in Integrations.");
|
|
79
86
|
let status = 422;
|
|
80
87
|
let error = 'Missing customerio access token';
|
|
@@ -116,6 +123,7 @@ class DirCustomerio {
|
|
|
116
123
|
CUSTOMERIO_HTTPREQUEST, async (err, resbody) => {
|
|
117
124
|
if (err) {
|
|
118
125
|
if (callback) {
|
|
126
|
+
this.logger.error("[Customer.io] Error response: ", err.response);
|
|
119
127
|
winston.debug("(DirCustomerio) err response:", err.response)
|
|
120
128
|
winston.debug("(DirCustomerio) err data:", err.response.data)
|
|
121
129
|
|
|
@@ -150,6 +158,7 @@ class DirCustomerio {
|
|
|
150
158
|
|
|
151
159
|
let status = 204;
|
|
152
160
|
let error = null;
|
|
161
|
+
this.logger.error("[Customer.io] Response status: ", status);
|
|
153
162
|
await this.#assignAttributes(action, status, error);
|
|
154
163
|
if (trueIntent) {
|
|
155
164
|
await this.#executeCondition(true, trueIntent, null, falseIntent, null);
|
|
@@ -3,6 +3,7 @@ const ms = require('minimist-string');
|
|
|
3
3
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
4
|
const { Filler } = require('../Filler');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
|
+
const { Logger } = require('../../Logger');
|
|
6
7
|
|
|
7
8
|
class DirDeleteVariable {
|
|
8
9
|
|
|
@@ -11,9 +12,12 @@ class DirDeleteVariable {
|
|
|
11
12
|
throw new Error('context object is mandatory.');
|
|
12
13
|
}
|
|
13
14
|
this.context = context;
|
|
15
|
+
this.requestId = this.context.requestId;
|
|
16
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
async execute(directive, callback) {
|
|
20
|
+
this.logger.info("[Delete Attribute] Executing action");
|
|
17
21
|
winston.verbose("Execute DeleteVariable directive");
|
|
18
22
|
let action;
|
|
19
23
|
if (directive.action) {
|
|
@@ -24,7 +28,14 @@ class DirDeleteVariable {
|
|
|
24
28
|
variableName: directive.parameter
|
|
25
29
|
}
|
|
26
30
|
}
|
|
31
|
+
else {
|
|
32
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
33
|
+
winston.warn("(DirDeleteVariable) Incorrect directive: ", directive);
|
|
34
|
+
callback();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
27
37
|
this.go(action, () => {
|
|
38
|
+
this.logger.info("[Delete Attribute] Action completed");
|
|
28
39
|
callback();
|
|
29
40
|
});
|
|
30
41
|
}
|
|
@@ -34,6 +45,7 @@ class DirDeleteVariable {
|
|
|
34
45
|
|
|
35
46
|
let variableName = action.variableName;
|
|
36
47
|
if (!variableName) {
|
|
48
|
+
this.logger.warn("[Delete Attribute] Missing 'variableName'. Skip")
|
|
37
49
|
winston.error("(DirDeleteVariable) deleting variable. Missing 'variableName' error. Skipping");
|
|
38
50
|
if (callback) {
|
|
39
51
|
callback();
|
|
@@ -59,6 +71,7 @@ class DirDeleteVariable {
|
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
catch(err) {
|
|
74
|
+
this.logger.error("[Delete Attribute] Error deleting attribute");
|
|
62
75
|
winston.error("(DirDeleteVariable) error: ", err);
|
|
63
76
|
if (completion) {
|
|
64
77
|
completion();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { TiledeskClient } = require("@tiledesk/tiledesk-client");
|
|
2
2
|
const winston = require('../../utils/winston');
|
|
3
|
+
const { Logger } = require("../../Logger");
|
|
3
4
|
|
|
4
5
|
class DirDepartment {
|
|
5
6
|
|
|
@@ -10,6 +11,8 @@ class DirDepartment {
|
|
|
10
11
|
this.context = context;
|
|
11
12
|
this.requestId = context.requestId;
|
|
12
13
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
14
|
+
this.log = context.log;
|
|
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
|
this.tdClient = new TiledeskClient({
|
|
15
18
|
projectId: this.context.projectId,
|
|
@@ -20,6 +23,7 @@ class DirDepartment {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
execute(directive, callback) {
|
|
26
|
+
this.logger.info("[Change Department] Executing action");
|
|
23
27
|
winston.verbose("Execute Department directive");
|
|
24
28
|
let action;
|
|
25
29
|
if (directive.action) {
|
|
@@ -35,6 +39,7 @@ class DirDepartment {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
this.go(action, () => {
|
|
42
|
+
this.logger.info("[Change Department] Action executed");
|
|
38
43
|
callback();
|
|
39
44
|
});
|
|
40
45
|
|
|
@@ -64,6 +69,7 @@ class DirDepartment {
|
|
|
64
69
|
const depName = action.depName;
|
|
65
70
|
this.moveToDepartment(this.requestId, depName, (deps) => {
|
|
66
71
|
if (!deps) {
|
|
72
|
+
this.logger.warn("[Change Department] Department not found");
|
|
67
73
|
winston.warn("(DirDepartment) Dep not found");
|
|
68
74
|
callback();
|
|
69
75
|
return
|
|
@@ -92,14 +98,19 @@ class DirDepartment {
|
|
|
92
98
|
this.requestId,
|
|
93
99
|
message, (err) => {
|
|
94
100
|
if (err) {
|
|
101
|
+
this.logger.error("[Change Department] Unable to trigger bot");
|
|
95
102
|
winston.error("(DirDepartment) Error sending hidden message: " + err.message)
|
|
103
|
+
} else {
|
|
104
|
+
this.logger.verbose("[Change Department] Bot triggered");
|
|
105
|
+
winston.debug("(DirDepartment) Hidden message sent.");
|
|
106
|
+
|
|
96
107
|
}
|
|
97
|
-
winston.debug("(DirDepartment) Hidden message sent.");
|
|
98
108
|
callback();
|
|
99
109
|
});
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
112
|
else {
|
|
113
|
+
this.logger.verbose("[Change Department] No triggering bot");
|
|
103
114
|
winston.debug("(DirDepartment) No action.triggerBot");
|
|
104
115
|
callback();
|
|
105
116
|
}
|
|
@@ -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
|
|
|
@@ -24,20 +25,24 @@ class DirGptTask {
|
|
|
24
25
|
this.token = this.context.token;
|
|
25
26
|
this.intentDir = new DirIntent(context);
|
|
26
27
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
28
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft, intent_id: this.context.reply.attributes.intent_info.intent_id });
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
execute(directive, callback) {
|
|
32
|
+
this.logger.info("[ChatGPT Task] Executing action");
|
|
30
33
|
winston.verbose("Execute GptTask directive");
|
|
31
34
|
let action;
|
|
32
35
|
if (directive.action) {
|
|
33
36
|
action = directive.action;
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
39
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
36
40
|
winston.warn("DirGptTask Incorrect directive: ", directive);
|
|
37
41
|
callback();
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
44
|
this.go(action, (stop) => {
|
|
45
|
+
this.logger.info("[ChatGPT Task] Action completed");
|
|
41
46
|
callback(stop);
|
|
42
47
|
})
|
|
43
48
|
}
|
|
@@ -67,6 +72,7 @@ class DirGptTask {
|
|
|
67
72
|
let model = "gpt-3.5-turbo";
|
|
68
73
|
|
|
69
74
|
if (!action.question || action.question === '') {
|
|
75
|
+
this.logger.warn("[ChatGPT Task] question attribute is mandatory");
|
|
70
76
|
winston.debug("(DirGptTask) Error: question attribute is mandatory. Executing condition false...")
|
|
71
77
|
if (falseIntent) {
|
|
72
78
|
await this.chatbot.addParameter("flowError", "GPT Error: question attribute is undefined");
|
|
@@ -103,13 +109,13 @@ class DirGptTask {
|
|
|
103
109
|
this.context.tdcache,
|
|
104
110
|
this.context.requestId,
|
|
105
111
|
TiledeskChatbotConst.REQ_TRANSCRIPT_KEY);
|
|
106
|
-
winston.debug("(DirGptTask)
|
|
112
|
+
winston.debug("(DirGptTask) transcript string: " + transcript_string)
|
|
107
113
|
|
|
108
114
|
if (transcript_string) {
|
|
109
115
|
transcript = await TiledeskChatbotUtil.transcriptJSON(transcript_string);
|
|
110
|
-
winston.debug("(DirGptTask)
|
|
116
|
+
winston.debug("(DirGptTask) transcript: ", transcript)
|
|
111
117
|
} else {
|
|
112
|
-
winston.debug("(DirGptTask)
|
|
118
|
+
winston.debug("(DirGptTask) transcript_string is undefined. Skip JSON translation for chat history");
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
|
|
@@ -118,17 +124,20 @@ class DirGptTask {
|
|
|
118
124
|
|
|
119
125
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'openai', this.token);
|
|
120
126
|
if (!key) {
|
|
127
|
+
this.logger.debug("[ChatGPT Task] Key not found in Integrations.");
|
|
121
128
|
winston.debug("(DirGptTask) - Key not found in Integrations. Searching in kb settings...");
|
|
122
129
|
key = await this.getKeyFromKbSettings();
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
if (!key) {
|
|
126
|
-
|
|
133
|
+
this.logger.debug("[ChatGPT Task] Retrieve shared gptkey.");
|
|
134
|
+
winston.debug("(DirGptTask) - Retrieve public gptkey")
|
|
127
135
|
key = process.env.GPTKEY;
|
|
128
136
|
publicKey = true;
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
if (!key) {
|
|
140
|
+
this.logger.error("[ChatGPT Task] OpenAI key is mandatory");
|
|
132
141
|
winston.error("(DirGptTask) gptkey is mandatory");
|
|
133
142
|
await this.#assignAttributes(action, answer);
|
|
134
143
|
if (falseIntent) {
|
|
@@ -144,7 +153,7 @@ class DirGptTask {
|
|
|
144
153
|
if (publicKey === true) {
|
|
145
154
|
let keep_going = await this.checkQuoteAvailability();
|
|
146
155
|
if (keep_going === false) {
|
|
147
|
-
|
|
156
|
+
this.logger.warn("[ChatGPT Task] OpenAI tokens quota exceeded");
|
|
148
157
|
await this.chatbot.addParameter("flowError", "GPT Error: tokens quota exceeded");
|
|
149
158
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
150
159
|
callback();
|
|
@@ -201,6 +210,7 @@ class DirGptTask {
|
|
|
201
210
|
if (err) {
|
|
202
211
|
winston.debug("(DirGptTask) openai err: ", err);
|
|
203
212
|
winston.debug("(DirGptTask) openai err: " + err.response?.data?.error?.message);
|
|
213
|
+
this.logger.error("[ChatGPT Task] Completions error: ", err.response?.data?.error?.message);
|
|
204
214
|
await this.#assignAttributes(action, answer);
|
|
205
215
|
if (falseIntent) {
|
|
206
216
|
await this.chatbot.addParameter("flowError", "GPT Error: " + err.response?.data?.error?.message);
|
|
@@ -218,6 +228,8 @@ class DirGptTask {
|
|
|
218
228
|
answer = await this.convertToJson(answer);
|
|
219
229
|
}
|
|
220
230
|
|
|
231
|
+
this.logger.debug("[ChatGPT Task] Completions answer: ", answer);
|
|
232
|
+
|
|
221
233
|
await this.#assignAttributes(action, answer);
|
|
222
234
|
|
|
223
235
|
if (publicKey === true) {
|
|
@@ -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
|
|
|
@@ -20,20 +21,24 @@ class DirHubspot {
|
|
|
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("[Hubspot] Executing action");
|
|
26
29
|
winston.verbose("Execute Hubspot 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("DirHubspot Incorrect directive: ", directive);
|
|
33
37
|
callback();
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
this.go(action, (stop) => {
|
|
41
|
+
this.logger.info("[Hubspot] Action completed");
|
|
37
42
|
callback(stop);
|
|
38
43
|
})
|
|
39
44
|
}
|
|
@@ -67,6 +72,7 @@ class DirHubspot {
|
|
|
67
72
|
winston.debug("(DirHubspot) bodyParameters: ", bodyParameters);
|
|
68
73
|
|
|
69
74
|
if (!bodyParameters || bodyParameters === '') {
|
|
75
|
+
this.logger.error("[Hubspot] bodyParameters is undefined or null or empty string");
|
|
70
76
|
winston.error("(DirHubspot) Error: bodyParameters is undefined or null or empty string");
|
|
71
77
|
callback();
|
|
72
78
|
return;
|
|
@@ -77,7 +83,8 @@ class DirHubspot {
|
|
|
77
83
|
|
|
78
84
|
let key = await integrationService.getKeyFromIntegrations(this.projectId, 'hubspot', this.token);
|
|
79
85
|
if (!key) {
|
|
80
|
-
|
|
86
|
+
this.logger.error("[Hubspot] Key not found in Integrations");
|
|
87
|
+
winston.debug("(DirHubspot) - Key not found in Integrations.");
|
|
81
88
|
if (falseIntent) {
|
|
82
89
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
83
90
|
callback(true);
|
|
@@ -112,6 +119,7 @@ class DirHubspot {
|
|
|
112
119
|
HUBSPOT_HTTPREQUEST, async (err, resbody) => {
|
|
113
120
|
if (err) {
|
|
114
121
|
if (callback) {
|
|
122
|
+
this.logger.error("[Hubspot] Error response: ", err.response);
|
|
115
123
|
winston.error("(DirHubspot) err response: ", err.response.data)
|
|
116
124
|
let result = null;
|
|
117
125
|
let status = null;
|
|
@@ -147,6 +155,7 @@ class DirHubspot {
|
|
|
147
155
|
let status = 201;
|
|
148
156
|
let error = null;
|
|
149
157
|
let result = resbody;
|
|
158
|
+
this.logger.error("[Hubspot] Result: ", result);
|
|
150
159
|
await this.#assignAttributes(action, status, result, error);
|
|
151
160
|
if (trueIntent) {
|
|
152
161
|
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes)
|
|
@@ -5,6 +5,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
7
|
const httpUtils = require('../../utils/HttpUtils');
|
|
8
|
+
const { Logger } = require('../../Logger');
|
|
8
9
|
|
|
9
10
|
class DirIfOnlineAgentsV2 {
|
|
10
11
|
|
|
@@ -14,30 +15,35 @@ class DirIfOnlineAgentsV2 {
|
|
|
14
15
|
}
|
|
15
16
|
this.context = context;
|
|
16
17
|
this.chatbot = context.chatbot;
|
|
18
|
+
this.requestId = this.context.requestId;
|
|
17
19
|
this.intentDir = new DirIntent(context);
|
|
18
20
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
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
|
this.tdClient = new TiledeskClient({
|
|
21
24
|
projectId: this.context.projectId,
|
|
22
25
|
token: this.context.token,
|
|
23
26
|
APIURL: this.API_ENDPOINT,
|
|
24
|
-
APIKEY: "___"
|
|
27
|
+
APIKEY: "___"
|
|
25
28
|
});
|
|
26
29
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
execute(directive, callback) {
|
|
33
|
+
this.logger.info("[If Online Agents] Executing action");
|
|
30
34
|
winston.verbose("Execute IfOnlineAgentsV2 directive");
|
|
31
35
|
let action;
|
|
32
36
|
if (directive.action) {
|
|
33
37
|
action = directive.action
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
40
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
36
41
|
winston.warn("DirIfOnlineAgentsV2 Incorrect directive: ", directive);
|
|
37
42
|
callback();
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
40
45
|
this.go(action, (stop) => {
|
|
46
|
+
this.logger.info("[If Online Agents] Action completed");
|
|
41
47
|
callback(stop);
|
|
42
48
|
});
|
|
43
49
|
}
|
|
@@ -46,6 +52,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
46
52
|
winston.debug("(DirIfOnlineAgentsV2) Action: ", action);
|
|
47
53
|
|
|
48
54
|
if (!action.trueIntent && !action.falseIntent) {
|
|
55
|
+
this.logger.error("[If Online Agents] missing both action.trueIntent & action.falseIntent");
|
|
49
56
|
winston.error("(DirIfOnlineAgentsV2) Error: missing both action.trueIntent & action.falseIntent");
|
|
50
57
|
callback();
|
|
51
58
|
return;
|
|
@@ -90,6 +97,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
90
97
|
if (departmentId) {
|
|
91
98
|
agents = await this.getProjectAvailableAgents(departmentId, true);
|
|
92
99
|
} else {
|
|
100
|
+
this.logger.error("[If Online Agents] No departmentId found in attributes");
|
|
93
101
|
winston.error("(DirIfOnlineAgentsV2) no departmentId found in attributes");
|
|
94
102
|
await this.chatbot.addParameter("flowError", "(If online Agents) No departmentId found in attributes.");
|
|
95
103
|
if (falseIntent) { // no agents available
|
|
@@ -153,6 +161,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
catch(err) {
|
|
164
|
+
this.logger.error("[If Online Agents] An error occurred: ", err);
|
|
156
165
|
winston.error("(DirIfOnlineAgentsV2) An error occurred: ", err);
|
|
157
166
|
this.chatbot.addParameter("flowError", "(If online Agents) An error occurred: " + err);
|
|
158
167
|
callback();
|
|
@@ -4,6 +4,7 @@ let https = require("https");
|
|
|
4
4
|
const ms = require('minimist-string');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
6
|
const httpUtils = require('../../utils/HttpUtils');
|
|
7
|
+
const { Logger } = require('../../Logger');
|
|
7
8
|
|
|
8
9
|
class DirIfOpenHours {
|
|
9
10
|
|
|
@@ -13,11 +14,14 @@ class DirIfOpenHours {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
this.context = context;
|
|
17
|
+
this.requestId = this.context.requestId;
|
|
16
18
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
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 });
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
execute(directive, callback) {
|
|
24
|
+
this.logger.info("[If Operating Hours] Executing action");
|
|
21
25
|
winston.verbose("Execute IfOpenHours directive");
|
|
22
26
|
let action;
|
|
23
27
|
if (directive.action) {
|
|
@@ -37,11 +41,13 @@ class DirIfOpenHours {
|
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
else {
|
|
44
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
40
45
|
winston.warn("DirIfOpenHours Incorrect directive: ", directive);
|
|
41
46
|
callback();
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
44
49
|
this.go(action, (stop) => {
|
|
50
|
+
this.logger.info("[If Operating Hours] Action complteted");
|
|
45
51
|
callback(stop);
|
|
46
52
|
});
|
|
47
53
|
}
|
|
@@ -63,6 +69,7 @@ class DirIfOpenHours {
|
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
if (!trueIntent && !falseIntent) {
|
|
72
|
+
this.logger.error("[If Operating Hours] Invalid condition, no intents specified");
|
|
66
73
|
winston.error("(DirIfOpenHours) Invalid condition, no intents specified");
|
|
67
74
|
callback();
|
|
68
75
|
return;
|
|
@@ -94,6 +101,7 @@ class DirIfOpenHours {
|
|
|
94
101
|
winston.debug("(DirIfOpenHours) resbody:", resbody);
|
|
95
102
|
|
|
96
103
|
if (err) {
|
|
104
|
+
this.logger.error("[If Operating Hours] Error response: ", err.response);
|
|
97
105
|
winston.debug("(DirIfOpenHours) error: ", err);
|
|
98
106
|
if (callback) {
|
|
99
107
|
if (falseIntent) {
|
|
@@ -106,6 +114,7 @@ class DirIfOpenHours {
|
|
|
106
114
|
}
|
|
107
115
|
} else {
|
|
108
116
|
if (resbody.isopen && resbody.isopen === true) {
|
|
117
|
+
this.logger.debug("[If Operating Hours] is open: true")
|
|
109
118
|
if (trueIntent) {
|
|
110
119
|
let intentDirective = DirIntent.intentDirectiveFor(trueIntent);
|
|
111
120
|
winston.debug("(DirIfOpenHours) agents (openHours) => trueIntent");
|
|
@@ -116,6 +125,7 @@ class DirIfOpenHours {
|
|
|
116
125
|
callback();
|
|
117
126
|
return;
|
|
118
127
|
} else {
|
|
128
|
+
this.logger.debug("[If Operating Hours] is open: false")
|
|
119
129
|
if (falseIntent) {
|
|
120
130
|
let intentDirective = DirIntent.intentDirectiveFor(falseIntent);
|
|
121
131
|
winston.debug("(DirIfOpenHours) !agents (openHours) => falseIntent", falseIntent);
|