@tiledesk/tiledesk-tybot-connector 2.0.11 → 2.0.12-rc2

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 (59) hide show
  1. package/Logger.js +28 -16
  2. package/logs/app.log +23037 -17188
  3. package/logs/app1.log +16746 -31032
  4. package/logs/app7.log +28054 -0
  5. package/package.json +3 -2
  6. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +7 -0
  7. package/tiledeskChatbotPlugs/directives/DirAddTags.js +17 -11
  8. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +18 -2
  9. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +2 -2
  10. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +18 -2
  11. package/tiledeskChatbotPlugs/directives/DirAssign.js +0 -9
  12. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -8
  13. package/tiledeskChatbotPlugs/directives/DirAssistant.js +13 -3
  14. package/tiledeskChatbotPlugs/directives/DirBrevo.js +11 -8
  15. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +10 -1
  16. package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +5 -0
  17. package/tiledeskChatbotPlugs/directives/DirClose.js +8 -9
  18. package/tiledeskChatbotPlugs/directives/DirCode.js +9 -1
  19. package/tiledeskChatbotPlugs/directives/DirCondition.js +13 -1
  20. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +7 -9
  21. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +11 -2
  22. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -7
  23. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +14 -1
  24. package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -9
  25. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +2 -8
  26. package/tiledeskChatbotPlugs/directives/DirFlowLog.js +88 -0
  27. package/tiledeskChatbotPlugs/directives/DirForm.js +3 -10
  28. package/tiledeskChatbotPlugs/directives/DirGptTask.js +19 -7
  29. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +2 -1
  30. package/tiledeskChatbotPlugs/directives/DirHubspot.js +12 -3
  31. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +3 -9
  32. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +12 -10
  33. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +11 -1
  34. package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +3 -9
  35. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +14 -4
  36. package/tiledeskChatbotPlugs/directives/DirMake.js +6 -1
  37. package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -7
  38. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +5 -9
  39. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -9
  40. package/tiledeskChatbotPlugs/directives/DirQapla.js +7 -3
  41. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +7 -9
  42. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -7
  43. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +7 -9
  44. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +7 -9
  45. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +7 -9
  46. package/tiledeskChatbotPlugs/directives/DirReply.js +9 -16
  47. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -10
  48. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +7 -9
  49. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +7 -2
  50. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +7 -1
  51. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +2 -8
  52. package/tiledeskChatbotPlugs/directives/DirWait.js +6 -1
  53. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +20 -5
  54. package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +2 -1
  55. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +8 -40
  56. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +7 -1
  57. package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
  58. package/utils/TiledeskChatbotUtil.js +2 -2
  59. package/logs/app2.log +0 -15253
@@ -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
- this.tdClient = new TiledeskClient({
22
- projectId: this.context.projectId,
23
- token: this.context.token,
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
- this.tdClient = new TiledeskClient({
25
- projectId: this.context.projectId,
26
- token: this.context.token,
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("6 End of action reply " + directive.action.text + " -> callback")
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.info("2 Sending reply " + message.text);
66
+ this.logger.debug("[Reply] Reply with: " + message.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
- this.logger.info("3 Sending reply (text) " + cleanMessage.text);
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
- this.tdClient = new TiledeskClient({
31
- projectId: this.context.projectId,
32
- token: this.context.token,
33
- APIURL: this.API_ENDPOINT,
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
- this.tdClient = new TiledeskClient({
22
- projectId: this.context.projectId,
23
- token: this.context.token,
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
- this.log = context.log;
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.log = context.log;
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
- this.tdClient = new TiledeskClient({
17
- projectId: this.context.projectId,
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
- this.log = context.log;
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 trueIntent " + trueIntent)
54
- winston.debug("DirWebRequestV2 falseIntent " + falseIntent)
55
- winston.debug("DirWebRequestV2 trueIntentAttributes " + trueIntentAttributes)
56
- winston.debug("DirWebRequestV2 falseIntentAttributes " + falseIntentAttributes)
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
- this.log = context.log;
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
- // return stop true?
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 };
@@ -1,4 +1,5 @@
1
1
  const axios = require("axios").default;
2
+ const { Logger } = require("../../Logger");
2
3
  const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
3
4
  const httpUtils = require("../../utils/HttpUtils");
4
5
  const winston = require('../../utils/winston');
@@ -12,22 +13,27 @@ class DirWhatsappByAttribute {
12
13
  throw new Error('context object is mandatory');
13
14
  }
14
15
  this.context = context;
16
+ this.requestId = this.context.requestId;
15
17
  this.API_ENDPOINT = context.API_ENDPOINT;
16
- this.log = context.log;
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 });
17
20
  }
18
21
 
19
22
  execute(directive, callback) {
23
+ this.logger.info("[Whatsapp by Attribute] Executing action");
20
24
  winston.verbose("Execute WhatsappByAttribute directive");
21
25
  let action;
22
26
  if (directive.action) {
23
27
  action = directive.action;
24
28
  }
25
29
  else {
30
+ this.logger.error("Incorrect action for ", directive.name, directive)
26
31
  winston.warn("DirWhatsappByAttribute Incorrect directive: ", directive);
27
32
  callback();
28
33
  return;
29
34
  }
30
35
  this.go(action, () => {
36
+ this.logger.info("[Whatsapp by Attribute] Action completed");
31
37
  callback();
32
38
  })
33
39
  }
@@ -59,6 +59,7 @@ class Directives {
59
59
  static CONNECT_BLOCK = "connect_block";
60
60
  static ADD_TAGS = 'add_tags'
61
61
  static WEB_RESPONSE = "web_response";
62
+ static FLOW_LOG = "flow_log";
62
63
 
63
64
  // static WHEN_ONLINE_MOVE_TO_AGENT = "whenonlinemovetoagent"; // DEPRECATED?
64
65
  // static WHEN_OFFLINE_HOURS = "whenofflinehours"; // DEPRECATED // adds a message on top of the original message when offline hours opts: --replace
@@ -605,10 +605,10 @@ class TiledeskChatbotUtil {
605
605
  }
606
606
  }
607
607
  let currentLeadName = await chatbot.getParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY);
608
- if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) You lead email from attributes: " + currentLeadEmail); }
608
+ if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) You lead name from attributes: " + currentLeadName); }
609
609
  if (message.request.lead.fullname && !currentLeadName) {
610
610
  // worth saving
611
- if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) worth saving email"); }
611
+ if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) worth saving name"); }
612
612
  try {
613
613
  await chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY, message.request.lead.fullname);
614
614
  }