@tiledesk/tiledesk-tybot-connector 0.4.2 → 0.5.0-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 (87) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/ExtApi.js +3 -13
  3. package/ExtUtil.js +0 -1
  4. package/Logger.js +86 -0
  5. package/TdCache.js +5 -3
  6. package/TiledeskClientTest.js +5 -28
  7. package/TiledeskExpression.js +6 -47
  8. package/index.js +87 -273
  9. package/logs/app.log +12983 -275
  10. package/logs/app1.log +62258 -0
  11. package/logs/app2.log +46280 -0
  12. package/logs/app3.log +28864 -0
  13. package/models/IntentForm.js +30 -44
  14. package/models/IntentsMachineFactory.js +4 -3
  15. package/models/MockBotsDataSource.js +1 -17
  16. package/models/MockTdCache.js +0 -9
  17. package/models/MongodbBotsDataSource.js +29 -53
  18. package/models/MongodbIntentsMachine.js +5 -4
  19. package/models/TiledeskChatbot.js +79 -258
  20. package/models/TiledeskChatbotConst.js +9 -0
  21. package/models/TiledeskChatbotUtil.js +180 -232
  22. package/models/TiledeskIntentsMachine.js +5 -14
  23. package/models/faqKbService.js +0 -1
  24. package/package.json +5 -2
  25. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +66 -139
  26. package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +7 -13
  27. package/tiledeskChatbotPlugs/Filler.js +0 -1
  28. package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +12 -20
  29. package/tiledeskChatbotPlugs/MessagePipeline.js +5 -15
  30. package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +4 -13
  31. package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +21 -89
  32. package/tiledeskChatbotPlugs/directives/DirAddTags.js +15 -98
  33. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +3 -3
  34. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +32 -57
  35. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +46 -70
  36. package/tiledeskChatbotPlugs/directives/DirAssign.js +11 -22
  37. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +15 -11
  38. package/tiledeskChatbotPlugs/directives/DirAssistant.js +48 -97
  39. package/tiledeskChatbotPlugs/directives/DirBrevo.js +37 -68
  40. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +8 -18
  41. package/tiledeskChatbotPlugs/directives/DirClose.js +3 -1
  42. package/tiledeskChatbotPlugs/directives/DirCode.js +15 -22
  43. package/tiledeskChatbotPlugs/directives/DirCondition.js +18 -24
  44. package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +9 -13
  45. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +7 -19
  46. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +30 -57
  47. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +15 -20
  48. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +7 -7
  49. package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -12
  50. package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +2 -6
  51. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -4
  52. package/tiledeskChatbotPlugs/directives/DirForm.js +15 -22
  53. package/tiledeskChatbotPlugs/directives/DirGptTask.js +38 -65
  54. package/tiledeskChatbotPlugs/directives/DirHubspot.js +27 -58
  55. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +19 -26
  56. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +22 -40
  57. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +17 -32
  58. package/tiledeskChatbotPlugs/directives/DirIntent.js +16 -33
  59. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +14 -13
  60. package/tiledeskChatbotPlugs/directives/DirLockIntent.js +7 -12
  61. package/tiledeskChatbotPlugs/directives/DirMake.js +20 -52
  62. package/tiledeskChatbotPlugs/directives/DirMessage.js +35 -28
  63. package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +10 -20
  64. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +4 -2
  65. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +4 -2
  66. package/tiledeskChatbotPlugs/directives/DirQapla.js +21 -50
  67. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +9 -17
  68. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +4 -0
  69. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +4 -1
  70. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +10 -21
  71. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +9 -19
  72. package/tiledeskChatbotPlugs/directives/DirReply.js +32 -35
  73. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +27 -69
  74. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +8 -9
  75. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +13 -12
  76. package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +7 -4
  77. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +22 -75
  78. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +14 -13
  79. package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +3 -3
  80. package/tiledeskChatbotPlugs/directives/DirWait.js +4 -5
  81. package/tiledeskChatbotPlugs/directives/DirWebRequest.js +13 -48
  82. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +11 -76
  83. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +34 -7
  84. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +11 -14
  85. package/tiledeskChatbotPlugs/directives/Directives.js +1 -3
  86. package/utils/winston.js +42 -0
  87. package/TdCache copy.js +0 -242
