@tiledesk/tiledesk-tybot-connector 2.0.10-rc9 → 2.0.10

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 (86) hide show
  1. package/CHANGELOG.md +2 -27
  2. package/ExtApi.js +8 -1
  3. package/ExtUtil.js +6 -5
  4. package/Logger.js +17 -26
  5. package/TdCache copy.js +242 -0
  6. package/engine/IntentForm.js +1 -0
  7. package/engine/IntentsMachineFactory.js +4 -4
  8. package/engine/MongodbBotsDataSource.js +1 -0
  9. package/engine/MongodbIntentsMachine.js +1 -0
  10. package/engine/TiledeskChatbot.js +16 -11
  11. package/engine/TiledeskIntentsMachine.js +2 -1
  12. package/engine/mock/MockBotsDataSource.js +2 -1
  13. package/index.js +25 -22
  14. package/logs/app.log +43056 -4268
  15. package/logs/app1.log +41129 -0
  16. package/logs/app2.log +14567 -45594
  17. package/logs/app6.log +29039 -0
  18. package/logs/app7.log +4726 -0
  19. package/package.json +2 -3
  20. package/services/AIService.js +1 -1
  21. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +18 -38
  22. package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +2 -1
  23. package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +3 -1
  24. package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +3 -1
  25. package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +9 -7
  26. package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfNotOpenHours.js +10 -3
  27. package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfOpenHours.js +9 -2
  28. package/tiledeskChatbotPlugs/directives/DirAddTags.js +4 -16
  29. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +0 -16
  30. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +1 -0
  31. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +4 -17
  32. package/tiledeskChatbotPlugs/directives/DirAssign.js +8 -5
  33. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +3 -1
  34. package/tiledeskChatbotPlugs/directives/DirAssistant.js +1 -0
  35. package/tiledeskChatbotPlugs/directives/DirBrevo.js +6 -4
  36. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +1 -0
  37. package/tiledeskChatbotPlugs/directives/DirClose.js +2 -0
  38. package/tiledeskChatbotPlugs/directives/DirCode.js +1 -0
  39. package/tiledeskChatbotPlugs/directives/DirCondition.js +1 -0
  40. package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +1 -0
  41. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +3 -1
  42. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +1 -0
  43. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +5 -2
  44. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +1 -0
  45. package/tiledeskChatbotPlugs/directives/DirDepartment.js +3 -1
  46. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +3 -1
  47. package/tiledeskChatbotPlugs/directives/DirForm.js +3 -1
  48. package/tiledeskChatbotPlugs/directives/DirGptTask.js +1 -0
  49. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +55 -36
  50. package/tiledeskChatbotPlugs/directives/DirHubspot.js +1 -0
  51. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +4 -1
  52. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +4 -1
  53. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +2 -0
  54. package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +12 -8
  55. package/tiledeskChatbotPlugs/directives/DirIntent.js +5 -6
  56. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +1 -0
  57. package/tiledeskChatbotPlugs/directives/DirLockIntent.js +1 -0
  58. package/tiledeskChatbotPlugs/directives/DirMake.js +16 -1
  59. package/tiledeskChatbotPlugs/directives/DirMessage.js +3 -1
  60. package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +1 -0
  61. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +4 -1
  62. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +3 -0
  63. package/tiledeskChatbotPlugs/directives/DirQapla.js +1 -0
  64. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +3 -1
  65. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +2 -1
  66. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +3 -1
  67. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +3 -1
  68. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +3 -1
  69. package/tiledeskChatbotPlugs/directives/DirReply.js +18 -7
  70. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +13 -8
  71. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +3 -1
  72. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +1 -0
  73. package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +1 -0
  74. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +4 -1
  75. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +3 -1
  76. package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +1 -0
  77. package/tiledeskChatbotPlugs/directives/DirWait.js +1 -0
  78. package/tiledeskChatbotPlugs/directives/DirWebRequest.js +1 -0
  79. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +19 -19
  80. package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +417 -0
  81. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +40 -6
  82. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -0
  83. package/tiledeskChatbotPlugs/directives/Directives.js +0 -3
  84. package/utils/TiledeskChatbotUtil.js +57 -19
  85. package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +0 -332
  86. package/tiledeskChatbotPlugs/directives/DirFlowLog.js +0 -88
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
 
