@tiledesk/tiledesk-tybot-connector 2.0.10-rc2 → 2.0.10-rc20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/Logger.js +6 -1
  2. package/logs/app.log +28600 -21124
  3. package/logs/app1.log +41129 -0
  4. package/logs/app2.log +16449 -45594
  5. package/logs/app6.log +44412 -0
  6. package/logs/app7.log +4726 -0
  7. package/package.json +2 -2
  8. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +7 -0
  9. package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +333 -0
  10. package/tiledeskChatbotPlugs/directives/DirAddTags.js +13 -19
  11. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +17 -17
  12. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +2 -1
  13. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +19 -16
  14. package/tiledeskChatbotPlugs/directives/DirAssign.js +0 -6
  15. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -6
  16. package/tiledeskChatbotPlugs/directives/DirAssistant.js +13 -2
  17. package/tiledeskChatbotPlugs/directives/DirBrevo.js +11 -6
  18. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +10 -0
  19. package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +5 -0
  20. package/tiledeskChatbotPlugs/directives/DirClose.js +8 -7
  21. package/tiledeskChatbotPlugs/directives/DirCode.js +9 -0
  22. package/tiledeskChatbotPlugs/directives/DirCondition.js +13 -0
  23. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +7 -7
  24. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +11 -1
  25. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -6
  26. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +14 -0
  27. package/tiledeskChatbotPlugs/directives/DirDepartment.js +14 -8
  28. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +3 -7
  29. package/tiledeskChatbotPlugs/directives/DirFlowLog.js +22 -10
  30. package/tiledeskChatbotPlugs/directives/DirForm.js +4 -9
  31. package/tiledeskChatbotPlugs/directives/DirGptTask.js +19 -6
  32. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +3 -1
  33. package/tiledeskChatbotPlugs/directives/DirHubspot.js +12 -2
  34. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +4 -8
  35. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +12 -8
  36. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +11 -0
  37. package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +4 -8
  38. package/tiledeskChatbotPlugs/directives/DirIntent.js +5 -6
  39. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +14 -3
  40. package/tiledeskChatbotPlugs/directives/DirMake.js +6 -0
  41. package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -6
  42. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +5 -7
  43. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -7
  44. package/tiledeskChatbotPlugs/directives/DirQapla.js +7 -2
  45. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +7 -7
  46. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -6
  47. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +7 -7
  48. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +7 -7
  49. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +7 -7
  50. package/tiledeskChatbotPlugs/directives/DirReply.js +9 -11
  51. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -8
  52. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +7 -7
  53. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +7 -1
  54. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +7 -0
  55. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +2 -7
  56. package/tiledeskChatbotPlugs/directives/DirWait.js +6 -0
  57. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +16 -13
  58. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +6 -4
  59. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +7 -0
  60. package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
  61. package/utils/TiledeskChatbotUtil.js +3 -1
@@ -11,15 +11,11 @@ class DirIfOpenHours {
11
11
  }
12
12
 
13
13
  this.context = context;
14
- this.intentDir = new DirIntent(context);
15
-
14
+ this.log = context.log;
16
15
  this.API_ENDPOINT = context.API_ENDPOINT;
17
- this.tdClient = new TiledeskClient({
18
- projectId: this.context.projectId,
19
- token: this.context.token,
20
- APIURL: this.API_ENDPOINT,
21
- APIKEY: "___"
22
- });
16
+
17
+ this.intentDir = new DirIntent(context);
18
+ this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
23
19
  }
24
20
 
25
21
  execute(directive, callback) {
@@ -61,12 +61,11 @@ class DirIntent {
61
61
  "recipient": requestId,
62
62
  "text": intent_command,
63
63
  "id_project": projectId,
64
- "request": this.supportRequest,
65
- // "request": {
66
- // "request_id": requestId,
67
- // "id_project": projectId
68
- // // "bot_id": botId
69
- // }
64
+ "request": {
65
+ "request_id": requestId,
66
+ "id_project": projectId
67
+ // "bot_id": botId
68
+ }
70
69
  },
71
70
  "token": this.token
72
71
  }
@@ -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,22 +12,27 @@ class DirJSONCondition {
11
12
  }
12
13
  this.context = context;
