@tiledesk/tiledesk-tybot-connector 2.0.7 → 2.0.8-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/CHANGELOG.md CHANGED
@@ -5,8 +5,17 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # 2.0.8-rc1
9
+ - removed: TILEBOT_LOG var
10
+
11
+ # 0.5.1-rc1
12
+ - added json_buttons
13
+ - added winston log with code refactoring
14
+
8
15
  # v0.5.0
9
16
  - added: AI_ENDPOINT env var
17
+
18
+ # v0.5.0-rc1
10
19
  - added: ability to get 'none' as bodytype in webresponse
11
20
 
12
21
  # v0.4.2
@@ -21,6 +30,19 @@ available on:
21
30
  - changed: refactoring of DIrWebRequestv2
22
31
  - bug-fixed: erro while parsing webrequestv2 body
23
32
 
33
+ # v0.3.5-rc4
34
+ - added: webhook action (same as intent one)
35
+
36
+ # v0.3.5-rc3
37
+ - bug-fixed: jsonBody parse error in web-request-v2
38
+
39
+ # v0.3.5-rc2
40
+ - bug-fixed: cannot set status of undefined reading res.status in DirAssistant
41
+
42
+ # v0.3.5-rc1
43
+ - changed: refactoring web-request-v2
44
+ - bug-fixed: jsonBody parse error in web-request-v2
45
+
24
46
  # v0.3.4
25
47
  -bug-fixed: slit is undefined in TiledeskChatbotUtils
26
48
 
@@ -30,6 +52,18 @@ available on:
30
52
  # v0.3.2
31
53
  - bug-fixed: minor improvement
32
54
 
55
+ # v0.2.153-rc9
56
+ - changed: updated tiledesk-multi-worker to 0.2.1-rc2
57
+
58
+ # v0.2.153-rc8
59
+ - added: fixToken function in TiledeskService utils class
60
+
61
+ # v0.2.153-rc4
62
+ - log added
63
+
64
+ # v0.2.153-rc3
65
+ - added: specchToText function to transcript audio file
66
+
33
67
  # v0.2.153-rc1
34
68
  - changed: context for gpt-40 and gpt-40-mini
35
69
 
package/Logger.js CHANGED
@@ -2,13 +2,18 @@ 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
 
15
+ console.log("LOGGER publisher: ", publisher);
16
+
12
17
  class Logger {
13
18
 
14
19
  constructor(config) {
@@ -33,10 +38,15 @@ class Logger {
33
38
  }
34
39
 
35
40
  this.request_id = config.request_id;
41
+ console.log("LOGGER for request ", this.request_id);
42
+
36
43
  this.dev = false;
37
- if (config.dev && config.dev === true) {
38
- this.dev = true;
39
- }
44
+ console.log("LOGGER is dev conversation ? ", config.dev);
45
+ // if (config.dev && config.dev === true) {
46
+ // this.dev = true;
47
+ // } else {
48
+ // this._disableDebugMethods()
49
+ // }
40
50
 
41
51
  // if (!AMQP_MANAGER_URL) {
42
52
  // console.error('AMQP_MANAGER_URL is undefined. Logger not available...');
@@ -68,27 +78,29 @@ class Logger {
68
78
 
69
79
  base(level, text) {
70
80
  if (!this.request_id || !publisher) {
71
- //console.log("Return because request or publisher is undefined", this.request_id, publisher);
81
+ console.log("Return because request or publisher is undefined", this.request_id, publisher);
72
82
  return;
73
83
  }
74
84
 
75
85
  let data = {
76
86
  request_id: this.request_id,
87
+ id_project: this.request_id.split("-")[2],
77
88
  text: text,
78
89
  level: level,
90
+ nlevel: levels[level],
79
91
  timestamp: new Date(),
80
92
  dev: this.dev
81
93
  }
82
94
 
83
- publisher.publish(data, (err, ok) => {
84
- if (err) console.warn("publish log fail: ", err);
85
- return;
86
- })
95
+ let topic = LOGS_BASE_ROUTING_KEY + `.${this.request_id}`;
96
+ console.log("LOGGER publishing on topic ", topic)
97
+ publisher.publish(data, topic);
98
+ return;
87
99
  }
88
100
 
89
101
  formatLog(args) {
90
102
  return args
91
- .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg ))
103
+ .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg))
92
104
  .join(" ")
93
105
  }
94
106
 
@@ -96,9 +108,14 @@ class Logger {
96
108
  _disableMethods() {
97
109
  const methods = ['error', 'warn', 'info', 'debug'];
98
110
  methods.forEach(method => {
99
- this[method] = () => {};
111
+ this[method] = () => { };
100
112
  });
101
- }
113
+ }
114
+
115
+ _disableDebugMethods() {
116
+ const method = 'debug';
117
+ this[method] = () => { };
118
+ }
102
119
 
103
120
  }
104
121
 
@@ -24,8 +24,7 @@ class MockBotsDataSource {
24
24
  }catch(err){
25
25
  reject(err);
26
26
  }
27
-
28
- })
27
+ })
29
28
  }
30
29
 
31
30
  async getBotByIdCache(botId, tdcache) {
package/index.js CHANGED
@@ -112,6 +112,9 @@ router.post('/ext/:botid', async (req, res) => {
112
112
  Promise.reject(err);
113
113
  return;
114
114
  });
115
+
116
+ winston.debug("(tybotRoute) Bot found: ", bot)
117
+
115
118
 
116
119
  let intentsMachine;
117
120
  let backupMachine;