package/ExtApi.js CHANGED
@@ -10,6 +10,12 @@ class ExtApi {
10
10
  throw new Error("options.TILEBOT_ENDPOINT is mandatory");
11
11
  //this.extEndpoint = `${options.TILEBOT_ENDPOINT}/;
12
12
  }
13
+ if (options.log) {
14
+ this.log = options.log;
15
+ }
16
+ else {
17
+ this.log = false;
18
+ }
13
19
  this.TILEBOT_ENDPOINT = options.TILEBOT_ENDPOINT;
14
20
  }
15
21
 
@@ -57,7 +63,8 @@ class ExtApi {
57
63
  callback(null, resbody);
58
64
  }
59
65
  }
60
- });
66
+ }, this.log
67
+ );
61
68
  }
62
69
 
63
70
  }
package/ExtUtil.js CHANGED
@@ -8,19 +8,20 @@ const { FillParamsChatbotPlug } = require('./tiledeskChatbotPlugs/FillParamsChat
8
8
 
9
9
  // PROD
10
10
  /*const { MessagePipeline } = require('@tiledesk/tiledesk-chatbot-plugs/MessagePipeline');
11
+ const { DirectivesChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/DirectivesChatbotPlug');
11
12
  const { SplitsChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/SplitsChatbotPlug');
12
13
  const { MarkbotChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/MarkbotChatbotPlug');
13
14
  const { WebhookChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/WebhookChatbotPlug');*/
14
15
 
15
16
  class ExtUtil {
16
17
 
17
- static async execPipelineExt(request, static_bot_answer, directivesPlug, tdcache) {
18
+ static async execPipelineExt(request, static_bot_answer, directivesPlug, tdcache, log) {
18
19
  const messagePipeline = new MessagePipeline(static_bot_answer, null);
19
20
  messagePipeline.addPlug(directivesPlug);
20
- messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache)); // in original message
21
- messagePipeline.addPlug(new SplitsChatbotPlug());
22
- messagePipeline.addPlug(new MarkbotChatbotPlug());
23
- messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache)); // in splits
21
+ messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache, log)); // in original message
22
+ messagePipeline.addPlug(new SplitsChatbotPlug(log));
23
+ messagePipeline.addPlug(new MarkbotChatbotPlug(log));
24
+ messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache, log)); // in splits
24
25
  const bot_answer = await messagePipeline.exec();
25
26
  return bot_answer;
26
27
  }
package/Logger.js CHANGED
@@ -2,18 +2,13 @@ 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
-
9
5
  let publisher = new Publisher(AMQP_MANAGER_URL, {
10
6
  debug: false,
11
7
  queueName: "logs_queue",
12
- exchange: "amq.topic"
8
+ exchange: "tiledesk-multi",
9
+ topic: "logs",
13
10
  })
14
11
 
15
- console.log("LOGGER publisher: ", publisher);
16
-
17
12
  class Logger {
18
13
 
19
14
  constructor(config) {
@@ -38,14 +33,17 @@ class Logger {
38
33
  }
39
34
 
40
35
  this.request_id = config.request_id;
41
-
42
36
  this.dev = false;
43
37
  if (config.dev && config.dev === true) {
44
38
  this.dev = true;
45
- } else {
46
- this._disableDebugMethods()
47
39
  }
48
-
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
+
49
47
  }
50
48
 
51
49
  error(...args) {
@@ -70,29 +68,27 @@ class Logger {
70
68
 
71
69
  base(level, text) {
72
70
  if (!this.request_id || !publisher) {
73
- console.log("Return because request or publisher is undefined", this.request_id, publisher);
71
+ //console.log("Return because request or publisher is undefined", this.request_id, publisher);
74
72
  return;
75
73
  }
76
74
 
77
75
  let data = {
78
76
  request_id: this.request_id,
79
- id_project: this.request_id.split("-")[2],
80
77
  text: text,
81
78
  level: level,
82
- nlevel: levels[level],
83
79
  timestamp: new Date(),
84
80
  dev: this.dev
85
81
  }
86
82
 
87
- let topic = LOGS_BASE_ROUTING_KEY + `.${this.request_id}`;
88
- console.log("LOGGER publishing on topic ", topic)
89
- publisher.publish(data, topic);
90
- return;
83
+ publisher.publish(data, (err, ok) => {
84
+ if (err) console.warn("publish log fail: ", err);
85
+ return;
86
+ })
91
87
  }
92
88
 
93
89
  formatLog(args) {
94
90
  return args
95
- .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg))
91
+ .map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg ))
96
92
  .join(" ")
