@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
package/Logger.js CHANGED
@@ -2,11 +2,14 @@ let { Publisher } = require("@tiledesk/tiledesk-multi-worker");
2
2
 
3
3
  const FLOW_LOGS_ENABLED = process.env.FLOW_LOGS_ENABLED;
4
4
  const AMQP_MANAGER_URL = process.env.AMQP_MANAGER_URL;
5
+ const LOGS_BASE_ROUTING_KEY = process.env.LOGS_BASE_ROUTING_KEY || "apps.tilechat.logs";
6
+
7
+ const levels = { error: 0, warn: 1, info: 2, debug: 3 };
8
+
5
9
  let publisher = new Publisher(AMQP_MANAGER_URL, {
6
10
  debug: false,
7
11
  queueName: "logs_queue",
8
- exchange: "tiledesk-multi",
9
- topic: "logs",
12
+ exchange: "amq.topic"
10
13
  })
11
14
 
12
15
  class Logger {
@@ -33,17 +36,15 @@ class Logger {
33
36
  }
34
37
 
35
38
  this.request_id = config.request_id;
39
+ this.intent_id = config.intent_id;
40
+
36
41
  this.dev = false;
37
42
  if (config.dev && config.dev === true) {
38
43
  this.dev = true;
44
+ } else {
45
+ this._disableDebugMethods()
39
46
  }
40
-
41
- // if (!AMQP_MANAGER_URL) {
42
- // console.error('AMQP_MANAGER_URL is undefined. Logger not available...');
43
- // return;
44
- // //throw new Error("Error starting logger: AMQP_MANAGER_URL is undefined.")
45
- // }
46
-
47
+
47
48
  }
48
49
 
49
50
  error(...args) {
@@ -74,21 +75,27 @@ class Logger {
74
75
 
75
76
  let data = {
76
77
  request_id: this.request_id,
78
+ id_project: this.request_id.split("-")[2],
79
+ intent_id: this.intent_id,
77
80
  text: text,
78
81
  level: level,
82
+ nlevel: levels[level],
79
83
  timestamp: new Date(),
80
84
  dev: this.dev
81
85
  }
82
86
 
83
- publisher.publish(data, (err, ok) => {
84
- if (err) console.warn("publish log fail: ", err);
85
- return;
86
- })
87
+ if (this.request_id.startsWith('automation') && this.request_id.split("-")[4]) {
88
+ data.webhook_id = this.request_id.split("-")[4];
89
+ }
90
+
91
+ let topic = LOGS_BASE_ROUTING_KEY + `.${this.request_id}`;
92
+ publisher.publish(data, topic);
93
+ return;
87
94
  }
88
95
 
89
96
  formatLog(args) {
90
97
  return args
91
- .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg ))
98
+ .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg))
92
99
  .join(" ")
93
100
  }
94
101
 
@@ -96,9 +103,14 @@ class Logger {
96
103
  _disableMethods() {
97
104
  const methods = ['error', 'warn', 'info', 'debug'];
98
105
  methods.forEach(method => {
99
- this[method] = () => {};
106
+ this[method] = () => { };
100
107
  });
101
- }
108
+ }
109
+
110
+ _disableDebugMethods() {
111
+ const method = 'debug';
112
+ this[method] = () => { };
113
+ }
102
114
 
103
115
  }
104
116