@tiledesk/tiledesk-tybot-connector 0.5.0 → 2.0.0

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 (100) hide show
  1. package/ExtApi.js +4 -83
  2. package/ExtUtil.js +0 -1
  3. package/Logger.js +105 -0
  4. package/TdCache.js +5 -3
  5. package/TiledeskClientTest.js +5 -28
  6. package/TiledeskExpression.js +6 -47
  7. package/{models → engine}/IntentForm.js +30 -44
  8. package/{models → engine}/IntentsMachineFactory.js +5 -4
  9. package/{models → engine}/MongodbBotsDataSource.js +31 -55
  10. package/{models → engine}/MongodbIntentsMachine.js +6 -5
  11. package/{models → engine}/TiledeskChatbot.js +82 -259
  12. package/{models → engine}/TiledeskChatbotConst.js +9 -0
  13. package/{models → engine}/TiledeskIntentsMachine.js +5 -15
  14. package/{models → engine/mock}/MockBotsDataSource.js +3 -19
  15. package/{models → engine/mock}/MockTdCache.js +0 -9
  16. package/index.js +103 -380
  17. package/logs/app.log +12723 -277
  18. package/logs/app1.log +62258 -0
  19. package/logs/app2.log +46280 -0
  20. package/logs/app3.log +31686 -0
  21. package/logs/app4.log +46163 -0
  22. package/logs/app5.log +33173 -0
  23. package/models/faq.js +2 -5
  24. package/package.json +5 -2
  25. package/{TiledeskServices → services}/AIService.js +4 -3
  26. package/{models/faqKbService.js → services/FaqKbService.js} +1 -2
  27. package/{models/faqService.js → services/FaqService.js} +4 -3
  28. package/services/IntegrationService.js +43 -0
  29. package/services/TilebotService.js +47 -0
  30. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +49 -135
  31. package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +8 -14
  32. package/tiledeskChatbotPlugs/Filler.js +0 -1
  33. package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +12 -20
  34. package/tiledeskChatbotPlugs/MessagePipeline.js +5 -15
  35. package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +4 -13
  36. package/tiledeskChatbotPlugs/TiledeskRequestVariables.js +1 -1
  37. package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +21 -89
  38. package/tiledeskChatbotPlugs/directives/DEPRECATED_DirSetAttribute.js +1 -1
  39. package/tiledeskChatbotPlugs/directives/DirAddTags.js +23 -140
  40. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +42 -128
  41. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +37 -127
  42. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +52 -145
  43. package/tiledeskChatbotPlugs/directives/DirAssign.js +12 -23
  44. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +16 -12
  45. package/tiledeskChatbotPlugs/directives/DirAssistant.js +56 -198
  46. package/tiledeskChatbotPlugs/directives/DirBrevo.js +41 -101
  47. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +9 -19
  48. package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -1
  49. package/tiledeskChatbotPlugs/directives/DirClose.js +4 -2
  50. package/tiledeskChatbotPlugs/directives/DirCode.js +16 -23
  51. package/tiledeskChatbotPlugs/directives/DirCondition.js +19 -25
  52. package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +9 -82
  53. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +10 -22
  54. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +34 -89
  55. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +17 -22
  56. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +8 -8
  57. package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -12
  58. package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +2 -6
  59. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -4
  60. package/tiledeskChatbotPlugs/directives/DirForm.js +17 -24
  61. package/tiledeskChatbotPlugs/directives/DirGptTask.js +49 -139
  62. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +8 -53
  63. package/tiledeskChatbotPlugs/directives/DirHubspot.js +31 -91
  64. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +19 -26
  65. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +24 -78
  66. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +17 -68
  67. package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -100
  68. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +15 -14
  69. package/tiledeskChatbotPlugs/directives/DirLockIntent.js +7 -12
  70. package/tiledeskChatbotPlugs/directives/DirMake.js +21 -53
  71. package/tiledeskChatbotPlugs/directives/DirMessage.js +35 -28
  72. package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +8 -87
  73. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +6 -4
  74. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -4
  75. package/tiledeskChatbotPlugs/directives/DirQapla.js +26 -120
  76. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +11 -19
  77. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +4 -0
  78. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +5 -2
  79. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +12 -58
  80. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +11 -57
  81. package/tiledeskChatbotPlugs/directives/DirReply.js +36 -30
  82. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +30 -72
  83. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +9 -10
  84. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +15 -40
  85. package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +8 -5
  86. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +25 -113
  87. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +14 -13
  88. package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +3 -3
  89. package/tiledeskChatbotPlugs/directives/DirWait.js +5 -6
  90. package/tiledeskChatbotPlugs/directives/DirWebRequest.js +14 -49
  91. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +22 -77
  92. package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +1 -1
  93. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +11 -14
  94. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +13 -42
  95. package/tiledeskChatbotPlugs/directives/Directives.js +0 -3
  96. package/utils/HttpUtils.js +128 -0
  97. package/{models → utils}/TiledeskChatbotUtil.js +164 -234
  98. package/utils/winston.js +42 -0
  99. package/TiledeskServices/utils.js +0 -99
  100. /package/{models → engine/mock}/MockIntentsMachine.js +0 -0
