@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
|
@@ -12,13 +12,7 @@ class DirRemoveCurrentBot {
|
|
|
12
12
|
this.requestId = context.requestId;
|
|
13
13
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
14
14
|
|
|
15
|
-
this.tdClient = new TiledeskClient({
|
|
16
|
-
projectId: this.context.projectId,
|
|
17
|
-
token: this.context.token,
|
|
18
|
-
APIURL: this.API_ENDPOINT,
|
|
19
|
-
APIKEY: "___",
|
|
20
|
-
log: this.log
|
|
21
|
-
});
|
|
15
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
execute(directive, callback) {
|
|
@@ -2,6 +2,7 @@ const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
|
2
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { Filler } = require('../Filler');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
|
+
const { Logger } = require('../../Logger');
|
|
5
6
|
|
|
6
7
|
class DirReplaceBot {
|
|
7
8
|
|
|
@@ -11,19 +12,14 @@ class DirReplaceBot {
|
|
|
11
12
|
}
|
|
12
13
|
this.context = context;
|
|
13
14
|
this.requestId = context.requestId;
|
|
14
|
-
this.log = context.log;
|
|
15
|
-
|
|
16
15
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___",
|
|
22
|
-
log: this.log
|
|
23
|
-
});
|
|
16
|
+
|
|
17
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
18
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
execute(directive, callback) {
|
|
22
|
+
this.logger.info("[Replace Bot] Executing action");
|
|
27
23
|
winston.verbose("Execute ReplaceBot directive");
|
|
28
24
|
let action;
|
|
29
25
|
if (directive.action) {
|
|
@@ -36,10 +32,12 @@ class DirReplaceBot {
|
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
else {
|
|
35
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
39
36
|
winston.warn("DirReplaceBot Incorrect directive: ", directive);
|
|
40
37
|
callback();
|
|
41
38
|
}
|
|
42
39
|
this.go(action, () => {
|
|
40
|
+
this.logger.info("[Replace Bot] Action completed");
|
|
43
41
|
callback();
|
|
44
42
|
})
|
|
45
43
|
}
|
|
@@ -6,6 +6,7 @@ const axios = require("axios").default;
|
|
|
6
6
|
let https = require("https");
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const httpUtils = require('../../utils/HttpUtils');
|
|
9
|
+
const { Logger } = require('../../Logger');
|
|
9
10
|
|
|
10
11
|
class DirReplaceBotV2 {
|
|
11
12
|
|
|
@@ -15,19 +16,14 @@ class DirReplaceBotV2 {
|
|
|
15
16
|
}
|
|
16
17
|
this.context = context;
|
|
17
18
|
this.requestId = context.requestId;
|
|
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("[Replace Bot] Executing action");
|
|
31
27
|
winston.verbose("Execute ReplaceBotV2 directive");
|
|
32
28
|
let action;
|
|
33
29
|
if (directive.action) {
|
|
@@ -40,10 +36,12 @@ class DirReplaceBotV2 {
|
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
else {
|
|
39
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
43
40
|
winston.warn("DirReplaceBotV2 Incorrect directive: ", directive);
|
|
44
41
|
callback();
|
|
45
42
|
}
|
|
46
43
|
this.go(action, () => {
|
|
44
|
+
this.logger.info("[Replace Bot] Action completed");
|
|
47
45
|
callback();
|
|
48
46
|
})
|
|
49
47
|
}
|
|
@@ -6,6 +6,7 @@ const axios = require("axios").default;
|
|
|
6
6
|
let https = require("https");
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const httpUtils = require('../../utils/HttpUtils');
|
|
9
|
+
const { Logger } = require('../../Logger');
|
|
9
10
|
|
|
10
11
|
class DirReplaceBotV3 {
|
|
11
12
|
|
|
@@ -15,30 +16,27 @@ class DirReplaceBotV3 {
|
|
|
15
16
|
}
|
|
16
17
|
this.context = context;
|
|
17
18
|
this.requestId = context.requestId;
|
|
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("[Replace Bot] Executing action");
|
|
31
27
|
winston.verbose("Execute ReplaceBotV3 directive");
|
|
32
28
|
let action;
|
|
33
29
|
if (directive.action) {
|
|
34
30
|
action = directive.action;
|
|
35
31
|
}
|
|
36
32
|
else {
|
|
33
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
37
34
|
winston.warn("DirReplaceBotV3 Incorrect directive: ", directive);
|
|
38
35
|
callback();
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
38
|
this.go(action, () => {
|
|
39
|
+
this.logger.info("[Replace Bot] Action completed");
|
|
42
40
|
callback();
|
|
43
41
|
})
|
|
44
42
|
}
|
|
@@ -18,19 +18,14 @@ class DirReply {
|
|
|
18
18
|
this.token = context.token;
|
|
19
19
|
this.tdcache = context.tdcache;
|
|
20
20
|
this.log = context.log;
|
|
21
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft });
|
|
22
|
-
|
|
23
21
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
APIURL: this.API_ENDPOINT,
|
|
28
|
-
APIKEY: "___",
|
|
29
|
-
log: this.log
|
|
30
|
-
});
|
|
22
|
+
|
|
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: "___", log: this.log });
|
|
31
25
|
}
|
|
32
26
|
|
|
33
27
|
execute(directive, callback) {
|
|
28
|
+
this.logger.info("[Reply] Executing action");
|
|
34
29
|
let action;
|
|
35
30
|
if (directive.action) {
|
|
36
31
|
action = directive.action;
|
|
@@ -40,14 +35,14 @@ class DirReply {
|
|
|
40
35
|
action.attributes.fillParams = true;
|
|
41
36
|
}
|
|
42
37
|
else {
|
|
38
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
43
39
|
winston.error("DirReply Incorrect directive (no action provided):", directive);
|
|
44
40
|
callback();
|
|
45
41
|
return;
|
|
46
42
|
}
|
|
47
|
-
this.logger.info("1 Execute action reply for " + directive.action.text)
|
|
48
43
|
|
|
49
44
|
this.go(action, () => {
|
|
50
|
-
this.logger.info("
|
|
45
|
+
this.logger.info("[Reply] Action completed");
|
|
51
46
|
callback();
|
|
52
47
|
});
|
|
53
48
|
}
|
|
@@ -68,7 +63,7 @@ class DirReply {
|
|
|
68
63
|
const filler = new Filler();
|
|
69
64
|
// fill text attribute
|
|
70
65
|
message.text = filler.fill(message.text, requestAttributes);
|
|
71
|
-
this.logger.
|
|
66
|
+
this.logger.debug("[Reply] Reply with: " + cleanMessage.text);
|
|
72
67
|
|
|
73
68
|
if (message.metadata) {
|
|
74
69
|
winston.debug("DirReply filling message 'metadata':", message.metadata);
|
|
@@ -143,8 +138,7 @@ class DirReply {
|
|
|
143
138
|
}
|
|
144
139
|
|
|
145
140
|
let cleanMessage = message;
|
|
146
|
-
|
|
147
|
-
this.logger.info("4 Sending reply with clean message " + JSON.stringify(cleanMessage));
|
|
141
|
+
|
|
148
142
|
// cleanMessage = TiledeskChatbotUtil.removeEmptyReplyCommands(message);
|
|
149
143
|
// if (!TiledeskChatbotUtil.isValidReply(cleanMessage)) {
|
|
150
144
|
// console.log("invalid message", cleanMessage);
|
|
@@ -162,10 +156,9 @@ class DirReply {
|
|
|
162
156
|
(err) => {
|
|
163
157
|
if (err) {
|
|
164
158
|
winston.error("DirReply Error sending reply: ", err);
|
|
165
|
-
this.logger.error("Error sending reply: " + err);
|
|
159
|
+
this.logger.error("[Reply] Error sending reply: " + err);
|
|
166
160
|
}
|
|
167
161
|
winston.verbose("DirReply reply message sent")
|
|
168
|
-
this.logger.info("5 Reply message sent");
|
|
169
162
|
const delay = TiledeskChatbotUtil.totalMessageWait(cleanMessage);
|
|
170
163
|
if (delay > 0 && delay <= 30000) { // prevent long delays
|
|
171
164
|
setTimeout(() => {
|
|
@@ -8,6 +8,7 @@ const { DirMessageToBot } = require('./DirMessageToBot');
|
|
|
8
8
|
const { v4: uuidv4 } = require('uuid');
|
|
9
9
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
10
10
|
const winston = require('../../utils/winston');
|
|
11
|
+
const { Logger } = require('../../Logger');
|
|
11
12
|
|
|
12
13
|
class DirReplyV2 {
|
|
13
14
|
|
|
@@ -20,23 +21,18 @@ class DirReplyV2 {
|
|
|
20
21
|
this.requestId = context.requestId;
|
|
21
22
|
this.token = context.token;
|
|
22
23
|
this.tdcache = context.tdcache;
|
|
23
|
-
this.log = context.log;
|
|
24
|
-
this.intentDir = new DirIntent(context);
|
|
25
24
|
this.chatbot = context.chatbot;
|
|
26
25
|
this.reply = context.reply;
|
|
27
26
|
this.originalMessage = context.message;
|
|
28
|
-
|
|
29
27
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
APIKEY: "___",
|
|
35
|
-
log: this.log
|
|
36
|
-
});
|
|
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
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
execute(directive, callback) {
|
|
35
|
+
this.logger.info("[Advanced Reply] Executing action");
|
|
40
36
|
winston.verbose("Execute ReplyV2 directive");
|
|
41
37
|
let action;
|
|
42
38
|
if (directive.action) {
|
|
@@ -47,11 +43,13 @@ class DirReplyV2 {
|
|
|
47
43
|
action.attributes.fillParams = true;
|
|
48
44
|
}
|
|
49
45
|
else {
|
|
46
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
50
47
|
winston.warn("DirReplyV2 Incorrect directive: ", directive);
|
|
51
48
|
callback();
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
51
|
this.go(action, (stop) => {
|
|
52
|
+
this.logger.info("[Advanced Reply] Action completed");
|
|
55
53
|
callback(stop);
|
|
56
54
|
});
|
|
57
55
|
}
|
|
@@ -4,6 +4,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
4
4
|
const { Filler } = require('../Filler');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
|
+
const { Logger } = require('../../Logger');
|
|
7
8
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
8
9
|
|
|
9
10
|
class DirSendEmail {
|
|
@@ -15,19 +16,14 @@ class DirSendEmail {
|
|
|
15
16
|
this.context = context;
|
|
16
17
|
this.tdcache = context.tdcache;
|
|
17
18
|
this.requestId = context.requestId;
|
|
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("[Send Email] Executing action");
|
|
31
27
|
winston.verbose("Execute SendEmail directive");
|
|
32
28
|
let action;
|
|
33
29
|
if (directive.action) {
|
|
@@ -42,11 +38,13 @@ class DirSendEmail {
|
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
else {
|
|
41
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
45
42
|
winston.warn("DirSendEmail Incorrect directive: ", directive);
|
|
46
43
|
callback();
|
|
47
44
|
return;
|
|
48
45
|
}
|
|
49
46
|
this.go(action, () => {
|
|
47
|
+
this.logger.info("[Send Email] Action completed");
|
|
50
48
|
callback();
|
|
51
49
|
});
|
|
52
50
|
}
|
|
@@ -4,6 +4,7 @@ const { Filler } = require("../Filler");
|
|
|
4
4
|
const { DirIntent } = require("./DirIntent");
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
6
|
const httpUtils = require("../../utils/HttpUtils");
|
|
7
|
+
const { Logger } = require("../../Logger");
|
|
7
8
|
|
|
8
9
|
let whatsapp_api_url;
|
|
9
10
|
|
|
@@ -17,23 +18,27 @@ class DirSendWhatsapp {
|
|
|
17
18
|
this.chatbot = context.chatbot;
|
|
18
19
|
this.tdcache = this.context.tdcache;
|
|
19
20
|
this.requestId = this.context.requestId;
|
|
20
|
-
this.intentDir = new DirIntent(context);
|
|
21
21
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
22
|
-
|
|
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 });
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
execute(directive, callback) {
|
|
28
|
+
this.logger.info("[Send Whatsapp] Executing action");
|
|
26
29
|
winston.verbose("Execute SendWhatsapp 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("DirSendWhatsapp Incorrect directive: ", directive);
|
|
33
37
|
callback();
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
this.go(action, (stop) => {
|
|
41
|
+
this.logger.info("[Send Whatsapp] Action completed");
|
|
37
42
|
callback(stop);
|
|
38
43
|
})
|
|
39
44
|
}
|
|
@@ -6,6 +6,7 @@ const { Filler } = require('../Filler');
|
|
|
6
6
|
const validate = require('jsonschema').validate;
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
8
|
const httpUtils = require('../../utils/HttpUtils');
|
|
9
|
+
const { Logger } = require('../../Logger');
|
|
9
10
|
|
|
10
11
|
const schema = {
|
|
11
12
|
"type": "object",
|
|
@@ -79,21 +80,26 @@ class DirSetAttributeV2 {
|
|
|
79
80
|
}
|
|
80
81
|
this.context = context;
|
|
81
82
|
this.tdcache = context.tdcache;
|
|
82
|
-
this.
|
|
83
|
+
this.requestId = context.requestId;
|
|
84
|
+
|
|
85
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
execute(directive, callback) {
|
|
89
|
+
this.logger.info("[Set Attribute] Executing action");
|
|
86
90
|
winston.verbose("Execute SetAttributeV2 directive");
|
|
87
91
|
let action;
|
|
88
92
|
if (directive.action) {
|
|
89
93
|
action = directive.action
|
|
90
94
|
}
|
|
91
95
|
else {
|
|
96
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
92
97
|
winston.warn("DirSetAttributeV2 Incorrect directive: ", directive);
|
|
93
98
|
callback();
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
96
101
|
this.go(action, () => {
|
|
102
|
+
this.logger.info("[Set Attribute] Action completed");
|
|
97
103
|
callback();
|
|
98
104
|
});
|
|
99
105
|
}
|
|
@@ -11,15 +11,9 @@ class DirSetConversationTags {
|
|
|
11
11
|
this.context = context;
|
|
12
12
|
this.log = context.log;
|
|
13
13
|
this.requestId = context.requestId;
|
|
14
|
-
|
|
15
14
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
token: this.context.token,
|
|
19
|
-
APIURL: this.API_ENDPOINT,
|
|
20
|
-
APIKEY: "___",
|
|
21
|
-
log: this.log
|
|
22
|
-
});
|
|
15
|
+
|
|
16
|
+
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
execute(directive, callback) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
const { Logger } = require('../../Logger');
|
|
2
3
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
4
|
const winston = require('../../utils/winston');
|
|
4
5
|
|
|
@@ -12,11 +13,13 @@ class DirWait {
|
|
|
12
13
|
this.chatbot = context.chatbot;
|
|
13
14
|
this.tdcache = context.tdcache;
|
|
14
15
|
this.requestId = context.requestId;
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
execute(directive, callback) {
|
|
19
21
|
// 500ms < wait-time < 10.000ms
|
|
22
|
+
this.logger.info("[Wait] Executing action");
|
|
20
23
|
winston.verbose("Execute Wait directive");
|
|
21
24
|
let action;
|
|
22
25
|
if (directive.action) {
|
|
@@ -45,6 +48,7 @@ class DirWait {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
this.go(action, () => {
|
|
51
|
+
this.logger.info("[Wait] Action completed");
|
|
48
52
|
callback();
|
|
49
53
|
})
|
|
50
54
|
}
|
|
@@ -57,6 +61,7 @@ class DirWait {
|
|
|
57
61
|
// await this.tdcache.set(step_key, 0);
|
|
58
62
|
await TiledeskChatbot.resetStep(this.tdcache, this.requestId);
|
|
59
63
|
}
|
|
64
|
+
this.logger.verbose("[Wait] Waiting for ", action.millis, "[ms]")
|
|
60
65
|
setTimeout(() => {
|
|
61
66
|
callback();
|
|
62
67
|
}, action.millis);
|
|
@@ -4,6 +4,7 @@ const { Filler } = require('../Filler');
|
|
|
4
4
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
5
5
|
const { DirIntent } = require('./DirIntent');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
|
+
const { Logger } = require('../../Logger');
|
|
7
8
|
|
|
8
9
|
class DirWebRequestV2 {
|
|
9
10
|
|
|
@@ -15,8 +16,10 @@ class DirWebRequestV2 {
|
|
|
15
16
|
this.tdcache = context.tdcache;
|
|
16
17
|
this.requestId = context.requestId;
|
|
17
18
|
this.chatbot = context.chatbot;
|
|
18
|
-
this.intentDir = new DirIntent(context);
|
|
19
19
|
this.log = context.log;
|
|
20
|
+
|
|
21
|
+
this.intentDir = new DirIntent(context);
|
|
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) {
|
|
@@ -30,7 +33,9 @@ class DirWebRequestV2 {
|
|
|
30
33
|
callback();
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
36
|
+
this.logger.info("Executing WebRequest action ", directive.action)
|
|
33
37
|
this.go(action, (stop) => {
|
|
38
|
+
this.logger.info("WebRequest action terminated")
|
|
34
39
|
callback(stop);
|
|
35
40
|
}).catch((err) => {
|
|
36
41
|
// do not nothing
|
|
@@ -50,10 +55,10 @@ class DirWebRequestV2 {
|
|
|
50
55
|
let trueIntentAttributes = action.trueIntentAttributes;
|
|
51
56
|
let falseIntentAttributes = action.falseIntentAttributes;
|
|
52
57
|
|
|
53
|
-
winston.debug("DirWebRequestV2
|
|
54
|
-
winston.debug("DirWebRequestV2
|
|
55
|
-
winston.debug("DirWebRequestV2
|
|
56
|
-
winston.debug("DirWebRequestV2
|
|
58
|
+
winston.debug("DirWebRequestV2 trueIntent " + trueIntent)
|
|
59
|
+
winston.debug("DirWebRequestV2 falseIntent " + falseIntent)
|
|
60
|
+
winston.debug("DirWebRequestV2 trueIntentAttributes " + trueIntentAttributes)
|
|
61
|
+
winston.debug("DirWebRequestV2 falseIntentAttributes " + falseIntentAttributes)
|
|
57
62
|
|
|
58
63
|
let requestAttributes = null;
|
|
59
64
|
requestAttributes =
|
|
@@ -65,6 +70,7 @@ class DirWebRequestV2 {
|
|
|
65
70
|
const url = filler.fill(action.url, requestAttributes);
|
|
66
71
|
|
|
67
72
|
let headers = await this.getHeadersFromAction(action, filler, requestAttributes).catch( async (err) => {
|
|
73
|
+
this.logger.error("WebRequest: error getting headers");
|
|
68
74
|
await this.chatbot.addParameter("flowError", "Error getting headers");
|
|
69
75
|
if (falseIntent) {
|
|
70
76
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -76,6 +82,7 @@ class DirWebRequestV2 {
|
|
|
76
82
|
});
|
|
77
83
|
|
|
78
84
|
let json = await this.getJsonFromAction(action, filler, requestAttributes).catch( async (err) => {
|
|
85
|
+
this.logger.error("WebRequest: error parsing json body");
|
|
79
86
|
await this.chatbot.addParameter("flowError", "Error parsing json body");
|
|
80
87
|
if (falseIntent) {
|
|
81
88
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -107,8 +114,10 @@ class DirWebRequestV2 {
|
|
|
107
114
|
let error = res.error;
|
|
108
115
|
await this.#assignAttributes(action, resbody, status, error)
|
|
109
116
|
winston.debug("DirWebRequestV2 resbody:", resbody);
|
|
117
|
+
this.logger.info("WebRequest resbody: ", resbody);
|
|
110
118
|
|
|
111
119
|
if (err) {
|
|
120
|
+
this.logger.error("WebRequest error: ", err);
|
|
112
121
|
winston.log("webRequest error: ", err);
|
|
113
122
|
if (callback) {
|
|
114
123
|
if (falseIntent) {
|
|
@@ -130,6 +139,8 @@ class DirWebRequestV2 {
|
|
|
130
139
|
return;
|
|
131
140
|
}
|
|
132
141
|
else {
|
|
142
|
+
this.logger.warn("WebRequest status ", status);
|
|
143
|
+
this.logger.error("WebRequest error ", error);
|
|
133
144
|
if (falseIntent) {
|
|
134
145
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
135
146
|
callback(true);
|
|
@@ -228,6 +239,7 @@ class DirWebRequestV2 {
|
|
|
228
239
|
}
|
|
229
240
|
if (result === true) {
|
|
230
241
|
if (trueIntentDirective) {
|
|
242
|
+
this.logger.info("WebRequest: executing true condition");
|
|
231
243
|
this.intentDir.execute(trueIntentDirective, () => {
|
|
232
244
|
if (callback) {
|
|
233
245
|
callback();
|
|
@@ -235,6 +247,7 @@ class DirWebRequestV2 {
|
|
|
235
247
|
});
|
|
236
248
|
}
|
|
237
249
|
else {
|
|
250
|
+
this.logger.info("WebRequest: no block connected to true condition");
|
|
238
251
|
winston.debug("DirWebRequestV2 No trueIntentDirective specified");
|
|
239
252
|
if (callback) {
|
|
240
253
|
callback();
|
|
@@ -243,6 +256,7 @@ class DirWebRequestV2 {
|
|
|
243
256
|
}
|
|
244
257
|
else {
|
|
245
258
|
if (falseIntentDirective) {
|
|
259
|
+
this.logger.info("WebRequest: executing false condition");
|
|
246
260
|
this.intentDir.execute(falseIntentDirective, () => {
|
|
247
261
|
if (callback) {
|
|
248
262
|
callback();
|
|
@@ -250,6 +264,7 @@ class DirWebRequestV2 {
|
|
|
250
264
|
});
|
|
251
265
|
}
|
|
252
266
|
else {
|
|
267
|
+
this.logger.info("WebRequest: no block connected to false condition");
|
|
253
268
|
winston.debug("DirWebRequestV2 No falseIntentDirective specified");
|
|
254
269
|
if (callback) {
|
|
255
270
|
callback();
|
|
@@ -13,8 +13,9 @@ class DirWebRequestV2 {
|
|
|
13
13
|
this.tdcache = context.tdcache;
|
|
14
14
|
this.requestId = context.requestId;
|
|
15
15
|
this.chatbot = context.chatbot;
|
|
16
|
-
this.intentDir = new DirIntent(context);
|
|
17
16
|
this.log = context.log;
|
|
17
|
+
|
|
18
|
+
this.intentDir = new DirIntent(context);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
execute(directive, callback) {
|
|
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
3
3
|
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
5
|
let axios = require('axios');
|
|
6
|
+
const { Logger } = require('../../Logger');
|
|
6
7
|
|
|
7
8
|
class DirWebResponse {
|
|
8
9
|
|
|
@@ -15,22 +16,25 @@ class DirWebResponse {
|
|
|
15
16
|
this.requestId = context.requestId;
|
|
16
17
|
this.token = context.token;
|
|
17
18
|
this.tdcache = context.tdcache;
|
|
18
|
-
|
|
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 });
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
execute(directive, callback) {
|
|
24
|
+
this.logger.info("[Web Response] Executing action");
|
|
22
25
|
winston.debug("Execute WebResponse directive: ", directive);
|
|
23
26
|
let action;
|
|
24
27
|
if (directive.action) {
|
|
25
28
|
action = directive.action;
|
|
26
29
|
}
|
|
27
30
|
else {
|
|
31
|
+
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
28
32
|
winston.debug("DirWebResponse Incorrect directive: ", directive);
|
|
29
33
|
callback();
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
36
|
this.go(action, () => {
|
|
33
|
-
|
|
37
|
+
this.logger.info("[Web Response] Action completed");
|
|
34
38
|
callback();
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -59,6 +63,8 @@ class DirWebResponse {
|
|
|
59
63
|
payload: json
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
this.logger.debug("[Web Response] payload: ", webResponse);
|
|
67
|
+
|
|
62
68
|
const topic = `/webhooks/${this.requestId}`;
|
|
63
69
|
|
|
64
70
|
try {
|
|
@@ -96,42 +102,4 @@ class DirWebResponse {
|
|
|
96
102
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* A stub to send message to the "ext/botId" endpoint, hosted by tilebot on:
|
|
103
|
-
* /${TILEBOT_ROUTE}/ext/${botId}
|
|
104
|
-
*
|
|
105
|
-
* @param {Object} webResponse. The webhook response to send back
|
|
106
|
-
* @param {Object} projectId. The projectId
|
|
107
|
-
* @param {string} botId. Tiledesk botId
|
|
108
|
-
* @param {string} token. User token
|
|
109
|
-
*/
|
|
110
|
-
// function sendResponse(webResponse, projectId, botId, callback) {
|
|
111
|
-
// const url = `${WEBHOOK_URL}/${projectId}/${botId}`;
|
|
112
|
-
// const HTTPREQUEST = {
|
|
113
|
-
// url: url,
|
|
114
|
-
// headers: {
|
|
115
|
-
// 'Content-Type': 'application/json'
|
|
116
|
-
// },
|
|
117
|
-
// json: webResponse,
|
|
118
|
-
// method: 'POST'
|
|
119
|
-
// };
|
|
120
|
-
// myrequest(
|
|
121
|
-
// HTTPREQUEST,
|
|
122
|
-
// function (err, resbody) {
|
|
123
|
-
// if (err) {
|
|
124
|
-
// if (callback) {
|
|
125
|
-
// callback(err);
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
// else {
|
|
129
|
-
// if (callback) {
|
|
130
|
-
// callback(null, resbody);
|
|
131
|
-
// }
|
|
132
|
-
// }
|
|
133
|
-
// }, false
|
|
134
|
-
// );
|
|
135
|
-
// }
|
|
136
|
-
|
|
137
105
|
module.exports = { DirWebResponse };
|