13
14
  this.chatbot = context.chatbot;
14
- this.chatbot = context.chatbot;
15
+ this.requestId = this.context.requestId;
16
+
15
17
  this.intentDir = new DirIntent(context);
18
+ this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
16
19
  }
17
20
 
18
21
  execute(directive, callback) {
22
+ this.logger.info("[Condition] Executing action");
19
23
  winston.verbose("Execute JSONCondition directive");
20
24
  let action;
21
25
  if (directive.action) {
22
26
  action = directive.action
23
27
  }
24
28
  else {
29
+ this.logger.error("Incorrect action for ", directive.name, directive)
25
30
  winston.warn("DirJSONCondition Incorrect directive: ", directive);
26
31
  callback();
27
32
  return;
28
33
  }
29
34
  this.go(action, (stop) => {
35
+ this.logger.info("[Condition] Action completed");
30
36
  callback(stop);
31
37
  });
32
38
 
@@ -49,11 +55,13 @@ class DirJSONCondition {
49
55
  falseIntent = null;
50
56
  }
51
57
  if (!trueIntent && !falseIntent) {
58
+ this.logger.warn("[Condition] Invalid jsonCondition, no intents specified");
52
59
  winston.warn("(DirJSONCondition) Invalid jsonCondition, no intents specified");
53
60
  callback();
54
61
  return;
55
62
  }
56
63
  else if (groups === null) {
64
+ this.logger.warn("[Condition] Invalid jsonCondition, no groups");
57
65
  winston.warn("(DirJSONCondition) Invalid jsonCondition, no groups.");
58
66
  callback();
59
67
  return;
@@ -80,9 +88,9 @@ class DirJSONCondition {
80
88
  // const result = await this.evaluateCondition(scriptCondition, variables);
81
89
  let result;
82
90
  const expression = TiledeskExpression.JSONGroupsToExpression(groups, variables);
83
-
91
+ this.logger.debug("[Condition] Evaluating expression: ", expression);
84
92
  result = new TiledeskExpression().evaluateStaticExpression(expression, variables);
85
- winston.debug("(DirJSONCondition) executed condition: ", expression);
93
+ winston.debug("(DirJSONCondition) Evaluation result: ", result);
86
94
  if (result === true) {
87
95
  if (trueIntentDirective) {
88
96
  this.intentDir.execute(trueIntentDirective, () => {
@@ -90,6 +98,7 @@ class DirJSONCondition {
90
98
  });
91
99
  }
92
100
  else {
101
+ this.logger.debug("[Condition] No trueIntentDirective specified");
93
102
  winston.debug("(DirJSONCondition) No trueIntentDirective specified");
94
103
  callback();
95
104
  return;
@@ -97,6 +106,7 @@ class DirJSONCondition {
97
106
  }
98
107
  else {
99
108
  if (result === null) {
109
+ this.logger.error("[Condition] An error occurred evaluating the condition");
100
110
  await this.chatbot.addParameter("flowError", "An error occurred evaluating condition: result === null");
101
111
  }
102
112
  if (falseIntentDirective) {
@@ -105,6 +115,7 @@ class DirJSONCondition {
105
115
  });
106
116
  }
107
117
  else {
118
+ this.logger.debug("[Condition] No falseIntentDirective specified");
108
119
  winston.debug("(DirJSONCondition) No falseIntentDirective specified");
109
120
  callback();
110
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,21 +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);
21
+ this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
19
22
  }
20
23
 
21
24
  execute(directive, callback) {
25
+ this.logger.info("[Make] Executing action");
22
26
  winston.verbose("Execute Make directive");
23
27
  let action;
24
28
  if (directive.action) {
25
29
  action = directive.action;
26
30
  }
27
31
  else {
32
+ this.logger.error("Incorrect action for ", directive.name, directive)
28
33
  winston.warn("DirMake Incorrect directive: ", directive);
29
34
  callback();
30
35
  return;
31
36
  }
32
37
  this.go(action, (stop) => {
38
+ this.logger.info("[Make] Action completed");
33
39
  callback(stop);
34
40
  })
35
41
  }
@@ -18,12 +18,7 @@ class DirMessage {
18
18
  this.token = context.token;
19
19
  this.supportRequest = this.context.supportRequest
20
20
 
21
- this.tdClient = new TiledeskClient({
22
- projectId: this.context.projectId,
23
- token: this.context.token,
24
- APIURL: this.API_ENDPOINT,
25
- APIKEY: "___"
26
- });
21
+ this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
27
22
  }
28
23
 
29
24
  execute(directive, callback) {
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
3
3
  const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
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 DirMoveToAgent {
8
9
 
@@ -13,21 +14,18 @@ class DirMoveToAgent {
13
14
  this.context = context;
14
15
  this.tdcache = context.tdcache;
15
16
  this.requestId = context.requestId;
16
-
17
17
  this.API_ENDPOINT = context.API_ENDPOINT;
18
- this.tdClient = new TiledeskClient({
19
- projectId: this.context.projectId,
20
- token: this.context.token,
21
- APIURL: this.API_ENDPOINT,
22
- APIKEY: "___"
23
- });
24
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: "___" });
25
21
  }
26
22
 
27
23
  execute(directive, callback) {
24
+ this.logger.info("[Transfer to a Human] Executing action");
28
25
  winston.verbose("Execute MoveToAgent directive");
29
26
  directive.action = {};
30
27
  this.go(directive.action, () => {
28
+ this.logger.info("[Transfer to a Human] Action completed");
31
29
  callback();
32
30
  });
33
31
  }
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
3
3
  const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
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 DirMoveToUnassigned {
8
9
 
@@ -12,20 +13,18 @@ class DirMoveToUnassigned {
12
13
  }
13
14
  this.context = context;
14
15
  this.requestId = context.requestId;
15
-
16
16
  this.API_ENDPOINT = context.API_ENDPOINT;
17
- this.tdClient = new TiledeskClient({
18
- projectId: this.context.projectId,
19
- token: this.context.token,
20
- APIURL: this.API_ENDPOINT,
21
- APIKEY: "___",
22
- });
17
+
18
+ this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
19
+ this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
23
20
  }
24
21
 
25
22
  execute(directive, callback) {
23
+ this.logger.info("[Move to Unassigned] Executing action");
26
24
  winston.verbose("Execute MoveToUnassigned directive");
27
25
  directive.action = {};
28
26
  this.go(directive.action, () => {
27
+ this.logger.info("[Move to Unassigned] Action completed");
29
28
  callback();
30
29
  });
31
30
  }
@@ -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,22 +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
+
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 });
24
27
  }
25
28
 
26
29
  execute(directive, callback) {
27
- winston.verbose("Execute Qapla directive");
30
+ this.logger.info("[Qapla] Executing action");
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("DirQapla Incorrect directive: ", directive);
34
38
  callback();
35
39
  return;
36
40
  }
37
41
  this.go(action, (stop) => {
42
+ this.logger.info("[Qapla] Action completed");
38
43
  callback(stop);
39
44
  })
40
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,17 +16,14 @@ class DirRandomReply {
15
16
  this.requestId = context.requestId;
16
17
  this.token = context.token;
17
18
  this.tdcache = context.tdcache;
18
-
19
19
  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
- });
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: "___" });
26
23
  }
