@tiledesk/tiledesk-tybot-connector 2.0.16-rc5 → 2.0.17

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 (56) hide show
  1. package/CHANGELOG.md +3 -28
  2. package/Logger.js +4 -14
  3. package/TdCache copy.js +242 -0
  4. package/engine/mock/MockBotsDataSource.js +2 -1
  5. package/index.js +0 -3
  6. package/logs/app.log +44714 -5981
  7. package/logs/app1.log +16653 -0
  8. package/package.json +2 -2
  9. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +11 -29
  10. package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +21 -20
  11. package/tiledeskChatbotPlugs/directives/DirAddTags.js +6 -5
  12. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +8 -7
  13. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +21 -53
  14. package/tiledeskChatbotPlugs/directives/DirAssistant.js +2 -1
  15. package/tiledeskChatbotPlugs/directives/DirBrevo.js +2 -1
  16. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +5 -4
  17. package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +2 -1
  18. package/tiledeskChatbotPlugs/directives/DirClose.js +3 -2
  19. package/tiledeskChatbotPlugs/directives/DirCode.js +2 -1
  20. package/tiledeskChatbotPlugs/directives/DirCondition.js +4 -3
  21. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +2 -1
  22. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +2 -1
  23. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +2 -1
  24. package/tiledeskChatbotPlugs/directives/DirDepartment.js +4 -3
  25. package/tiledeskChatbotPlugs/directives/DirFlowLog.js +5 -5
  26. package/tiledeskChatbotPlugs/directives/DirGptTask.js +5 -4
  27. package/tiledeskChatbotPlugs/directives/DirHubspot.js +2 -1
  28. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +2 -1
  29. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +4 -3
  30. package/tiledeskChatbotPlugs/directives/DirIntent.js +1 -4
  31. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +5 -4
  32. package/tiledeskChatbotPlugs/directives/DirMake.js +2 -1
  33. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +2 -1
  34. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +2 -1
  35. package/tiledeskChatbotPlugs/directives/DirQapla.js +2 -1
  36. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +2 -1
  37. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +2 -1
  38. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +2 -1
  39. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +2 -1
  40. package/tiledeskChatbotPlugs/directives/DirReply.js +5 -6
  41. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +2 -1
  42. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +2 -1
  43. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +2 -1
  44. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +2 -1
  45. package/tiledeskChatbotPlugs/directives/DirWait.js +3 -2
  46. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +9 -8
  47. package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +418 -0
  48. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +3 -2
  49. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +2 -1
  50. package/tiledeskChatbotPlugs/directives/Directives.js +0 -1
  51. package/utils/TiledeskChatbotUtil.js +25 -4
  52. package/logs/app4.log +0 -46163
  53. package/logs/app5.log +0 -39983
  54. package/logs/app6.log +0 -50376
  55. package/logs/app7.log +0 -43568
  56. package/logs/app8.log +0 -4779
package/CHANGELOG.md CHANGED
@@ -5,6 +5,8 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # 2.0.9
9
+
8
10
  # 2.0.9-rc1
9
11
  - removed: speech-to-text management
10
12
 
@@ -18,8 +20,6 @@ available on:
18
20
 
19
21
  # v0.5.0
20
22
  - added: AI_ENDPOINT env var
21
-
22
- # v0.5.0-rc1
23
23
  - added: ability to get 'none' as bodytype in webresponse
24
24
 
25
25
  # v0.4.2
@@ -34,19 +34,6 @@ available on:
34
34
  - changed: refactoring of DIrWebRequestv2
35
35
  - bug-fixed: erro while parsing webrequestv2 body
36
36
 
37
- # v0.3.5-rc4
38
- - added: webhook action (same as intent one)
39
-
40
- # v0.3.5-rc3
41
- - bug-fixed: jsonBody parse error in web-request-v2
42
-
43
- # v0.3.5-rc2
44
- - bug-fixed: cannot set status of undefined reading res.status in DirAssistant
45
-
46
- # v0.3.5-rc1
47
- - changed: refactoring web-request-v2
48
- - bug-fixed: jsonBody parse error in web-request-v2
49
-
50
37
  # v0.3.4
51
38
  -bug-fixed: slit is undefined in TiledeskChatbotUtils
52
39
 
@@ -56,18 +43,6 @@ available on:
56
43
  # v0.3.2
57
44
  - bug-fixed: minor improvement
58
45
 
59
- # v0.2.153-rc9
60
- - changed: updated tiledesk-multi-worker to 0.2.1-rc2
61
-
62
- # v0.2.153-rc8
63
- - added: fixToken function in TiledeskService utils class
64
-
65
- # v0.2.153-rc4
66
- - log added
67
-
68
- # v0.2.153-rc3
69
- - added: specchToText function to transcript audio file
70
-
71
46
  # v0.2.153-rc1
72
47
  - changed: context for gpt-40 and gpt-40-mini
73
48
 
@@ -491,7 +466,7 @@ available on:
491
466
  - Added AskGPTV2 action
492
467
 
493
468
  # v0.2.49
