@tiledesk/tiledesk-tybot-connector 2.0.38 → 2.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/engine/TiledeskChatbot.js +60 -3
- package/engine/mock/MockBotsDataSource.js +1 -1
- package/index.js +154 -3
- package/logs/app.log +110 -0
- package/package.json +1 -1
- package/services/TilebotService.js +36 -0
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +100 -519
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAiCondition.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirCode.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirCondition.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIntent.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirQapla.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReply.js +10 -2
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWait.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -1
- package/utils/TiledeskChatbotUtil.js +131 -141
package/package.json
CHANGED
|
@@ -41,6 +41,42 @@ class TilebotService {
|
|
|
41
41
|
}, false
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A stub to send message to the "ext/botId" endpoint, hosted by tilebot on:
|
|
47
|
+
* /${TILEBOT_ROUTE}/ext/${botId}
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} message. The message to send
|
|
50
|
+
* @param {string} botId. Tiledesk botId
|
|
51
|
+
* @param {string} token. User token
|
|
52
|
+
*/
|
|
53
|
+
executeBlock(message, botId, callback) {
|
|
54
|
+
const url = `${TILEBOT_ENDPOINT}/exec/${botId}`;
|
|
55
|
+
winston.verbose("sendMessageToBot URL" + url);
|
|
56
|
+
const HTTPREQUEST = {
|
|
57
|
+
url: url,
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': 'application/json'
|
|
60
|
+
},
|
|
61
|
+
json: message,
|
|
62
|
+
method: 'POST'
|
|
63
|
+
};
|
|
64
|
+
httpUtils.request(
|
|
65
|
+
HTTPREQUEST,
|
|
66
|
+
function (err, resbody) {
|
|
67
|
+
if (err) {
|
|
68
|
+
if (callback) {
|
|
69
|
+
callback(err);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (callback) {
|
|
74
|
+
callback(null, resbody);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, false
|
|
78
|
+
);
|
|
79
|
+
}
|
|
44
80
|
}
|
|
45
81
|
|
|
46
82
|
let tilebotService = new TilebotService();
|
|
@@ -211,528 +211,109 @@ class DirectivesChatbotPlug {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
async process(directive) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
directive_name = directive.name.toLowerCase();
|
|
221
|
-
}
|
|
222
|
-
if (directive && directive.action) {
|
|
223
|
-
const action_id = directive.action["_tdActionId"];
|
|
224
|
-
const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
|
|
225
|
-
if ( locked_action_id && (locked_action_id !== action_id) ) {
|
|
226
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
227
|
-
this.process(next_dir);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
if (directive == null || (directive !== null && directive["name"] === undefined)) {
|
|
233
|
-
winston.debug("(DirectivesChatbotPlug) stop process(). directive is (null?): ", directive);
|
|
234
|
-
this.theend();
|
|
235
|
-
}
|
|
236
|
-
else if (directive_name === Directives.DEPARTMENT) {
|
|
237
|
-
new DirDepartment(context).execute(directive, async () => {
|
|
238
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
239
|
-
this.process(next_dir);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
else if (directive_name === Directives.HMESSAGE) {
|
|
243
|
-
new DirMessage(context).execute(directive, async () => {
|
|
244
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
245
|
-
this.process(next_dir);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
else if (directive_name === Directives.INTENT) {
|
|
249
|
-
new DirIntent(context).execute(directive, async (stop) => {
|
|
250
|
-
if (stop) {
|
|
251
|
-
winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
|
|
252
|
-
this.theend();
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
256
|
-
this.process(next_dir);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else if (directive_name === Directives.MESSAGE) {
|
|
261
|
-
new DirMessage(context).execute(directive, async (stop) => {
|
|
262
|
-
if (stop) {
|
|
263
|
-
winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
|
|
264
|
-
this.theend();
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
268
|
-
this.process(next_dir);
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
else if (directive_name === Directives.REPLY) {
|
|
273
|
-
new DirReply(context).execute(directive, async () => {
|
|
274
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
275
|
-
this.process(next_dir);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
else if (directive_name === Directives.REPLY_V2) {
|
|
279
|
-
new DirReplyV2(context).execute(directive, async (stop) => {
|
|
280
|
-
if (stop) {
|
|
281
|
-
winston.debug("(DirectivesChatbotPlug) DirIntent Stopping Actions on: ", directive);
|
|
282
|
-
this.theend();
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
286
|
-
this.process(next_dir);
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
else if (directive_name === Directives.DTMF_FORM) {
|
|
291
|
-
new DirReply(context).execute(directive, async () => {
|
|
292
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
293
|
-
this.process(next_dir);
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
else if (directive_name === Directives.DTMF_MENU) {
|
|
297
|
-
new DirReply(context).execute(directive, async () => {
|
|
298
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
299
|
-
this.process(next_dir);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
else if (directive_name === Directives.BLIND_TRANSFER) {
|
|
303
|
-
new DirReply(context).execute(directive, async () => {
|
|
304
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
305
|
-
this.process(next_dir);
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
else if (directive_name === Directives.SPEECH_FORM) {
|
|
309
|
-
new DirReply(context).execute(directive, async () => {
|
|
310
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
311
|
-
this.process(next_dir);
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
else if (directive_name === Directives.PLAY_PROMPT) {
|
|
315
|
-
new DirReply(context).execute(directive, async () => {
|
|
316
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
317
|
-
this.process(next_dir);
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
else if (directive_name === Directives.AUDIO_RECORD) {
|
|
321
|
-
new DirReply(context).execute(directive, async () => {
|
|
322
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
323
|
-
this.process(next_dir);
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
else if (directive_name === Directives.RANDOM_REPLY) {
|
|
327
|
-
new DirRandomReply(context).execute(directive, async () => {
|
|
328
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
329
|
-
this.process(next_dir);
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
else if (directive_name === Directives.IF_OPEN_HOURS) {
|
|
333
|
-
new DirIfOpenHours(context).execute(directive, async (stop) => {
|
|
334
|
-
if (stop) {
|
|
335
|
-
winston.debug("(DirectivesChatbotPlug) DirIfOpenHours Stopping Actions on: ", directive);
|
|
336
|
-
this.theend();
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
340
|
-
this.process(next_dir);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
else if (directive_name === Directives.IF_ONLINE_AGENTS) {
|
|
345
|
-
new DirIfOnlineAgents(context).execute(directive, async (stop) => {
|
|
346
|
-
if (stop) {
|
|
347
|
-
winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgents Stopping Actions on: ", directive);
|
|
348
|
-
this.theend();
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
352
|
-
this.process(next_dir);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
else if (directive_name === Directives.IF_ONLINE_AGENTS_V2) {
|
|
357
|
-
new DirIfOnlineAgentsV2(context).execute(directive, async (stop) => {
|
|
358
|
-
if (stop) {
|
|
359
|
-
winston.debug("(DirectivesChatbotPlug) DirIfOnlineAgentsV2 Stopping Actions on: ", directive);
|
|
360
|
-
this.theend();
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
364
|
-
this.process(next_dir);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
else if (directive_name === Directives.FUNCTION_VALUE) {
|
|
369
|
-
new DirAssignFromFunction(context).execute(directive, async () => {
|
|
370
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
371
|
-
this.process(next_dir);
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
else if (directive_name === Directives.CONDITION) { // DEPRECATED
|
|
375
|
-
new DirCondition(context).execute(directive, async (stop) => {
|
|
376
|
-
if (stop == true) {
|
|
377
|
-
winston.debug("(DirectivesChatbotPlug) DirCondition Stopping Actions on: ", directive);
|
|
378
|
-
this.theend();
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
382
|
-
this.process(next_dir);
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
else if (directive_name === Directives.JSON_CONDITION) {
|
|
387
|
-
new DirJSONCondition(context).execute(directive, async (stop) => {
|
|
388
|
-
if (stop == true) {
|
|
389
|
-
winston.debug("(DirectivesChatbotPlug) DirJSONCondition Stopping Actions on: ", directive);
|
|
390
|
-
this.theend();
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
394
|
-
this.process(next_dir);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
else if (directive_name === Directives.ASSIGN) {
|
|
399
|
-
new DirAssign(context).execute(directive, async () => {
|
|
400
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
401
|
-
this.process(next_dir);
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
else if (directive_name === Directives.SET_ATTRIBUTE) {
|
|
405
|
-
new DirSetAttribute(context).execute(directive, async () => {
|
|
406
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
407
|
-
this.process(next_dir);
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
else if (directive_name === Directives.SET_ATTRIBUTE_V2) {
|
|
411
|
-
new DirSetAttributeV2(context).execute(directive, async () => {
|
|
412
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
413
|
-
this.process(next_dir);
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
else if (directive_name === Directives.AGENT) {
|
|
417
|
-
new DirMoveToAgent(context).execute(directive, async () => {
|
|
418
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
419
|
-
this.process(next_dir);
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
else if (directive_name === Directives.CLOSE) {
|
|
423
|
-
new DirClose(context).execute(directive, async () => {
|
|
424
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
425
|
-
this.process(next_dir);
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
else if (directive_name === Directives.REMOVE_CURRENT_BOT) {
|
|
429
|
-
new DirRemoveCurrentBot(context).execute(directive, async () => {
|
|
430
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
431
|
-
this.process(next_dir);
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
else if (directive_name === Directives.REPLACE_BOT) {
|
|
435
|
-
new DirReplaceBot(context).execute(directive, async () => {
|
|
436
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
437
|
-
this.process(next_dir);
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
else if (directive_name === Directives.REPLACE_BOT_V2) {
|
|
441
|
-
new DirReplaceBotV2(context).execute(directive, async () => {
|
|
442
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
443
|
-
this.process(next_dir);
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
else if (directive_name === Directives.REPLACE_BOT_V3) {
|
|
447
|
-
new DirReplaceBotV3(context).execute(directive, async () => {
|
|
448
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
449
|
-
this.process(next_dir);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
else if (directive_name === Directives.WAIT) {
|
|
453
|
-
new DirWait(context).execute(directive, async () => {
|
|
454
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
455
|
-
this.process(next_dir);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
else if (directive_name === Directives.LOCK_INTENT) {
|
|
459
|
-
new DirLockIntent(context).execute(directive, async () => {
|
|
460
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
461
|
-
this.process(next_dir);
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
else if (directive_name === Directives.UNLOCK_INTENT) {
|
|
465
|
-
new DirUnlockIntent(context).execute(directive, async () => {
|
|
466
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
467
|
-
this.process(next_dir);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
else if (directive_name === Directives.FIRE_TILEDESK_EVENT) {
|
|
471
|
-
new DirFireTiledeskEvent(context).execute(directive, async () => {
|
|
472
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
473
|
-
this.process(next_dir);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
else if (directive_name === Directives.SEND_EMAIL) {
|
|
477
|
-
new DirSendEmail(context).execute(directive, async () => {
|
|
478
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
479
|
-
this.process(next_dir);
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
else if (directive_name === Directives.WEB_REQUEST) {
|
|
483
|
-
new DirWebRequest(context).execute(directive, async () => {
|
|
484
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
485
|
-
this.process(next_dir);
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
else if (directive_name === Directives.WEB_REQUEST_V2) {
|
|
489
|
-
new DirWebRequestV2(context).execute(directive, async (stop) => {
|
|
490
|
-
if (stop == true) {
|
|
491
|
-
winston.debug("(DirectivesChatbotPlug) DirWebRequestV2 Stopping Actions on: ", directive);
|
|
492
|
-
this.theend();
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
496
|
-
this.process(next_dir);
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
else if (directive_name === Directives.FORM) {
|
|
501
|
-
new DirForm(context).execute(directive, async (stop) => {
|
|
502
|
-
if (stop == true) {
|
|
503
|
-
winston.debug("(DirectivesChatbotPlug) DirForm Stopping Actions on: ", directive);
|
|
504
|
-
this.theend();
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
508
|
-
this.process(next_dir);
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
else if (directive_name === Directives.CAPTURE_USER_REPLY) {
|
|
513
|
-
new DirCaptureUserReply(context).execute(directive, async () => {
|
|
514
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
515
|
-
this.process(next_dir);
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
else if (directive_name === Directives.CODE) {
|
|
519
|
-
new DirCode(context).execute(directive, async () => {
|
|
520
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
521
|
-
this.process(next_dir);
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
else if (directive_name === Directives.DELETE) {
|
|
525
|
-
new DirDeleteVariable(context).execute(directive, async () => {
|
|
526
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
527
|
-
this.process(next_dir);
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
else if (directive_name === Directives.ASK_HELP_CENTER) {
|
|
531
|
-
new DirDeflectToHelpCenter(context).execute(directive, async (stop) => {
|
|
532
|
-
if (stop == true) {
|
|
533
|
-
winston.debug("(DirectivesChatbotPlug) DirDeflectToHelpCenter Stopping Actions on: ", directive);
|
|
534
|
-
this.theend();
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
538
|
-
this.process(next_dir);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
else if (directive_name === Directives.ASK_GPT) {
|
|
543
|
-
new DirAskGPT(context).execute(directive, async (stop) => {;
|
|
544
|
-
if (stop == true) {
|
|
545
|
-
winston.debug("(DirectivesChatbotPlug) DirAskGPT Stopping Actions on: ", directive);
|
|
546
|
-
this.theend();
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
550
|
-
this.process(next_dir);
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
else if (directive_name === Directives.ASK_GPT_V2) {
|
|
555
|
-
new DirAskGPTV2(context).execute(directive, async (stop) => {;
|
|
556
|
-
if (stop == true) {
|
|
557
|
-
winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
|
|
558
|
-
this.theend();
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
562
|
-
this.process(next_dir);
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
else if (directive_name === Directives.ADD_KB_CONTENT) {
|
|
567
|
-
new DirAddKbContent(context).execute(directive, async () => {
|
|
568
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
569
|
-
this.process(next_dir);
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
else if (directive_name === Directives.GPT_TASK) {
|
|
573
|
-
new DirGptTask(context).execute(directive, async (stop) => {
|
|
574
|
-
if (stop == true) {
|
|
575
|
-
winston.debug("(DirectivesChatbotPlug) DirGptTask Stopping Actions on: ", directive);
|
|
576
|
-
this.theend();
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
580
|
-
this.process(next_dir);
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
else if (directive_name === Directives.AI_PROMPT) {
|
|
585
|
-
new DirAiPrompt(context).execute(directive, async (stop) => {
|
|
586
|
-
if (stop == true) {
|
|
587
|
-
winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
|
|
588
|
-
this.theend();
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
592
|
-
this.process(next_dir);
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
else if (directive_name === Directives.AI_CONDITION) {
|
|
597
|
-
new DirAiCondition(context).execute(directive, async (stop) => {
|
|
598
|
-
if (stop == true) {
|
|
599
|
-
winston.debug("(DirectivesChatbotPlug) DirAskGPTV2 Stopping Actions on: ", directive);
|
|
600
|
-
this.theend();
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
604
|
-
this.process(next_dir);
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
else if (directive_name === Directives.WHATSAPP_ATTRIBUTE) {
|
|
609
|
-
new DirWhatsappByAttribute(context).execute(directive, async (stop) => {
|
|
610
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
611
|
-
this.process(next_dir);
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
else if (directive_name === Directives.SEND_WHATSAPP) {
|
|
615
|
-
new DirSendWhatsapp(context).execute(directive, async (stop) => {
|
|
616
|
-
if (stop == true) {
|
|
617
|
-
winston.debug("(DirectivesChatbotPlug) DirSendWhatsapp Stopping Actions on: ", directive);
|
|
618
|
-
this.theend();
|
|
619
|
-
} else {
|
|
620
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
621
|
-
this.process(next_dir);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
else if (directive_name === Directives.QAPLA) {
|
|
626
|
-
new DirQapla(context).execute(directive, async (stop) => {
|
|
627
|
-
if (stop == true) {
|
|
628
|
-
winston.debug("(DirectivesChatbotPlug) DirQapla Stopping Actions on: ", directive);
|
|
629
|
-
this.theend();
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
633
|
-
this.process(next_dir);
|
|
634
|
-
}
|
|
635
|
-
})
|
|
636
|
-
}
|
|
637
|
-
else if (directive_name === Directives.MAKE) {
|
|
638
|
-
new DirMake(context).execute(directive, async (stop) => {
|
|
639
|
-
if (stop == true) {
|
|
640
|
-
winston.debug("(DirectivesChatbotPlug) DirMake Stopping Actions on: ", directive);
|
|
641
|
-
this.theend();
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
645
|
-
this.process(next_dir);
|
|
646
|
-
}
|
|
647
|
-
})
|
|
648
|
-
}
|
|
649
|
-
else if (directive_name === Directives.HUBSPOT) {
|
|
650
|
-
new DirHubspot(context).execute(directive, async (stop) => {
|
|
651
|
-
if (stop == true) {
|
|
652
|
-
winston.debug("(DirectivesChatbotPlug) DirHubspot Stopping Actions on: ", directive);
|
|
653
|
-
this.theend();
|
|
654
|
-
} else {
|
|
655
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
656
|
-
this.process(next_dir);
|
|
657
|
-
}
|
|
658
|
-
})
|
|
659
|
-
}
|
|
660
|
-
else if (directive_name === Directives.CUSTOMERIO) {
|
|
661
|
-
new DirCustomerio(context).execute(directive, async () => {
|
|
662
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
663
|
-
this.process(next_dir);
|
|
664
|
-
})
|
|
665
|
-
}
|
|
666
|
-
else if (directive_name === Directives.BREVO) {
|
|
667
|
-
new DirBrevo(context).execute(directive, async () => {
|
|
668
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
669
|
-
this.process(next_dir);
|
|
670
|
-
})
|
|
671
|
-
}
|
|
672
|
-
else if (directive_name === Directives.GPT_ASSISTANT) {
|
|
673
|
-
new DirAssistant(context).execute(directive, async (stop) => {
|
|
674
|
-
if (stop == true) {
|
|
675
|
-
winston.debug("(DirectivesChatbotPlug) DirAssistant Stopping Actions on: ", directive);
|
|
676
|
-
this.theend();
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
680
|
-
this.process(next_dir);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
else if (directive_name === Directives.CONTACT_UPDATE) {
|
|
685
|
-
new DirContactUpdate(context).execute(directive, async () => {
|
|
686
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
687
|
-
this.process(next_dir);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
else if (directive_name === Directives.CLEAR_TRANSCRIPT) {
|
|
691
|
-
new DirClearTranscript(context).execute(directive, async () => {
|
|
692
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
693
|
-
this.process(next_dir);
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
else if (directive_name === Directives.MOVE_TO_UNASSIGNED) {
|
|
697
|
-
new DirMoveToUnassigned(context).execute(directive, async () => {
|
|
698
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
699
|
-
this.process(next_dir);
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
else if (directive_name === Directives.CONNECT_BLOCK) {
|
|
703
|
-
new DirConnectBlock(context).execute(directive, async () => {
|
|
704
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
705
|
-
this.process(next_dir);
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
else if (directive_name === Directives.ADD_TAGS) {
|
|
709
|
-
new DirAddTags(context).execute(directive, async (stop) => {
|
|
710
|
-
if (stop == true) {
|
|
711
|
-
winston.debug("(DirectivesChatbotPlug) DirAddTags Stopping Actions on: ", directive);
|
|
712
|
-
this.theend();
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
716
|
-
this.process(next_dir);
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
else if (directive_name === Directives.WEB_RESPONSE) {
|
|
721
|
-
new DirWebResponse(context).execute(directive, async () => {
|
|
722
|
-
let next_dir = await this.nextDirective(this.directives);
|
|
723
|
-
this.process(next_dir);
|
|
724
|
-
});
|
|
214
|
+
|
|
215
|
+
const context = this.context;
|
|
216
|
+
|
|
217
|
+
if (!directive || !directive.name) {
|
|
218
|
+
winston.debug("(DirectivesChatbotPlug) stop process(). directive is null", directive);
|
|
219
|
+
return this.theend();
|
|
725
220
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
221
|
+
|
|
222
|
+
const directive_name = directive.name.toLowerCase();
|
|
223
|
+
|
|
224
|
+
// Controllo lock action
|
|
225
|
+
if (directive.action) {
|
|
226
|
+
const action_id = directive.action["_tdActionId"];
|
|
227
|
+
const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
|
|
228
|
+
if (locked_action_id && locked_action_id !== action_id) {
|
|
229
|
+
const next_dir = await this.nextDirective(this.directives);
|
|
230
|
+
return this.process(next_dir);
|
|
231
|
+
}
|
|
731
232
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
233
|
+
|
|
234
|
+
// Mappa semplice directive_name -> classe
|
|
235
|
+
const handlers = {
|
|
236
|
+
[Directives.DEPARTMENT]: DirDepartment,
|
|
237
|
+
[Directives.HMESSAGE]: DirMessage,
|
|
238
|
+
[Directives.INTENT]: DirIntent,
|
|
239
|
+
[Directives.MESSAGE]: DirMessage,
|
|
240
|
+
[Directives.REPLY]: DirReply,
|
|
241
|
+
[Directives.REPLY_V2]: DirReplyV2,
|
|
242
|
+
[Directives.DTMF_FORM]: DirReply,
|
|
243
|
+
[Directives.DTMF_MENU]: DirReply,
|
|
244
|
+
[Directives.BLIND_TRANSFER]: DirReply,
|
|
245
|
+
[Directives.SPEECH_FORM]: DirReply,
|
|
246
|
+
[Directives.PLAY_PROMPT]: DirReply,
|
|
247
|
+
[Directives.AUDIO_RECORD]: DirReply,
|
|
248
|
+
[Directives.RANDOM_REPLY]: DirRandomReply,
|
|
249
|
+
[Directives.IF_OPEN_HOURS]: DirIfOpenHours,
|
|
250
|
+
[Directives.IF_ONLINE_AGENTS]: DirIfOnlineAgents,
|
|
251
|
+
[Directives.IF_ONLINE_AGENTS_V2]: DirIfOnlineAgentsV2,
|
|
252
|
+
[Directives.FUNCTION_VALUE]: DirAssignFromFunction,
|
|
253
|
+
[Directives.JSON_CONDITION]: DirJSONCondition,
|
|
254
|
+
[Directives.ASSIGN]: DirAssign,
|
|
255
|
+
[Directives.SET_ATTRIBUTE]: DirSetAttribute,
|
|
256
|
+
[Directives.SET_ATTRIBUTE_V2]: DirSetAttributeV2,
|
|
257
|
+
[Directives.AGENT]: DirMoveToAgent,
|
|
258
|
+
[Directives.CLOSE]: DirClose,
|
|
259
|
+
[Directives.REMOVE_CURRENT_BOT]: DirRemoveCurrentBot,
|
|
260
|
+
[Directives.REPLACE_BOT]: DirReplaceBot,
|
|
261
|
+
[Directives.REPLACE_BOT_V2]: DirReplaceBotV2,
|
|
262
|
+
[Directives.REPLACE_BOT_V3]: DirReplaceBotV3,
|
|
263
|
+
[Directives.WAIT]: DirWait,
|
|
264
|
+
[Directives.LOCK_INTENT]: DirLockIntent,
|
|
265
|
+
[Directives.UNLOCK_INTENT]: DirUnlockIntent,
|
|
266
|
+
[Directives.FIRE_TILEDESK_EVENT]: DirFireTiledeskEvent,
|
|
267
|
+
[Directives.SEND_EMAIL]: DirSendEmail,
|
|
268
|
+
[Directives.WEB_REQUEST]: DirWebRequest,
|
|
269
|
+
[Directives.WEB_REQUEST_V2]: DirWebRequestV2,
|
|
270
|
+
[Directives.FORM]: DirForm,
|
|
271
|
+
[Directives.CAPTURE_USER_REPLY]: DirCaptureUserReply,
|
|
272
|
+
[Directives.CODE]: DirCode,
|
|
273
|
+
[Directives.DELETE]: DirDeleteVariable,
|
|
274
|
+
[Directives.ASK_HELP_CENTER]: DirDeflectToHelpCenter,
|
|
275
|
+
[Directives.ASK_GPT]: DirAskGPT,
|
|
276
|
+
[Directives.ASK_GPT_V2]: DirAskGPTV2,
|
|
277
|
+
[Directives.ADD_KB_CONTENT]: DirAddKbContent,
|
|
278
|
+
[Directives.GPT_TASK]: DirGptTask,
|
|
279
|
+
[Directives.AI_PROMPT]: DirAiPrompt,
|
|
280
|
+
[Directives.AI_CONDITION]: DirAiCondition,
|
|
281
|
+
[Directives.WHATSAPP_ATTRIBUTE]: DirWhatsappByAttribute,
|
|
282
|
+
[Directives.SEND_WHATSAPP]: DirSendWhatsapp,
|
|
283
|
+
[Directives.QAPLA]: DirQapla,
|
|
284
|
+
[Directives.MAKE]: DirMake,
|
|
285
|
+
[Directives.HUBSPOT]: DirHubspot,
|
|
286
|
+
[Directives.CUSTOMERIO]: DirCustomerio,
|
|
287
|
+
[Directives.BREVO]: DirBrevo,
|
|
288
|
+
[Directives.GPT_ASSISTANT]: DirAssistant,
|
|
289
|
+
[Directives.CONTACT_UPDATE]: DirContactUpdate,
|
|
290
|
+
[Directives.CLEAR_TRANSCRIPT]: DirClearTranscript,
|
|
291
|
+
[Directives.MOVE_TO_UNASSIGNED]: DirMoveToUnassigned,
|
|
292
|
+
[Directives.CONNECT_BLOCK]: DirConnectBlock,
|
|
293
|
+
[Directives.ADD_TAGS]: DirAddTags,
|
|
294
|
+
[Directives.WEB_RESPONSE]: DirWebResponse,
|
|
295
|
+
[Directives.FLOW_LOG]: DirFlowLog
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const HandlerClass = handlers[directive_name];
|
|
299
|
+
if (!HandlerClass) {
|
|
300
|
+
const next_dir = await this.nextDirective(this.directives);
|
|
301
|
+
return this.process(next_dir);
|
|
735
302
|
}
|
|
303
|
+
|
|
304
|
+
const handler = new HandlerClass(context);
|
|
305
|
+
|
|
306
|
+
// Esegue l'handler e chiama next se non stop
|
|
307
|
+
|
|
308
|
+
handler.execute(directive, async (stop) => {
|
|
309
|
+
if (stop) {
|
|
310
|
+
winston.debug(`(DirectivesChatbotPlug) Stopping Actions on:`, directive);
|
|
311
|
+
return this.theend();
|
|
312
|
+
}
|
|
313
|
+
const next_dir = await this.nextDirective(this.directives);
|
|
314
|
+
let process_next_dir = await this.process(next_dir);
|
|
315
|
+
return process_next_dir;
|
|
316
|
+
});
|
|
736
317
|
}
|
|
737
318
|
|
|
738
319
|
// DEPRECATED
|
|
@@ -28,7 +28,7 @@ class DirAddKbContent {
|
|
|
28
28
|
this.log = context.log;
|
|
29
29
|
|
|
30
30
|
this.intentDir = new DirIntent(context);
|
|
31
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
31
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.intent_id || this.context.reply?.attributes?.intent_info?.intent_id });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
execute(directive, callback) {
|
|
@@ -25,7 +25,7 @@ class DirAddTags {
|
|
|
25
25
|
this.requestId = this.context.requestId;
|
|
26
26
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
27
27
|
|
|
28
|
-
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.attributes?.intent_info?.intent_id });
|
|
28
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest?.draft, intent_id: this.context.reply?.intent_id || this.context.reply?.attributes?.intent_info?.intent_id });
|
|
29
29
|
this.tdClient = new TiledeskClient({ projectId: this.context.projectId, token: this.context.token, APIURL: this.API_ENDPOINT, APIKEY: "___" });
|
|
30
30
|
}
|
|
31
31
|
|