@@ -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,25 @@ 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
- const action_id = directive.action["_tdActionId"];
244
- // console.log("Checking locked directive:", action_id, "for request:", this.supportRequest.request_id);
245
- const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
246
- // console.log("locked_action_id:", locked_action_id);
247
- if ( locked_action_id && (locked_action_id !== action_id) ) {
248
- // console.log("Found locked action:", locked_action_id, "Skipping this action:", action_id);
249
- let next_dir = await this.nextDirective(this.directives);
250
- this.process(next_dir);
251
- return;
252
- }
253
- else {
254
- // go on
255
- // console.log("Going on to next directive...");
256
- }
257
-
225
+ const action_id = directive.action["_tdActionId"];
226
+ const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
227
+ if ( locked_action_id && (locked_action_id !== action_id) ) {
228
+ let next_dir = await this.nextDirective(this.directives);
229
+ this.process(next_dir);
230
+ return;
231
+ }
258
232
  }
259
233
  if (directive == null || (directive !== null && directive["name"] === undefined)) {
260
- if (context.log) { console.log("stop process(). directive is (null?):", directive);}
234
+ winston.debug("(DirectivesChatbotPlug) stop process(). directive is (null?): ", directive);
261
235
  this.theend();
262
236
  }
263
237
  else if (directive_name === Directives.DEPARTMENT) {
@@ -273,10 +247,9 @@ class DirectivesChatbotPlug {
273
247
  });
274
248
  }