27
24
 
28
25
  execute(directive, callback) {
26
+ this.logger.info("[Random Reply] Executing action");
29
27
  winston.verbose("Execute RandomReply directive");
30
28
  let action;
31
29
  if (directive.action) {
@@ -36,11 +34,13 @@ class DirRandomReply {
36
34
  action.attributes.fillParams = true;
37
35
  }
38
36
  else {
37
+ this.logger.error("Incorrect action for ", directive.name, directive)
39
38
  winston.warn("DirRandomReply Incorrect directive: ", directive);
40
39
  callback();
41
40
  return;
42
41
  }
43
42
  this.go(action, () => {
43
+ this.logger.info("[Random Reply] Action completed");
44
44
  callback();
45
45
  });
46
46
  }
@@ -12,12 +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
- });
15
+ this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___", log: this.log });
21
16
  }
22
17
 
23
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,17 +12,14 @@ class DirReplaceBot {
11
12
  }
12
13
  this.context = context;
13
14
  this.requestId = context.requestId;
14
-
15
15
  this.API_ENDPOINT = context.API_ENDPOINT;
16
- this.tdClient = new TiledeskClient({
17
- projectId: this.context.projectId,
18
- token: this.context.token,
19
- APIURL: this.API_ENDPOINT,
20
- APIKEY: "___"
21
- });
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: "___" });
22
19
  }