494
- - resplacebotv2, added "/" + blockName (so the blockname will be implicitly Executed"), removing the need to specify the "/" in the body of the replacebot editor
469
+ - resplacebotv2, added "/" + blockName (so the blockname will be implicitly executed), removing the need to specify the "/" in the body of the replacebot editor
495
470
  - Never add "guest#" as lead userFullname
496
471
 
497
472
  # v0.2.48
package/Logger.js CHANGED
@@ -4,7 +4,7 @@ const FLOW_LOGS_ENABLED = process.env.FLOW_LOGS_ENABLED;
4
4
  const AMQP_MANAGER_URL = process.env.AMQP_MANAGER_URL;
5
5
  const LOGS_BASE_ROUTING_KEY = process.env.LOGS_BASE_ROUTING_KEY || "apps.tilechat.logs";
6
6
 
7
- const levels = { error: 0, warn: 1, info: 2, debug: 3, native: 4 };
7
+ const levels = { error: 0, warn: 1, info: 2, debug: 3 };
8
8
 
9
9
  let publisher = new Publisher(AMQP_MANAGER_URL, {
10
10
  debug: false,
@@ -12,8 +12,6 @@ let publisher = new Publisher(AMQP_MANAGER_URL, {
12
12
  exchange: "amq.topic"
13
13
  })
14
14
 
15
- console.log("LOGGER publisher: ", publisher);
16
-
17
15
  class Logger {
18
16
 
19
17
  constructor(config) {
@@ -67,11 +65,6 @@ class Logger {
67
65
  return this.base('debug', log);
68
66
  }
69
67
 
70
- native(...args) {
71
- let log = this.formatLog(args);
72
- return this.base('native', log);
73
- }
74
-
75
68
  base(level, text) {
76
69
  if (!this.request_id || !publisher) {
77
70
  console.log("Return because request or publisher is undefined", this.request_id, publisher);
@@ -94,7 +87,6 @@ class Logger {
94
87
  }
95
88
 
96
89
  let topic = LOGS_BASE_ROUTING_KEY + `.${this.request_id}`;
97
- console.log("LOGGER publishing on topic ", topic)
98
90
  publisher.publish(data, topic);
99
91
  return;
100
92
  }
@@ -107,17 +99,15 @@ class Logger {
107
99
 
108
100
  // Substitute methods with empty function if flow flogs are disabled
109
101
  _disableMethods() {
110
- const methods = ['error', 'warn', 'info', 'debug', 'native'];
102
+ const methods = ['error', 'warn', 'info', 'debug'];
111
103
  methods.forEach(method => {
112
104
  this[method] = () => { };
113
105
  });
114
106
  }
115
107
 
116
108
  _disableDebugMethods() {
117
- const methods = ['debug', 'native'];
118
- methods.forEach(method => {
119
- this[method] = () => { };
120
- });
109
+ const method = 'debug';
110
+ this[method] = () => { };
121
111
  }
122
112
 
123
113
  }
@@ -0,0 +1,242 @@
1
+ const redis = require('redis');
2
+
3
+ class TdCache {
4
+
5
+ constructor(config) {
6
+ this.redis_host = config.host;
7
+ this.redis_port = config.port;
8
+ this.redis_password = config.password;
9
+ this.client = null;
10
+ }
11
+
12
+ async connect(callback) {
13
+ // client = redis.createClient();
14
+ return new Promise( async (resolve, reject) => {
15
+ this.client = redis.createClient(
16
+ {
17
+ host: this.redis_host,
18
+ port: this.redis_port,
19
+ password: this.redis_password
20
+ });
21
+ this.client.on('error', err => {
22
+ reject(err);
23
+ if (callback) {
24
+ callback(err);
25
+ }
26
+ });
27
+ // this.client.on('connect', function() {
28
+ // console.log('Redis Connected!');
29
+ // });
30
+ this.client.on('ready',function() {
31
+ console.log("connected")
32
+ resolve();
33
+ if (callback) {
34
+ callback();
35
+ }
36
+ //console.log("Redis is ready.");
37
+ });
38
+ });
39
+ }
40
+
41
+ async set(key, value, options) {
42
+ //console.log("setting key value", key, value)
43
+ if (!options) {
44
+ options = {EX: 86400}
45
+ }
46
+ return new Promise( async (resolve, reject) => {
47
+ if (options && options.EX) {
48
+ //console.log("expires:", options.EX)
49
+ try {
50
+ await this.client.set(
51
+ key,
52
+ value,
53
+ 'EX', options.EX);
54
+ }
55
+ catch(error) {
56
+ reject(error)
57
+ }
58
+ }
59
+ else {
60
+ try {
61
+ //console.log("setting here...key", key, value)
62
+ await this.client.set(
63
+ key,
64
+ value);
65
+ }
66
+ catch(error) {
67
+ console.error("Error", error);
68
+ reject(error)
69
+ }
70
+ }
71
+ if (options && options.callback) {
72
+ options.callback();
73
+ }
74
+ //console.log("resolving...", key);
75
+ return resolve();
76
+ });
77
+ }
78
+
79
+ async incr(key) {
80
+ // console.log("incr key:", key)
81
+ return new Promise( async (resolve, reject) => {
82
+ try {
83
+ // console.log("incr here...key", key)
84
+ await this.client.incr(key);
85
+ }
86
+ catch(error) {
87
+ console.error("Error on incr:", error);
88
+ reject(error)
89
+ }
90
+ return resolve();
91
+ });
92
+ }
93
+
94
+ async hset(dict_key, key, value, options) {
95
+ //console.log("hsetting dict_key key value", dict_key, key, value)
96
+ return new Promise( async (resolve, reject) => {
97
+ if (options && options.EX) {
98
+ //console.log("expires:", options.EX)
99
+ try {
100
+ await this.client.hset(
101
+ dict_key,
102
+ key,
103
+ value,
104
+ 'EX', options.EX);
105
+ }
106
+ catch(error) {
107
+ reject(error)
108
+ }
109
+ }
110
+ else {
111
+ try {
112
+ //console.log("setting here...key", key, value)
113
+ await this.client.hset(
114
+ dict_key,
115
+ key,
116
+ value);
117
+ }
118
+ catch(error) {
119
+ console.error("Error", error);
120
+ reject(error)
121
+ }
122
+ }
123
+ if (options && options.callback) {
124
+ options.callback();
125
+ }
126
+ return resolve();
127
+ });
128
+ }
129
+
130
+ async hdel(dict_key, key, options) {
131
+ //console.log("hsetting dict_key key value", dict_key, key, value)
132
+ return new Promise( async (resolve, reject) => {
133
+ if (options && options.EX) {
134
+ //console.log("expires:", options.EX)
135
+ try {
136
+ await this.client.hdel(
137
+ dict_key,
138
+ key,
139
+ 'EX', options.EX);
140
+ }
141
+ catch(error) {
142
+ reject(error)
143
+ }
144
+ }
145
+ else {
146
+ try {
147
+ //console.log("setting here...key", key, value)
148
+ await this.client.hdel(
149
+ dict_key,
150
+ key);
151
+ }
152
+ catch(error) {
153
+ console.error("Error", error);
154
+ reject(error);
155
+ }
156
+ }
157
+ if (options && options.callback) {
158
+ options.callback();
159
+ }
160
+ return resolve();
161
+ });
162
+ }
163
+
164
+ async setJSON(key, value, options) {
165
+ const _string = JSON.stringify(value);
166
+ return await this.set(key, _string, options);
167
+ }
168
+
169
+ async get(key, callback) {
170
+ //console.log("getting key", key)
171
+ return new Promise( async (resolve, reject) => {
172
+ this.client.get(key, (err, value) => {
173
+ if (err) {
174
+ reject(err);
175
+ }
176
+ else {
177
+ if (callback) {
178
+ callback(value);
179
+ }
180
+ return resolve(value);
181
+ }
182
+ });
183
+ });
184
+ }
185
+
186
+ async hgetall(dict_key, callback) {
187
+ //console.log("hgetting dics", dict_key);
188
+ return new Promise( async (resolve, reject) => {
189
+ this.client.hgetall(dict_key, (err, value) => {
190
+ if (err) {
191
+ reject(err);
192
+ if (callback) {
193
+ callback(err, null);
194
+ }
195
+ }
196
+ else {
197
+ if (callback) {
198
+ callback(null, value);
199
+ }
200
+ resolve(value);
201
+ }
202
+ });
203
+ });
204
+ }
205
+
206
+ async hget(dict_key, key, callback) {
207
+ //console.log("hgetting dics", dict_key);
208
+ return new Promise( async (resolve, reject) => {
209
+ this.client.hget(dict_key, key, (err, value) => {
210
+ if (err) {
211
+ reject(err);
212
+ if (callback) {
213
+ callback(err, null);
214
+ }
215
+ }
216
+ else {
217
+ if (callback) {
218
+ callback(null, value);
219
+ }
220
+ resolve(value);
221
+ }
222
+ });
223
+ });
224
+ }
225
+
226
+ async getJSON(key, callback) {
227
+ const value = await this.get(key);
228
+ return JSON.parse(value);
229
+ }
230
+
231
+ async del(key, callback) {
232
+ return new Promise( async (resolve, reject) => {
233
+ await this.client.del(key);
234
+ if (callback) {
235
+ callback();
236
+ }
237
+ return resolve();
238
+ })
239
+ }
240
+ }
241
+
242
+ module.exports = { TdCache };
@@ -24,7 +24,8 @@ class MockBotsDataSource {
24
24
  }catch(err){
25
25
  reject(err);
26
26
  }
27
- })
27
+
28
+ })
28
29
  }
29
30
 
30
31
  async getBotByIdCache(botId, tdcache) {
package/index.js CHANGED
@@ -98,9 +98,6 @@ router.post('/ext/:botid', async (req, res) => {
98
98
  Promise.reject(err);
99
99
  return;
100
100
  });
101
-
102
- winston.debug("(tybotRoute) Bot found: ", bot)
103
-
104
101
 
105
102
  let intentsMachine;
106
103
  let backupMachine;