97
93
  }
98
94
 
@@ -100,14 +96,9 @@ class Logger {
100
96
  _disableMethods() {
101
97
  const methods = ['error', 'warn', 'info', 'debug'];
102
98
  methods.forEach(method => {
103
- this[method] = () => { };
99
+ this[method] = () => {};
104
100
  });
105
- }
106
-
107
- _disableDebugMethods() {
108
- const method = 'debug';
109
- this[method] = () => { };
110
- }
101
+ }
111
102
 
112
103
  }
113
104
 
@@ -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 };
@@ -11,6 +11,7 @@ class IntentForm {
11
11
  this.form = options.form;
12
12
  this.CURRENT_FIELD_INDEX_KEY = "tilebot:requests:" + this.requestId + ":currentFieldIndex"
13
13
  this.CURRENT_FORM_KEY = "tilebot:requests:" + this.requestId + ":currentForm"
14
+ this.log = options.log;
14
15
  this.requestParameters = options.requestParameters;
15
16
  }
16
17
 
@@ -4,7 +4,7 @@ const winston = require('../utils/winston.js')
4
4
 
5
5
  class IntentsMachineFactory {
6
6
 
7
- static getMachine(bot, botId, projectId) {
7
+ static getMachine(bot, botId, projectId, log) {
8
8
  let machine;
9
9
  if (bot && bot.intentsEngine === "tiledesk-ai") {
10
10
  winston.verbose("(IntentsMachineFactory) bot.intentsEngine is tiledesk-ai");
@@ -15,7 +15,7 @@ class IntentsMachineFactory {
15
15
  }
16
16
  else if (bot) {
17
17
  winston.verbose("(IntentsMachineFactory) Setting MongodbIntentsMachine with bot:", JSON.stringify(bot));
18
- machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language});
18
+ machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language, log});
19
19
  }
20
20
  else {
21
21
  winston.error("bot is null for: " + botId + " on projectId: " + projectId);
@@ -23,10 +23,10 @@ class IntentsMachineFactory {
23
23
  return machine;
24
24
  }
25
25
 
26
- static getBackupMachine(bot, botId, projectId) {
26
+ static getBackupMachine(bot, botId, projectId, log) {
27
27
  let machine;
28
28
  winston.verbose("(IntentsMachineFactory) Setting MongodbIntentsMachine as Backup Intents Machine on bot:", JSON.stringify(bot));
29
- machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language});
29
+ machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language, log});
30
30
  return machine;
31
31
  }
32
32
  }
@@ -9,6 +9,7 @@ class MongodbBotsDataSource {
9
9
  throw new Error("config.projectId is mandatory");
10
10
  }
11
11
  this.projectId = config.projectId;
12
+ this.log = config.log;
12
13
  }
13
14
 
14
15
  async getBotById(botId) {
@@ -10,6 +10,7 @@ class MongodbIntentsMachine {
10
10
  }
11
11
  this.projectId = config.projectId;
12
12
  this.language = config.language;
13
+ this.log = config.log;
13
14
  }
14
15
 