@@ -32,7 +32,7 @@ const { DirWhatsappByAttribute } = require('./directives/DirWhatsappByAttribute'
32
32
  const { DirAskGPT } = require('./directives/DirAskGPT');
33
33
  const { DirQapla } = require('./directives/DirQapla');
34
34
 
35
- const { TiledeskChatbot } = require('../models/TiledeskChatbot');
35
+ const { TiledeskChatbot } = require('../engine/TiledeskChatbot');
36
36
  const { DirIfOnlineAgents } = require('./directives/DirIfOnlineAgents');
37
37
  const { DirReply } = require('./directives/DirReply');
38
38
  const { DirRandomReply } = require('./directives/DirRandomReply');
@@ -58,6 +58,8 @@ const { DirAiTask, DirAiPrompt } = require('./directives/DirAiPrompt');
58
58
  const { DirWebResponse } = require('./directives/DirWebResponse');
59
59
  const { DirConnectBlock } = require('./directives/DirConnectBlock');
60
60
 
61
+ const winston = require('../utils/winston');
62
+
61
63
  class DirectivesChatbotPlug {
62
64
 
63
65
  /**
@@ -78,7 +80,6 @@ class DirectivesChatbotPlug {
78
80
  this.reply = config.reply;
79
81
  this.chatbot = config.chatbot;
80
82
  this.message = config.message;
81
- // console.log("We have the support request:", JSON.stringify(this.supportRequest))
82
83
  }
83
84
 
84
85
  exec(pipeline) {
@@ -88,27 +89,24 @@ class DirectivesChatbotPlug {
88
89
  pipeline.nextplug();
89
90
  return;
90
91
  }
92
+
91
93
  const message_text = message.text;
92
- if (this.log) { console.log("processing message:", message_text); }
94
+ winston.verbose("(DirectivesChatbotPlug) processing message: " + message_text);
95
+
93
96
  let parsed_result = TiledeskChatbotUtil.parseDirectives(message_text);
94
- if (this.log) {
95
- console.log("Message directives:", JSON.stringify(parsed_result));
96
- console.log("Message text ripped from directives:", parsed_result.text);
97
- }
97
+
98
+ winston.debug("(DirectivesChatbotPlug) Message directives: ", parsed_result);
99
+ winston.debug("(DirectivesChatbotPlug) Message text ripped from directives: " + parsed_result.text);
100
+
98
101
  if (parsed_result && parsed_result.directives && parsed_result.directives.length > 0) {
99
- if (this.log) {console.log("Do not process more intents. Process directives and return");}
102
+ winston.verbose("(DirectivesChatbotPlug) Do not process more intents. Process directives and return");
100
103
  const text = parsed_result.text;
101
104
  message.text = text;
102
105
  this.directives = parsed_result.directives;
103
106
  this.processInlineDirectives(pipeline, () => {
104
- if (this.log) { console.log("End process directives."); }
107
+ winston.verbose("(DirectivesChatbotPlug) End process directives.");
105
108
  pipeline.nextplug();
106
109
  });
107
- //pipeline.nextplug();
108
- /*this.processDirectives( () => {
109
- console.log("End process directives.");
110
- pipeline.nextplug();
111
- });*/
112
110
  }
113
111
  else {
114
112
  pipeline.nextplug();
@@ -120,24 +118,22 @@ class DirectivesChatbotPlug {
120
118
  this.theend = theend;
121
119
  const directives = this.directives;
122
120
  if (!directives || directives.length === 0) {
123
- if (this.log) { console.log("No directives to process."); }
121
+ winston.verbose("(DirectivesChatbotPlug) No directives to process.");
124
122
  this.theend();
125
123
  return;
126
124
  }
127
- const supportRequest = this.supportRequest;
128
- // console.log("supportRequest is:", JSON.stringify(supportRequest))
129
125
 
126
+ const supportRequest = this.supportRequest;
130
127
  const token = this.token;
131
128
  const API_ENDPOINT = this.API_ENDPOINT;
132
129
  const TILEBOT_ENDPOINT = this.TILEBOT_ENDPOINT;
133
130
 
134
- // const requestId = supportRequest.request_id
135
131
  let depId;
136
132
  if (supportRequest.department && supportRequest.department._id) {
137
- if (this.log) {console.log("setting depId:", supportRequest.department._id);}
133
+ winston.debug("(DirectivesChatbotPlug) Setting depId: " + supportRequest.department._id);
138
134
  depId = supportRequest.department._id;
139
- if (this.log) {console.log("depId is:", depId);}
140
135
  }
136
+
141
137
  const projectId = supportRequest.id_project;
142
138
  const tdcache = this.tdcache;
143
139
  let tdclient = null;
@@ -151,7 +147,7 @@ class DirectivesChatbotPlug {
151
147
  });
152
148
  }
153
149
  catch(err) {
154
- console.log("An error occurred while creating TiledeskClient in DirectivesChatbotPlug:", err);
150
+ winston.error("(DirectivesChatbotPlug) An error occurred while creating TiledeskClient in DirectivesChatbotPlug: ", err);
155
151
  }
156
152
 
157
153
  this.context = {
@@ -169,37 +165,29 @@ class DirectivesChatbotPlug {
169
165
  HELP_CENTER_API_ENDPOINT: this.HELP_CENTER_API_ENDPOINT,
170
166
  log: this.log
171
167
  }
172
- if (this.log) {console.log("this.context.departmentId is:", this.context.departmentId);}
168
+ winston.debug("(DirectivesChatbotPlug) this.context.departmentId: " + this.context.departmentId);
173
169
 
174
170
  this.curr_directive_index = -1;
175
- if (this.log) { console.log("processing directives...");}
171
+ winston.verbose("(DirectivesChatbotPlug) processing directives...");
176
172
 
177
173
  const next_dir = await this.nextDirective(directives);
178
- if (this.log) { console.log("next_dir:", JSON.stringify(next_dir));}
174
+ winston.debug("(DirectivesChatbotPlug) next_dir: ", next_dir);
179
175
  await this.process(next_dir);
180
176
  }
181
177
 
182
178
  async nextDirective(directives) {
183
- if (this.log) {console.log("....nextDirective() checkStep():");}
179
+ winston.debug("(DirectivesChatbotPlug) ....nextDirective() checkStep()");
184
180
  const go_on = await TiledeskChatbot.checkStep(
185
181
  this.context.tdcache, this.context.requestId, this.chatbot?.MAX_STEPS, this.chatbot?.MAX_EXECUTION_TIME, this.log
186
182
  );
187
- // const current_step = await TiledeskChatbot.currentStep(this.context.tdcache, this.context.requestId);
188
- // if (this.log) {console.log("........nextDirective() currentStep:", current_step);}
183
+
189
184
  if (go_on.error) {
190
- if (this.log) {console.log("go_on == false! nextDirective() Stopped!");}
185
+ winston.debug("(DirectivesChatbotPlug) go_on == false! nextDirective() Stopped!");
191
186
  return this.errorMessage(go_on.error); //"Request error: anomaly detection. MAX ACTIONS exeeded.");
192
187
  }
193
- // else if (go_on == 2) {
194
- // return null;
195
- // }
196
- else { // continue with the next directive
197
- // console.log("Go on!");
198
- }
199
188
  this.curr_directive_index += 1;
200
189
  if (this.curr_directive_index < directives.length) {
201
190
  let nextd = directives[this.curr_directive_index];
202
- // console.log("nextd:", nextd);
203
191
  return nextd;
204
192
  }
205
193
  else {
@@ -225,39 +213,26 @@ class DirectivesChatbotPlug {
225
213
  }
226
214
 
227
215
  async process(directive) {
228
- // console.log(".process(directive):", JSON.stringify(directive));
229
216
  let context = this.context;
230
- // console.log(".this.context.reply", JSON.stringify(this.context.reply));
231
217
  if (directive) {
232
- if (context.log) {
233
- console.log("directive['name']:", directive["name"]);
234
- }
218
+ winston.verbose("(DirectivesChatbotPlug) directive['name']: " + directive["name"]);
235
219
  }
236
220
  let directive_name = null;
237
221
  if (directive && directive.name) {
238
222
  directive_name = directive.name.toLowerCase();
239
223
  }
240
224
  if (directive && directive.action) {
241
- // console.log("Checking locks", JSON.stringify(directive));
242
- // try {
243
225
  const action_id = directive.action["_tdActionId"];
244
- // console.log("Checking locked directive:", action_id, "for request:", this.supportRequest.request_id);
245
226
  const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
246
- // console.log("locked_action_id:", locked_action_id);
247
227
  if ( locked_action_id && (locked_action_id !== action_id) ) {
248
- // console.log("Found locked action:", locked_action_id, "Skipping this action:", action_id);
249
228
  let next_dir = await this.nextDirective(this.directives);
250
229
  this.process(next_dir);
251
230
  return;
252
231
  }
253
- else {
254
- // go on
255
- // console.log("Going on to next directive...");
256
- }
257
232
 
258
233
  }
259
234
  if (directive == null || (directive !== null && directive["name"] === undefined)) {
260
- if (context.log) { console.log("stop process(). directive is (null?):", directive);}
235
+ winston.debug("(DirectivesChatbotPlug) stop process(). directive is (null?): ", directive);
261
236
  this.theend();
262
237
  }
263
238
  else if (directive_name === Directives.DEPARTMENT) {
@@ -273,10 +248,9 @@ class DirectivesChatbotPlug {
273
248
  });
274
249
  }
275
250
  else if (directive_name === Directives.INTENT) {
276
- // console.log(".....DirIntent")
277
251
  new DirIntent(context).execute(directive, async (stop) => {
278
252
  if (stop) {
279
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
253
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
280
254
  this.theend();
281
255
  }
282
256
  else {
@@ -288,7 +262,7 @@ class DirectivesChatbotPlug {
288
262
  else if (directive_name === Directives.MESSAGE) {
289
263
  new DirMessage(context).execute(directive, async (stop) => {
290
264
  if (stop) {
291
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
265
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
292
266
  this.theend();
293
267
  }
294
268
  else {
@@ -298,17 +272,15 @@ class DirectivesChatbotPlug {
298
272
  });
299
273
  }
300
274
  else if (directive_name === Directives.REPLY) {
301
- // console.log("...DirReply");
302
275
  new DirReply(context).execute(directive, async () => {
303
276
  let next_dir = await this.nextDirective(this.directives);
304
277
  this.process(next_dir);
305
278
  });
306
279
  }
307
280
  else if (directive_name === Directives.REPLY_V2) {
308
- // console.log("...DirReplyV2");
309
281
  new DirReplyV2(context).execute(directive, async (stop) => {
310
282
  if (stop) {
311
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
283
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
312
284
  this.theend();
313
285
  }
314
286
  else {
@@ -318,49 +290,42 @@ class DirectivesChatbotPlug {
318
290
  });
319
291
  }
320
292
  else if (directive_name === Directives.DTMF_FORM) {
321
- // console.log("...DirReply");
322
293
  new DirReply(context).execute(directive, async () => {
323
294
  let next_dir = await this.nextDirective(this.directives);
324
295
  this.process(next_dir);
325
296
  });
326
297
  }
327
298
  else if (directive_name === Directives.DTMF_MENU) {
328
- // console.log("...DirReply");
329
299
  new DirReply(context).execute(directive, async () => {
330
300
  let next_dir = await this.nextDirective(this.directives);
331
301
  this.process(next_dir);
332
302
  });
333
303
  }
334
304
  else if (directive_name === Directives.BLIND_TRANSFER) {
335
- // console.log("...DirReply");
336
305
  new DirReply(context).execute(directive, async () => {
337
306
  let next_dir = await this.nextDirective(this.directives);
338
307
  this.process(next_dir);
339
308
  });
340
309
  }
341
310
  else if (directive_name === Directives.SPEECH_FORM) {
342
- // console.log("...DirReply");
343
311
  new DirReply(context).execute(directive, async () => {
344
312
  let next_dir = await this.nextDirective(this.directives);
345
313
  this.process(next_dir);
346
314
  });
347
315
  }
348
316
  else if (directive_name === Directives.PLAY_PROMPT) {
349
- // console.log("...DirReply");
350
317
  new DirReply(context).execute(directive, async () => {
351
318
  let next_dir = await this.nextDirective(this.directives);
352
319
  this.process(next_dir);
353
320
  });
354
321
  }
355
322
  else if (directive_name === Directives.AUDIO_RECORD) {
356
- // console.log("...DirReply");
357
323
  new DirReply(context).execute(directive, async () => {
358
324
  let next_dir = await this.nextDirective(this.directives);
359
325
  this.process(next_dir);
360
326
  });
361
327
  }
362
328
  else if (directive_name === Directives.RANDOM_REPLY) {
363
- // console.log("...DirRandomReply");
364
329
  new DirRandomReply(context).execute(directive, async () => {
365
330
  let next_dir = await this.nextDirective(this.directives);
366
331
  this.process(next_dir);
@@ -369,7 +334,7 @@ class DirectivesChatbotPlug {
369
334
  else if (directive_name === Directives.IF_OPEN_HOURS) {
370
335
  new DirIfOpenHours(context).execute(directive, async (stop) => {
371
336
  if (stop) {
372
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
337
+ winston.debug("(DirectivesChatbotPlug) DirIfOpenHours Stopping Actions on: ", directive);
373
338
  this.theend();
374
339
  }
375
340
  else {
@@ -379,25 +344,21 @@ class DirectivesChatbotPlug {
379
344
  });
380
345
  }
381
346
  else if (directive_name === Directives.IF_ONLINE_AGENTS) {
382
- // console.log("...DirIfOnlineAgents")
383
347
  new DirIfOnlineAgents(context).execute(directive, async (stop) => {
384
348
  if (stop) {
385
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
349
+ winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgents Stopping Actions on: ", directive);
386
350
  this.theend();
387
351
  }
388
352
  else {
389
353
  let next_dir = await this.nextDirective(this.directives);
390
354
  this.process(next_dir);
391
355
  }
392
- // let next_dir = await this.nextDirective(this.directives);
393
- // this.process(next_dir);
394
356
  });
395
357
  }
396
358
  else if (directive_name === Directives.IF_ONLINE_AGENTS_V2) {
397
- // console.log("...DirIfOnlineAgents")
398
359
  new DirIfOnlineAgentsV2(context).execute(directive, async (stop) => {
399
360
  if (stop) {
400
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
361
+ winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgentsV2 Stopping Actions on: ", directive);
401
362
  this.theend();
402
363
  }
403
364
  else {
@@ -407,18 +368,15 @@ class DirectivesChatbotPlug {
407
368
  });
408
369
  }
409
370
  else if (directive_name === Directives.FUNCTION_VALUE) {
410
- // console.log("...DirAssignFromFunction")
411
371
  new DirAssignFromFunction(context).execute(directive, async () => {
412
372
  let next_dir = await this.nextDirective(this.directives);
413
373
  this.process(next_dir);
414
374
  });
415
375
  }
416
376
  else if (directive_name === Directives.CONDITION) { // DEPRECATED
417
- // console.log("...DirCondition");
418
377
  new DirCondition(context).execute(directive, async (stop) => {
419
- if (context.log) { console.log("stop on condition?", stop);}
420
378
  if (stop == true) {
421
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
379
+ winston.debug("(DirectivesChatbotPlug) DirCondition Stopping Actions on: ", directive);
422
380
  this.theend();
423
381
  }
424
382
  else {
@@ -428,11 +386,9 @@ class DirectivesChatbotPlug {
428
386
  });
429
387
  }
430
388
  else if (directive_name === Directives.JSON_CONDITION) {
431
- // console.log("...DirJSONCondition");
432
389
  new DirJSONCondition(context).execute(directive, async (stop) => {
433
- // console.log("stop on condition?", stop);
434
390
  if (stop == true) {
435
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
391
+ winston.debug("(DirectivesChatbotPlug) DirJSONCondition Stopping Actions on: ", directive);
436
392
  this.theend();
437
393
  }
438
394
  else {
@@ -442,35 +398,30 @@ class DirectivesChatbotPlug {
442
398
  });
443
399
  }
444
400
  else if (directive_name === Directives.ASSIGN) {
445
- // console.log("...DirAssign", context.log);
446
401
  new DirAssign(context).execute(directive, async () => {
447
402
  let next_dir = await this.nextDirective(this.directives);
448
403
  this.process(next_dir);
449
404
  });
450
405
  }
451
406
  else if (directive_name === Directives.SET_ATTRIBUTE) {
452
- // console.log("...DirSetAttribute");
453
407
  new DirSetAttribute(context).execute(directive, async () => {
454
408
  let next_dir = await this.nextDirective(this.directives);
455
409
  this.process(next_dir);
456
410
  });
457
411
  }
458
412
  else if (directive_name === Directives.SET_ATTRIBUTE_V2) {
459
- // console.log("...DirSetAttribute");
460
413
  new DirSetAttributeV2(context).execute(directive, async () => {
461
414
  let next_dir = await this.nextDirective(this.directives);
462
415
  this.process(next_dir);
463
416
  });
464
417
  }
465
418
  else if (directive_name === Directives.AGENT) {
466
- // console.log("...DirMoveToAgent");
467
419
  new DirMoveToAgent(context).execute(directive, async () => {
468
420
  let next_dir = await this.nextDirective(this.directives);
469
421
  this.process(next_dir);
470
422
  });
471
423
  }
472
424
  else if (directive_name === Directives.CLOSE) {
473
- // console.log("Exec close()")
474
425
  new DirClose(context).execute(directive, async () => {
475
426
  let next_dir = await this.nextDirective(this.directives);
476
427
  this.process(next_dir);
@@ -501,7 +452,6 @@ class DirectivesChatbotPlug {
501
452
  });
502
453
  }
503
454
  else if (directive_name === Directives.WAIT) {
504
- // console.log("........ DirWait");
505
455
  new DirWait(context).execute(directive, async () => {
506
456
  let next_dir = await this.nextDirective(this.directives);
507
457
  this.process(next_dir);
@@ -526,25 +476,21 @@ class DirectivesChatbotPlug {
526
476
  });
527
477
  }
528
478
  else if (directive_name === Directives.SEND_EMAIL) {
529
- // console.log("...DirSendEmail");
530
479
  new DirSendEmail(context).execute(directive, async () => {
531
480
  let next_dir = await this.nextDirective(this.directives);
532
481
  this.process(next_dir);
533
482
  });
534
483
  }
535
484
  else if (directive_name === Directives.WEB_REQUEST) {
536
- // console.log("...DirWebRequest");
537
485
  new DirWebRequest(context).execute(directive, async () => {
538
486
  let next_dir = await this.nextDirective(this.directives);
539
487
  this.process(next_dir);
540
488
  });
541
489
  }
542
490
  else if (directive_name === Directives.WEB_REQUEST_V2) {
543
- // console.log("...DirWebRequestV2");
544
491
  new DirWebRequestV2(context).execute(directive, async (stop) => {
545
- if (context.log) { console.log("stop on condition?", stop);}
546
492
  if (stop == true) {
547
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
493
+ winston.debug("(DirectivesChatbotPlug) DirWebRequestV2 Stopping Actions on: ", directive);
548
494
  this.theend();
549
495
  }
550
496
  else {
@@ -554,11 +500,9 @@ class DirectivesChatbotPlug {
554
500
  });
555
501
  }
556
502
  else if (directive_name === Directives.FORM) {
557
- console.log("...DirForm");
558
503
  new DirForm(context).execute(directive, async (stop) => {
559
- if (context.log) { console.log("stop on form?", stop);}
560
504
  if (stop == true) {
561
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
505
+ winston.debug("(DirectivesChatbotPlug) DirForm Stopping Actions on: ", directive);
562
506
  this.theend();
563
507
  }
564
508
  else {
@@ -568,21 +512,18 @@ class DirectivesChatbotPlug {
568
512
  });
569
513
  }
570
514
  else if (directive_name === Directives.CAPTURE_USER_REPLY) {
571
- // console.log("...DirCaptureUserReply");
572
515
  new DirCaptureUserReply(context).execute(directive, async () => {
573
516
  let next_dir = await this.nextDirective(this.directives);
574
517
  this.process(next_dir);
575
518
  });
576
519
  }
577
520
  else if (directive_name === Directives.CODE) {
578
- // console.log("...DirCode", directive);
579
521
  new DirCode(context).execute(directive, async () => {
580
522
  let next_dir = await this.nextDirective(this.directives);
581
523
  this.process(next_dir);
582
524
  });
583
525
  }
584
526
  else if (directive_name === Directives.DELETE) {
585
- // console.log("got delete dir...")
586
527
  new DirDeleteVariable(context).execute(directive, async () => {
587
528
  let next_dir = await this.nextDirective(this.directives);
588
529
  this.process(next_dir);
@@ -590,9 +531,8 @@ class DirectivesChatbotPlug {
590
531
  }
591
532
  else if (directive_name === Directives.ASK_HELP_CENTER) {
592
533
  new DirDeflectToHelpCenter(context).execute(directive, async (stop) => {
593
- if (context.log) { console.log("DeflectToHelpCenter stop?", stop);}
594
534
  if (stop == true) {
595
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
535
+ winston.debug("(DirectivesChatbotPlug) DirDeflectToHelpCenter Stopping Actions on: ", directive);
596
536
  this.theend();
597
537
  }
598
538
  else {
@@ -603,9 +543,8 @@ class DirectivesChatbotPlug {
603
543
  }
604
544
  else if (directive_name === Directives.ASK_GPT) {
605
545
  new DirAskGPT(context).execute(directive, async (stop) => {;
606
- if (context.log) { console.log("AskGPT stop?", stop);}
607
546
  if (stop == true) {
608
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
547
+ winston.debug("(DirectivesChatbotPlug) DirAskGPT Stopping Actions on: ", directive);
609
548
  this.theend();
610
549
  }
611
550
  else {
@@ -616,9 +555,8 @@ class DirectivesChatbotPlug {
616
555
  }
617
556
  else if (directive_name === Directives.ASK_GPT_V2) {
618
557
  new DirAskGPTV2(context).execute(directive, async (stop) => {;
619
- if (context.log) { console.log("AskGPTV2 stop?", stop);}
620
558
  if (stop == true) {
621
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
559
+ winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
622
560
  this.theend();
623
561
  }
624
562
  else {
@@ -629,9 +567,8 @@ class DirectivesChatbotPlug {
629
567
  }
630
568
  else if (directive_name === Directives.GPT_TASK) {
631
569
  new DirGptTask(context).execute(directive, async (stop) => {
632
- if (context.log) { console.log("GPTTask stop?", stop);}
633
570
  if (stop == true) {
634
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
571
+ winston.debug("(DirectivesChatbotPlug) DirGptTask Stopping Actions on: ", directive);
635
572
  this.theend();
636
573
  }
637
574
  else {
@@ -642,9 +579,8 @@ class DirectivesChatbotPlug {
642
579
  }
643
580
  else if (directive_name === Directives.AI_PROMPT) {
644
581
  new DirAiPrompt(context).execute(directive, async (stop) => {
645
- if (context.log) { console.log("AiPrompt stop?", stop);}
646
582
  if (stop == true) {
647
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
583
+ winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
648
584
  this.theend();
649
585
  }
650
586
  else {
@@ -662,7 +598,7 @@ class DirectivesChatbotPlug {
662
598
  else if (directive_name === Directives.SEND_WHATSAPP) {
663
599
  new DirSendWhatsapp(context).execute(directive, async (stop) => {
664
600
  if (stop == true) {
665
- if (context.log) { console.log("Stoppin Actions on:", JSON.stringify(directive));}
601
+ winston.debug("(DirectivesChatbotPlug) DirSendWhatsapp Stopping Actions on: ", directive);
666
602
  this.theend();
667
603
  } else {
668
604
  let next_dir = await this.nextDirective(this.directives);
@@ -672,9 +608,8 @@ class DirectivesChatbotPlug {
672
608
  }
673
609
  else if (directive_name === Directives.QAPLA) {
674
610
  new DirQapla(context).execute(directive, async (stop) => {
675
- if (context.log) { console.log("DirQapla stop?", stop);}
676
611
  if (stop == true) {
677
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
612
+ winston.debug("(DirectivesChatbotPlug) DirQapla Stopping Actions on: ", directive);
678
613
  this.theend();
679
614
  }
680
615
  else {
@@ -685,9 +620,8 @@ class DirectivesChatbotPlug {
685
620
  }
686
621
  else if (directive_name === Directives.MAKE) {
687
622
  new DirMake(context).execute(directive, async (stop) => {
688
- if (context.log) { console.log("DirMake stop?", stop);}
689
623
  if (stop == true) {
690
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
624
+ winston.debug("(DirectivesChatbotPlug) DirMake Stopping Actions on: ", directive);
691
625
  this.theend();
692
626
  }
693
627
  else {
@@ -698,9 +632,8 @@ class DirectivesChatbotPlug {
698
632
  }
699
633
  else if (directive_name === Directives.HUBSPOT) {
700
634
  new DirHubspot(context).execute(directive, async (stop) => {
701
- if (context.log) { console.log("Hubspot stop?", stop);}
702
635
  if (stop == true) {
703
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
636
+ winston.debug("(DirectivesChatbotPlug) DirHubspot Stopping Actions on: ", directive);
704
637
  this.theend();
705
638
  } else {
706
639
  let next_dir = await this.nextDirective(this.directives);
@@ -721,11 +654,9 @@ class DirectivesChatbotPlug {
721
654
  })
722
655
  }
723
656
  else if (directive_name === Directives.GPT_ASSISTANT) {
724
- // console.log("...GPT_ASSISTANT");
725
657
  new DirAssistant(context).execute(directive, async (stop) => {
726
- if (context.log) { console.log("stop on condition?", stop);}
727
658
  if (stop == true) {
728
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
659
+ winston.debug("(DirectivesChatbotPlug) DirAssistant Stopping Actions on: ", directive);
729
660
  this.theend();
730
661
  }
731
662
  else {
@@ -735,7 +666,6 @@ class DirectivesChatbotPlug {
735
666
  });
736
667
  }
737
668
  else if (directive_name === Directives.CONTACT_UPDATE) {
738
- // console.log("...CONTACT_UPDATE");
739
669
  new DirContactUpdate(context).execute(directive, async () => {
740
670
  let next_dir = await this.nextDirective(this.directives);
741
671
  this.process(next_dir);
@@ -754,18 +684,15 @@ class DirectivesChatbotPlug {
754
684
  });
755
685
  }
756
686
  else if (directive_name === Directives.CONNECT_BLOCK) {
757
- // console.log(".....DirIntent")
758
687
  new DirConnectBlock(context).execute(directive, async () => {
759
688
  let next_dir = await this.nextDirective(this.directives);
760
689
  this.process(next_dir);
761
690
  });
762
691
  }
763
692
  else if (directive_name === Directives.ADD_TAGS) {
764
- // console.log(".....DirAddTags")
765
693
  new DirAddTags(context).execute(directive, async (stop) => {
766
- if (context.log) { console.log("GPTTask stop?", stop);}
767
694
  if (stop == true) {
768
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
695
+ winston.debug("(DirectivesChatbotPlug) DirAddTags Stopping Actions on: ", directive);
769
696
  this.theend();
770
697
  }
771
698
  else {
@@ -781,7 +708,6 @@ class DirectivesChatbotPlug {
781
708
  });
782
709
  }
783
710
  else {
784
- //console.log("Unhandled Post-message Directive:", directive_name);
785
711
  let next_dir = await this.nextDirective(this.directives);
786
712
  this.process(next_dir);
787
713
  }
@@ -791,7 +717,7 @@ class DirectivesChatbotPlug {
791
717
  processInlineDirectives(pipeline, theend) {
792
718
  const directives = this.directives;
793
719
  if (!directives || directives.length === 0) {
794
- console.log("No directives to process.");
720
+ winston.verbose("(DirectivesChatbotPlug) No directives to process.");
795
721
  return;
796
722
  }
797
723
  const supportRequest = this.supportRequest;
@@ -811,10 +737,10 @@ class DirectivesChatbotPlug {
811
737
  log: false
812
738
  });
813
739
  let i = -1;
814
- if (this.log) { console.log("processing Inline directives:", directives); }
740
+ winston.debug("(DirectivesChatbotPlug) processing Inline directives: ", directives);
815
741
  const process = (directive) => {
816
742
  if (directive) {
817
- if (this.log) {console.log("__directive.name:", directive.name);}
743
+ winston.debug("(DirectivesChatbotPlug) __directive.name: " + directive.name);
818
744
  }
819
745
  let directive_name = null;
820
746
  if (directive && directive.name) {
@@ -823,18 +749,6 @@ class DirectivesChatbotPlug {
823
749
  if (directive == null) {
824
750
  theend();
825
751
  }
826
- // else if (directive_name === Directives.WHEN_OFFLINE_HOURS) { // DEPRECATED
827
- // const offlineHoursDir = new DirOfflineHours(tdclient);
828
- // offlineHoursDir.execute(directive, pipeline, () => {
829
- // process(nextDirective());
830
- // });
831
- // }
832
- // else if (directive_name === Directives.DISABLE_INPUT_TEXT) { // DEPRECATED => will change in a "message-option" --disableInput
833
- // const disableInputTextDir = new DirDisableInputText();
834
- // disableInputTextDir.execute(directive, pipeline, () => {
835
- // process(nextDirective());
836
- // });
837
- // }
838
752
  else if (directive_name === Directives.DEFLECT_TO_HELP_CENTER) {
839
753
  const helpDir = new DirDeflectToHelpCenter({HELP_CENTER_API_ENDPOINT: this.HELP_CENTER_API_ENDPOINT, projectId: projectId});
840
754
  helpDir.execute(directive, pipeline, 3, () => {