23
20
 
24
21
  execute(directive, callback) {
22
+ this.logger.info("[Replace Bot] Executing action");
25
23
  winston.verbose("Execute ReplaceBot directive");
26
24
  let action;
27
25
  if (directive.action) {
@@ -34,10 +32,12 @@ class DirReplaceBot {
34
32
  }
35
33
  }
36
34
  else {
35
+ this.logger.error("Incorrect action for ", directive.name, directive)
37
36
  winston.warn("DirReplaceBot Incorrect directive: ", directive);
38
37
  callback();
39
38
  }
40
39
  this.go(action, () => {
40
+ this.logger.info("[Replace Bot] Action completed");
41
41
  callback();
42
42
  })
43
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,17 +16,14 @@ class DirReplaceBotV2 {
15
16
  }
16
17
  this.context = context;
17
18
  this.requestId = context.requestId;
18
-
19
19
  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
- });
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: "___" });
26
23
  }
27
24
 
28
25
  execute(directive, callback) {
26
+ this.logger.info("[Replace Bot] Executing action");
29
27
  winston.verbose("Execute ReplaceBotV2 directive");
30
28
  let action;
31
29
  if (directive.action) {
@@ -38,10 +36,12 @@ class DirReplaceBotV2 {
38
36
  }
39
37
  }
40
38
  else {
39
+ this.logger.error("Incorrect action for ", directive.name, directive)
41
40
  winston.warn("DirReplaceBotV2 Incorrect directive: ", directive);
42
41
  callback();
43
42
  }
44
43
  this.go(action, () => {
44
+ this.logger.info("[Replace Bot] Action completed");
45
45
  callback();
46
46
  })
47
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,28 +16,27 @@ class DirReplaceBotV3 {
15
16
  }
16
17
  this.context = context;
17
18
  this.requestId = context.requestId;
18
-
19
19
  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
- });
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: "___" });
26
23
  }
27
24
 
28
25
  execute(directive, callback) {
26
+ this.logger.info("[Replace Bot] Executing action");
29
27
  winston.verbose("Execute ReplaceBotV3 directive");
30
28
  let action;
31
29
  if (directive.action) {
32
30
  action = directive.action;
33
31
  }
34
32
  else {
33
+ this.logger.error("Incorrect action for ", directive.name, directive)
35
34
  winston.warn("DirReplaceBotV3 Incorrect directive: ", directive);
36
35
  callback();
37
36
  return;
38
37
  }
39
38
  this.go(action, () => {
39
+ this.logger.info("[Replace Bot] Action completed");
40
40
  callback();
41
41
  })
42
42
  }
@@ -17,19 +17,15 @@ class DirReply {
17
17
  this.requestId = context.requestId;
18
18
  this.token = context.token;
19
19
  this.tdcache = context.tdcache;
20
- this.supportRequest = this.context.supportRequest;
21
- this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft });
22
-
20
+ this.log = context.log;
23
21
  this.API_ENDPOINT = context.API_ENDPOINT;
24
- this.tdClient = new TiledeskClient({
25
- projectId: this.context.projectId,
26
- token: this.context.token,
27
- APIURL: this.API_ENDPOINT,
28
- APIKEY: "___"
29
- });
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 });
30
25
  }
31
26
 