15
16
  /**
@@ -1,5 +1,6 @@
1
1
  // let Faq = require('./faq');
2
2
  // let Faq_kb = require('./faq_kb');
3
+ // const { DirectivesChatbotPlug } = require('../tiledeskChatbotPlugs/DirectivesChatbotPlug');
3
4
  const { MessagePipeline } = require('../tiledeskChatbotPlugs/MessagePipeline');
4
5
  const { WebhookChatbotPlug } = require('../tiledeskChatbotPlugs/WebhookChatbotPlug');
5
6
  const { TiledeskClient } = require('@tiledesk/tiledesk-client');
@@ -40,6 +41,7 @@ class TiledeskChatbot {
40
41
  this.projectId = config.projectId;
41
42
  this.MAX_STEPS = config.MAX_STEPS;
42
43
  this.MAX_EXECUTION_TIME = config.MAX_EXECUTION_TIME;
44
+ this.log = config.log;
43
45
  }
44
46
 
45
47
  async replyToMessage(message, callback) {
@@ -70,13 +72,13 @@ class TiledeskChatbot {
70
72
  winston.verbose("(TiledeskChatbot) Resetting current step by request message: " + message.text);
71
73
  await TiledeskChatbot.resetStep(this.tdcache, this.requestId);
72
74
  await TiledeskChatbot.resetStarted(this.tdcache, this.requestId);
73
-
74
- if (this.tdcache) {
75
- let currentStep =
76
- await TiledeskChatbot.currentStep(this.tdcache, this.requestId);
77
- winston.verbose("(TiledeskChatbot) After reset currentStep:" + currentStep);
75
+ if (this.log) {
76
+ if (this.tdcache) {
77
+ let currentStep =
78
+ await TiledeskChatbot.currentStep(this.tdcache, this.requestId);
79
+ winston.verbose("(TiledeskChatbot) After reset currentStep:" + currentStep);
80
+ }
78
81
  }
79
-
80
82
  }
81
83
  } catch(error) {
82
84
  winston.error("(TiledeskChatbot) Error resetting locked intent: ", error);
@@ -91,7 +93,8 @@ class TiledeskChatbot {
91
93
  // projectId: this.projectId,
92
94
  // token: this.token,
93
95
  // APIURL: this.APIURL,
94
- // APIKEY: this.APIKEY
96
+ // APIKEY: this.APIKEY,
97
+ // log: false
95
98
  // });
96
99
  // it only gets the locked_intent
97
100
  // const faq = await this.botsDataSource.getByIntentDisplayName(this.botId, locked_intent);
@@ -503,7 +506,7 @@ class TiledeskChatbot {
503
506
  TiledeskChatbot.requestCacheKey(requestId) + ":parameters", paramName);
504
507
  }
505
508
 
506
- static async checkStep(_tdcache, requestId, max_steps, max_execution_time) {
509
+ static async checkStep(_tdcache, requestId, max_steps, max_execution_time, log) {
507
510
  winston.verbose("(TiledeskChatbot) Checking on MAX_STEPS: " + max_steps);
508
511
  // let go_on = true; // continue
509
512
  const parameter_key = TiledeskChatbot.requestCacheKey(requestId) + ":step";
@@ -576,7 +579,7 @@ class TiledeskChatbot {
576
579
  }
577
580
  const messagePipeline = new MessagePipeline(static_bot_answer, context);
578
581
  const webhookurl = bot.webhook_url;
579
- messagePipeline.addPlug(new WebhookChatbotPlug(userMessage.request, webhookurl, this.token));
582
+ messagePipeline.addPlug(new WebhookChatbotPlug(userMessage.request, webhookurl, this.token, this.log));
580
583
  const bot_answer = await messagePipeline.exec();
581
584
  return bot_answer;
582
585
  }
@@ -589,7 +592,8 @@ class TiledeskChatbot {
589
592
  form: form,
590
593
  requestId: this.requestId,
591
594
  chatbot: this,
592
- requestParameters: all_parameters
595
+ requestParameters: all_parameters,
596
+ log: this.log
593
597
  });
594
598
  let message = await intentForm.getMessage(userInputReply);
595
599
  return message;
@@ -606,7 +610,8 @@ class TiledeskChatbot {
606
610
  projectId: this.projectId,
607
611
  token: this.token,
608
612
  APIURL: this.APIURL,
609
- APIKEY: this.APIKEY
613
+ APIKEY: this.APIKEY,
614
+ log: this.log
610
615
  });
611
616
  // const parameters_key = "tilebot:requests:" + requestId + ":parameters";
612
617
  const all_parameters = await this.allParameters();//this.tdcache.hgetall(parameters_key);
@@ -12,6 +12,7 @@ class TiledeskIntentsMachine {
12
12
  else {
13
13
  this.API_ENDPOINT = config.API_ENDPOINT;
14
14
  }
15
+ this.log = config.log;
15
16
  }
16
17
 
17
18
  /**
@@ -92,7 +93,7 @@ class TiledeskIntentsMachine {
92
93
  return tiledesk_intents;
93
94
  }
94
95
 
95
- myrequest(options, callback) {
96
+ myrequest(options, callback, log) {
96
97
  axios(
97
98
  {
98
99
  url: options.url,
@@ -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) {