275
249
  else if (directive_name === Directives.INTENT) {
276
- // console.log(".....DirIntent")
277
250
  new DirIntent(context).execute(directive, async (stop) => {
278
251
  if (stop) {
279
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
252
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
280
253
  this.theend();
281
254
  }
282
255
  else {
@@ -288,7 +261,7 @@ class DirectivesChatbotPlug {
288
261
  else if (directive_name === Directives.MESSAGE) {
289
262
  new DirMessage(context).execute(directive, async (stop) => {
290
263
  if (stop) {
291
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
264
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
292
265
  this.theend();
293
266
  }
294
267
  else {
@@ -298,17 +271,15 @@ class DirectivesChatbotPlug {
298
271
  });
299
272
  }
300
273
  else if (directive_name === Directives.REPLY) {
301
- // console.log("...DirReply");
302
274
  new DirReply(context).execute(directive, async () => {
303
275
  let next_dir = await this.nextDirective(this.directives);
304
276
  this.process(next_dir);
305
277
  });
306
278
  }
307
279
  else if (directive_name === Directives.REPLY_V2) {
308
- // console.log("...DirReplyV2");
309
280
  new DirReplyV2(context).execute(directive, async (stop) => {
310
281
  if (stop) {
311
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
282
+ winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
312
283
  this.theend();
313
284
  }
314
285
  else {
@@ -318,49 +289,42 @@ class DirectivesChatbotPlug {
318
289
  });
319
290
  }
320
291
  else if (directive_name === Directives.DTMF_FORM) {
321
- // console.log("...DirReply");
322
292
  new DirReply(context).execute(directive, async () => {
323
293
  let next_dir = await this.nextDirective(this.directives);
324
294
  this.process(next_dir);
325
295
  });
326
296
  }
327
297
  else if (directive_name === Directives.DTMF_MENU) {
328
- // console.log("...DirReply");
329
298
  new DirReply(context).execute(directive, async () => {
330
299
  let next_dir = await this.nextDirective(this.directives);
331
300
  this.process(next_dir);
332
301
  });
333
302
  }
334
303
  else if (directive_name === Directives.BLIND_TRANSFER) {
335
- // console.log("...DirReply");
336
304
  new DirReply(context).execute(directive, async () => {
337
305
  let next_dir = await this.nextDirective(this.directives);
338
306
  this.process(next_dir);
339
307
  });
340
308
  }
341
309
  else if (directive_name === Directives.SPEECH_FORM) {
342
- // console.log("...DirReply");
343
310
  new DirReply(context).execute(directive, async () => {
344
311
  let next_dir = await this.nextDirective(this.directives);
345
312
  this.process(next_dir);
346
313
  });
347
314
  }
348
315
  else if (directive_name === Directives.PLAY_PROMPT) {
349
- // console.log("...DirReply");
350
316
  new DirReply(context).execute(directive, async () => {
351
317
  let next_dir = await this.nextDirective(this.directives);
352
318
  this.process(next_dir);
353
319
  });
354
320
  }
355
321
  else if (directive_name === Directives.AUDIO_RECORD) {
356
- // console.log("...DirReply");
357
322
  new DirReply(context).execute(directive, async () => {
358
323
  let next_dir = await this.nextDirective(this.directives);
359
324
  this.process(next_dir);
360
325
  });
361
326
  }
362
327
  else if (directive_name === Directives.RANDOM_REPLY) {
363
- // console.log("...DirRandomReply");
364
328
  new DirRandomReply(context).execute(directive, async () => {
365
329
  let next_dir = await this.nextDirective(this.directives);
366
330
  this.process(next_dir);
@@ -369,7 +333,7 @@ class DirectivesChatbotPlug {
369
333
  else if (directive_name === Directives.IF_OPEN_HOURS) {
370
334
  new DirIfOpenHours(context).execute(directive, async (stop) => {
371
335
  if (stop) {
372
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
336
+ winston.debug("(DirectivesChatbotPlug) DirIfOpenHours Stopping Actions on: ", directive);
373
337
  this.theend();
374
338
  }
375
339
  else {
@@ -379,25 +343,21 @@ class DirectivesChatbotPlug {
379
343
  });
380
344
  }
381
345
  else if (directive_name === Directives.IF_ONLINE_AGENTS) {
382
- // console.log("...DirIfOnlineAgents")
383
346
  new DirIfOnlineAgents(context).execute(directive, async (stop) => {
384
347
  if (stop) {
385
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
348
+ winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgents Stopping Actions on: ", directive);
386
349
  this.theend();
387
350
  }
388
351
  else {
389
352
  let next_dir = await this.nextDirective(this.directives);
390
353
  this.process(next_dir);
391
354
  }
392
- // let next_dir = await this.nextDirective(this.directives);
393
- // this.process(next_dir);
394
355
  });
395
356
  }
396
357
  else if (directive_name === Directives.IF_ONLINE_AGENTS_V2) {
397
- // console.log("...DirIfOnlineAgents")
398
358
  new DirIfOnlineAgentsV2(context).execute(directive, async (stop) => {
399
359
  if (stop) {
400
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
360
+ winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgentsV2 Stopping Actions on: ", directive);
401
361
  this.theend();
402
362
  }
403
363
  else {
@@ -407,18 +367,15 @@ class DirectivesChatbotPlug {
407
367
  });
408
368
  }
409
369
  else if (directive_name === Directives.FUNCTION_VALUE) {
410
- // console.log("...DirAssignFromFunction")
411
370
  new DirAssignFromFunction(context).execute(directive, async () => {
412
371
  let next_dir = await this.nextDirective(this.directives);
413
372
  this.process(next_dir);
414
373
  });
415
374
  }
416
375
  else if (directive_name === Directives.CONDITION) { // DEPRECATED
417
- // console.log("...DirCondition");
418
376
  new DirCondition(context).execute(directive, async (stop) => {
419
- if (context.log) { console.log("stop on condition?", stop);}
420
377
  if (stop == true) {
421
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
378
+ winston.debug("(DirectivesChatbotPlug) DirCondition Stopping Actions on: ", directive);
422
379
  this.theend();
423
380
  }
424
381
  else {
@@ -428,11 +385,9 @@ class DirectivesChatbotPlug {
428
385
  });
429
386
  }
430
387
  else if (directive_name === Directives.JSON_CONDITION) {
431
- // console.log("...DirJSONCondition");
432
388
  new DirJSONCondition(context).execute(directive, async (stop) => {
433
- // console.log("stop on condition?", stop);
434
389
  if (stop == true) {
435
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
390
+ winston.debug("(DirectivesChatbotPlug) DirJSONCondition Stopping Actions on: ", directive);
436
391
  this.theend();
437
392
  }
438
393
  else {
@@ -442,35 +397,30 @@ class DirectivesChatbotPlug {
442
397
  });
443
398
  }
444
399
  else if (directive_name === Directives.ASSIGN) {
445
- // console.log("...DirAssign", context.log);
446
400
  new DirAssign(context).execute(directive, async () => {
447
401
  let next_dir = await this.nextDirective(this.directives);
448
402
  this.process(next_dir);
449
403
  });
450
404
  }
451
405
  else if (directive_name === Directives.SET_ATTRIBUTE) {
452
- // console.log("...DirSetAttribute");
453
406
  new DirSetAttribute(context).execute(directive, async () => {
454
407
  let next_dir = await this.nextDirective(this.directives);
455
408
  this.process(next_dir);
456
409
  });
457
410
  }
458
411
  else if (directive_name === Directives.SET_ATTRIBUTE_V2) {
459
- // console.log("...DirSetAttribute");
460
412
  new DirSetAttributeV2(context).execute(directive, async () => {
461
413
  let next_dir = await this.nextDirective(this.directives);
462
414
  this.process(next_dir);
463
415
  });
464
416
  }
465
417
  else if (directive_name === Directives.AGENT) {
466
- // console.log("...DirMoveToAgent");
467
418
  new DirMoveToAgent(context).execute(directive, async () => {
468
419
  let next_dir = await this.nextDirective(this.directives);
469
420
  this.process(next_dir);
470
421
  });
471
422
  }
472
423
  else if (directive_name === Directives.CLOSE) {
473
- // console.log("Exec close()")
474
424
  new DirClose(context).execute(directive, async () => {
475
425
  let next_dir = await this.nextDirective(this.directives);
476
426
  this.process(next_dir);
@@ -501,7 +451,6 @@ class DirectivesChatbotPlug {
501
451
  });
502
452
  }
503
453
  else if (directive_name === Directives.WAIT) {
504
- // console.log("........ DirWait");
505
454
  new DirWait(context).execute(directive, async () => {
506
455
  let next_dir = await this.nextDirective(this.directives);
507
456
  this.process(next_dir);
@@ -526,25 +475,21 @@ class DirectivesChatbotPlug {
526
475
  });
527
476
  }
528
477
  else if (directive_name === Directives.SEND_EMAIL) {
529
- // console.log("...DirSendEmail");
530
478
  new DirSendEmail(context).execute(directive, async () => {
531
479
  let next_dir = await this.nextDirective(this.directives);
532
480
  this.process(next_dir);
533
481
  });
534
482
  }
535
483
  else if (directive_name === Directives.WEB_REQUEST) {
536
- // console.log("...DirWebRequest");
537
484
  new DirWebRequest(context).execute(directive, async () => {
538
485
  let next_dir = await this.nextDirective(this.directives);
539
486
  this.process(next_dir);
540
487
  });
541
488
  }
542
489
  else if (directive_name === Directives.WEB_REQUEST_V2) {
543
- // console.log("...DirWebRequestV2");
544
490
  new DirWebRequestV2(context).execute(directive, async (stop) => {
545
- if (context.log) { console.log("stop on condition?", stop);}
546
491
  if (stop == true) {
547
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
492
+ winston.debug("(DirectivesChatbotPlug) DirWebRequestV2 Stopping Actions on: ", directive);
548
493
  this.theend();
549
494
  }
550
495
  else {
@@ -554,11 +499,9 @@ class DirectivesChatbotPlug {
554
499
  });
555
500
  }
556
501
  else if (directive_name === Directives.FORM) {
557
- console.log("...DirForm");
558
502
  new DirForm(context).execute(directive, async (stop) => {
559
- if (context.log) { console.log("stop on form?", stop);}
560
503
  if (stop == true) {
561
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
504
+ winston.debug("(DirectivesChatbotPlug) DirForm Stopping Actions on: ", directive);
562
505
  this.theend();
563
506
  }
564
507
  else {
@@ -568,21 +511,18 @@ class DirectivesChatbotPlug {
568
511
  });
569
512
  }
570
513
  else if (directive_name === Directives.CAPTURE_USER_REPLY) {
571
- // console.log("...DirCaptureUserReply");
572
514
  new DirCaptureUserReply(context).execute(directive, async () => {
573
515
  let next_dir = await this.nextDirective(this.directives);
574
516
  this.process(next_dir);
575
517
  });
576
518
  }
577
519
  else if (directive_name === Directives.CODE) {
578
- // console.log("...DirCode", directive);
579
520
  new DirCode(context).execute(directive, async () => {
580
521
  let next_dir = await this.nextDirective(this.directives);
581
522
  this.process(next_dir);
582
523
  });
583
524
  }
584
525
  else if (directive_name === Directives.DELETE) {
585
- // console.log("got delete dir...")
586
526
  new DirDeleteVariable(context).execute(directive, async () => {
587
527
  let next_dir = await this.nextDirective(this.directives);
588
528
  this.process(next_dir);
@@ -590,9 +530,8 @@ class DirectivesChatbotPlug {
590
530
  }
591
531
  else if (directive_name === Directives.ASK_HELP_CENTER) {
592
532
  new DirDeflectToHelpCenter(context).execute(directive, async (stop) => {
593
- if (context.log) { console.log("DeflectToHelpCenter stop?", stop);}
594
533
  if (stop == true) {
595
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
534
+ winston.debug("(DirectivesChatbotPlug) DirDeflectToHelpCenter Stopping Actions on: ", directive);
596
535
  this.theend();
597
536
  }
598
537
  else {
@@ -603,9 +542,8 @@ class DirectivesChatbotPlug {
603
542
  }
604
543
  else if (directive_name === Directives.ASK_GPT) {
605
544
  new DirAskGPT(context).execute(directive, async (stop) => {;
606
- if (context.log) { console.log("AskGPT stop?", stop);}
607
545
  if (stop == true) {
608
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
546
+ winston.debug("(DirectivesChatbotPlug) DirAskGPT Stopping Actions on: ", directive);
609
547
  this.theend();
610
548
  }
611
549
  else {
@@ -616,9 +554,8 @@ class DirectivesChatbotPlug {
616
554
  }
617
555
  else if (directive_name === Directives.ASK_GPT_V2) {
618
556
  new DirAskGPTV2(context).execute(directive, async (stop) => {;
619
- if (context.log) { console.log("AskGPTV2 stop?", stop);}
620
557
  if (stop == true) {
621
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
558
+ winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
622
559
  this.theend();
623
560
  }
624
561
  else {
@@ -629,9 +566,8 @@ class DirectivesChatbotPlug {
629
566
  }
630
567
  else if (directive_name === Directives.GPT_TASK) {
631
568
  new DirGptTask(context).execute(directive, async (stop) => {
632
- if (context.log) { console.log("GPTTask stop?", stop);}
633
569
  if (stop == true) {
634
- if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
570
+ winston.debug("(DirectivesChatbotPlug) DirGptTask Stopping Actions on: ", directive);
635
571
  this.theend();
636
572
  }
637
573
  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,17 +684,27 @@ 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) {
695
+ winston.debug("(DirectivesChatbotPlug) DirAddTags Stopping Actions on: ", directive);
696
+ this.theend();
697
+ }
698
+ else {
699
+ let next_dir = await this.nextDirective(this.directives);
700
+ this.process(next_dir);
701
+ }
702
+ });
703
+ }
704
+ else if (directive_name === Directives.WEBHOOK) {
705
+ // console.log(".....DirIntent")
706
+ new DirIntent(context).execute(directive, async (stop) => {
707
+ if (stop) {
768
708
  if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
769
709
  this.theend();
770
710
  }
@@ -781,7 +721,6 @@ class DirectivesChatbotPlug {
781
721
  });
782
722
  }
783
723
  else {
784
- //console.log("Unhandled Post-message Directive:", directive_name);
785
724
  let next_dir = await this.nextDirective(this.directives);
786
725
  this.process(next_dir);
787
726
  }
@@ -791,7 +730,7 @@ class DirectivesChatbotPlug {
791
730
  processInlineDirectives(pipeline, theend) {
792
731
  const directives = this.directives;
793
732
  if (!directives || directives.length === 0) {
794
- console.log("No directives to process.");
733
+ winston.verbose("(DirectivesChatbotPlug) No directives to process.");
795
734
  return;
796
735
  }
797
736
  const supportRequest = this.supportRequest;
@@ -811,10 +750,10 @@ class DirectivesChatbotPlug {
811
750
  log: false
812
751
  });
813
752
  let i = -1;
814
- if (this.log) { console.log("processing Inline directives:", directives); }
753
+ winston.debug("(DirectivesChatbotPlug) processing Inline directives: ", directives);
815
754
  const process = (directive) => {
816
755
  if (directive) {
817
- if (this.log) {console.log("__directive.name:", directive.name);}
756
+ winston.debug("(DirectivesChatbotPlug) __directive.name: " + directive.name);
818
757
  }
819
758
  let directive_name = null;
820
759
  if (directive && directive.name) {
@@ -823,18 +762,6 @@ class DirectivesChatbotPlug {
823
762
  if (directive == null) {
824
763
  theend();
825
764
  }
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
765
  else if (directive_name === Directives.DEFLECT_TO_HELP_CENTER) {
839
766
  const helpDir = new DirDeflectToHelpCenter({HELP_CENTER_API_ENDPOINT: this.HELP_CENTER_API_ENDPOINT, projectId: projectId});
840
767
  helpDir.execute(directive, pipeline, 3, () => {