32
27
  execute(directive, callback) {
28
+ this.logger.info("[Reply] Executing action");
33
29
  let action;
34
30
  if (directive.action) {
35
31
  action = directive.action;
@@ -39,14 +35,14 @@ class DirReply {
39
35
  action.attributes.fillParams = true;
40
36
  }
41
37
  else {
38
+ this.logger.error("Incorrect action for ", directive.name, directive)
42
39
  winston.error("DirReply Incorrect directive (no action provided):", directive);
43
40
  callback();
44
41
  return;
45
42
  }
46
- this.logger.info("Executing Action Reply ", directive.action)
47
43
 
48
44
  this.go(action, () => {
49
- this.logger.info("Action Reply terminated")
45
+ this.logger.info("[Reply] Action completed");
50
46
  callback();
51
47
  });
52
48
  }
@@ -67,6 +63,7 @@ class DirReply {
67
63
  const filler = new Filler();
68
64
  // fill text attribute
69
65
  message.text = filler.fill(message.text, requestAttributes);
66
+ this.logger.debug("[Reply] Reply with: " + message.text);
70
67
 
71
68
  if (message.metadata) {
72
69
  winston.debug("DirReply filling message 'metadata':", message.metadata);
@@ -153,6 +150,7 @@ class DirReply {
153
150
  (err) => {
154
151
  if (err) {
155
152
  winston.error("DirReply Error sending reply: ", err);
153
+ this.logger.error("[Reply] Error sending reply: " + err);
156
154
  }
157
155
  winston.verbose("DirReply reply message sent")
158
156
  const delay = TiledeskChatbotUtil.totalMessageWait(cleanMessage);
@@ -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,21 +21,18 @@ class DirReplyV2 {
20
21
  this.requestId = context.requestId;
21
22
  this.token = context.token;
22
23
  this.tdcache = context.tdcache;
23
- this.intentDir = new DirIntent(context);
24
24
  this.chatbot = context.chatbot;
25
25
  this.reply = context.reply;
26
26
  this.originalMessage = context.message;
27
-
28
27
  this.API_ENDPOINT = context.API_ENDPOINT;
29
- this.tdClient = new TiledeskClient({
30
- projectId: this.context.projectId,
31
- token: this.context.token,
32
- APIURL: this.API_ENDPOINT,
33
- APIKEY: "___"
34
- });
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: "___" });
35
32
  }
36
33
 
37
34
  execute(directive, callback) {
35
+ this.logger.info("[Advanced Reply] Executing action");
38
36
  winston.verbose("Execute ReplyV2 directive");
39
37
  let action;
40
38
  if (directive.action) {
@@ -45,11 +43,13 @@ class DirReplyV2 {
45
43
  action.attributes.fillParams = true;
46
44
  }
47
45
  else {
46
+ this.logger.error("Incorrect action for ", directive.name, directive)
48
47
  winston.warn("DirReplyV2 Incorrect directive: ", directive);
49
48
  callback();
50
49
  return;
51
50
  }
52
51
  this.go(action, (stop) => {
52
+ this.logger.info("[Advanced Reply] Action completed");
53
53
  callback(stop);
54
54
  });
55
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,17 +16,14 @@ class DirSendEmail {
15
16
  this.context = context;
16
17
  this.tdcache = context.tdcache;
17
18
  this.requestId = context.requestId;
18
-
19
19
  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
- });
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: "___" });
26
23
  }
27
24
 
28
25
  execute(directive, callback) {
26
+ this.logger.info("[Send Email] Executing action");
29
27
  winston.verbose("Execute SendEmail directive");
30
28
  let action;
31
29
  if (directive.action) {
@@ -40,11 +38,13 @@ class DirSendEmail {
40
38
  }
41
39
  }
42
40
  else {
41
+ this.logger.error("Incorrect action for ", directive.name, directive)
43
42
  winston.warn("DirSendEmail Incorrect directive: ", directive);
44
43
  callback();
45
44
  return;
46
45
  }
47
46
  this.go(action, () => {
47
+ this.logger.info("[Send Email] Action completed");
48
48
  callback();
49
49
  });
50
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,22 +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
+
23
+ this.intentDir = new DirIntent(context);
24
+ this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
22
25
  }
23
26
 
24
27
  execute(directive, callback) {
28
+ this.logger.info("[Send Whatsapp] Executing action");
25
29
  winston.verbose("Execute SendWhatsapp directive");
26
30
  let action;
27
31
  if (directive.action) {
28
32
  action = directive.action;
29
33
  }
30
34
  else {
35
+ this.logger.error("Incorrect action for ", directive.name, directive)
31
36
  winston.warn("DirSendWhatsapp Incorrect directive: ", directive);
32
37
  callback();
33
38
  return;
34
39
  }
35
40
  this.go(action, (stop) => {
41
+ this.logger.info("[Send Whatsapp] Action completed");
36
42
  callback(stop);
37
43
  })
38
44
  }