@tiledesk/tiledesk-tybot-connector 2.0.8-rc1 → 2.0.8-rc3
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/ExtApi.js +1 -8
- package/ExtUtil.js +5 -6
- package/engine/IntentForm.js +0 -1
- package/engine/IntentsMachineFactory.js +4 -4
- package/engine/MongodbBotsDataSource.js +0 -1
- package/engine/MongodbIntentsMachine.js +0 -1
- package/engine/TiledeskChatbot.js +11 -16
- package/engine/TiledeskIntentsMachine.js +1 -2
- package/index.js +19 -25
- package/logs/app.log +9295 -20243
- package/logs/app2.log +46280 -0
- package/logs/app3.log +31686 -0
- package/logs/app4.log +46163 -0
- package/logs/app5.log +39983 -0
- package/logs/app6.log +5964 -0
- package/package.json +1 -1
- package/services/AIService.js +1 -1
- package/services/IntegrationService.js +1 -1
- package/services/TilebotService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +4 -10
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +1 -2
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +7 -9
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfNotOpenHours.js +3 -10
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfOpenHours.js +2 -9
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAssign.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +4 -6
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirCode.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +2 -5
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirForm.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +36 -55
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +8 -12
- package/tiledeskChatbotPlugs/directives/DirIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +0 -3
- package/tiledeskChatbotPlugs/directives/DirQapla.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReply.js +2 -5
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -13
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWait.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +6 -2
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +0 -1
- package/utils/TiledeskChatbotUtil.js +16 -30
- package/logs/app1.log +0 -11065
|
@@ -20,7 +20,6 @@ class DirReplyV2 {
|
|
|
20
20
|
this.requestId = context.requestId;
|
|
21
21
|
this.token = context.token;
|
|
22
22
|
this.tdcache = context.tdcache;
|
|
23
|
-
this.log = context.log;
|
|
24
23
|
this.intentDir = new DirIntent(context);
|
|
25
24
|
this.chatbot = context.chatbot;
|
|
26
25
|
this.reply = context.reply;
|
|
@@ -31,8 +30,7 @@ class DirReplyV2 {
|
|
|
31
30
|
projectId: this.context.projectId,
|
|
32
31
|
token: this.context.token,
|
|
33
32
|
APIURL: this.API_ENDPOINT,
|
|
34
|
-
APIKEY: "___"
|
|
35
|
-
log: this.log
|
|
33
|
+
APIKEY: "___"
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -61,11 +59,10 @@ class DirReplyV2 {
|
|
|
61
59
|
const message = action;
|
|
62
60
|
|
|
63
61
|
let current; // debug only
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
current = message.attributes.commands[1].message.text
|
|
67
|
-
}
|
|
62
|
+
if (message.attributes.commands[1].message.text) {
|
|
63
|
+
current = message.attributes.commands[1].message.text
|
|
68
64
|
}
|
|
65
|
+
|
|
69
66
|
let must_stop = false;
|
|
70
67
|
// fill
|
|
71
68
|
let requestAttributes = null;
|
|
@@ -74,11 +71,9 @@ class DirReplyV2 {
|
|
|
74
71
|
await TiledeskChatbot.allParametersStatic(
|
|
75
72
|
this.tdcache, this.requestId
|
|
76
73
|
);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
74
|
+
// for (const [key, value] of Object.entries(requestAttributes)) {
|
|
75
|
+
// const value_type = typeof value;
|
|
76
|
+
// }
|
|
82
77
|
|
|
83
78
|
TiledeskChatbotUtil.replaceJSONButtons(message, requestAttributes);
|
|
84
79
|
|
|
@@ -197,7 +192,7 @@ class DirReplyV2 {
|
|
|
197
192
|
let command = commands[i];
|
|
198
193
|
if (command.type === 'message' && command.message && command.message.text) {
|
|
199
194
|
command.message.text = filler.fill(command.message.text, requestAttributes);
|
|
200
|
-
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes
|
|
195
|
+
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes);
|
|
201
196
|
}
|
|
202
197
|
}
|
|
203
198
|
}
|
|
@@ -15,15 +15,13 @@ class DirSendEmail {
|
|
|
15
15
|
this.context = context;
|
|
16
16
|
this.tdcache = context.tdcache;
|
|
17
17
|
this.requestId = context.requestId;
|
|
18
|
-
this.log = context.log;
|
|
19
18
|
|
|
20
19
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
21
20
|
this.tdClient = new TiledeskClient({
|
|
22
21
|
projectId: this.context.projectId,
|
|
23
22
|
token: this.context.token,
|
|
24
23
|
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___"
|
|
26
|
-
log: this.log
|
|
24
|
+
APIKEY: "___"
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -79,7 +79,6 @@ class DirSetAttributeV2 {
|
|
|
79
79
|
}
|
|
80
80
|
this.context = context;
|
|
81
81
|
this.tdcache = context.tdcache;
|
|
82
|
-
this.log = context.log;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
execute(directive, callback) {
|
|
@@ -199,9 +198,7 @@ class DirSetAttributeV2 {
|
|
|
199
198
|
httpUtils.request(
|
|
200
199
|
HTTPREQUEST, async (err, resbody) => {
|
|
201
200
|
if (err) {
|
|
202
|
-
|
|
203
|
-
winston.error("(DirSetAttributeV2) persistOnTiledesk() error: ", err);
|
|
204
|
-
}
|
|
201
|
+
winston.error("(DirSetAttributeV2) persistOnTiledesk() error: ", err);
|
|
205
202
|
} else {
|
|
206
203
|
winston.debug("(DirSetAttributeV2) Attributes saved: ", resbody);
|
|
207
204
|
}
|
|
@@ -9,7 +9,6 @@ class DirSetConversationTags {
|
|
|
9
9
|
throw new Error('context object is mandatory.');
|
|
10
10
|
}
|
|
11
11
|
this.context = context;
|
|
12
|
-
this.log = context.log;
|
|
13
12
|
this.requestId = context.requestId;
|
|
14
13
|
|
|
15
14
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
@@ -17,8 +16,7 @@ class DirSetConversationTags {
|
|
|
17
16
|
projectId: this.context.projectId,
|
|
18
17
|
token: this.context.token,
|
|
19
18
|
APIURL: this.API_ENDPOINT,
|
|
20
|
-
APIKEY: "___"
|
|
21
|
-
log: this.log
|
|
19
|
+
APIKEY: "___"
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -16,7 +16,6 @@ class DirWebRequestV2 {
|
|
|
16
16
|
this.requestId = context.requestId;
|
|
17
17
|
this.chatbot = context.chatbot;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.log = context.log;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
execute(directive, callback) {
|
|
@@ -302,21 +301,7 @@ class DirWebRequestV2 {
|
|
|
302
301
|
}
|
|
303
302
|
})
|
|
304
303
|
.catch((err) => {
|
|
305
|
-
|
|
306
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - START
|
|
307
|
-
let cache = [];
|
|
308
|
-
let error_log = JSON.stringify(err, function (key, value) { // try to use a separate function
|
|
309
|
-
if (typeof value === 'object' && value != null) {
|
|
310
|
-
if (cache.indexOf(value) !== -1) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
cache.push(value);
|
|
314
|
-
}
|
|
315
|
-
return value;
|
|
316
|
-
});
|
|
317
|
-
winston.error("(DirWebRequestv2) An error occurred: ", error_log);
|
|
318
|
-
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END
|
|
319
|
-
}
|
|
304
|
+
// FIX THE STRINGIFY OF CIRCULAR STRUCTURE BUG - END
|
|
320
305
|
if (callback) {
|
|
321
306
|
let status = 1000;
|
|
322
307
|
let cache = [];
|
|
@@ -3,6 +3,7 @@ const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
|
3
3
|
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
5
|
let axios = require('axios');
|
|
6
|
+
const { Logger } = require('../../Logger');
|
|
6
7
|
|
|
7
8
|
class DirWebResponse {
|
|
8
9
|
|
|
@@ -15,7 +16,7 @@ class DirWebResponse {
|
|
|
15
16
|
this.requestId = context.requestId;
|
|
16
17
|
this.token = context.token;
|
|
17
18
|
this.tdcache = context.tdcache;
|
|
18
|
-
this.
|
|
19
|
+
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft });
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
execute(directive, callback) {
|
|
@@ -29,8 +30,9 @@ class DirWebResponse {
|
|
|
29
30
|
callback();
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
33
|
+
this.logger.info("Executing WebResponse action ", directive.action)
|
|
32
34
|
this.go(action, () => {
|
|
33
|
-
|
|
35
|
+
this.logger.info("WebResponse action terminated")
|
|
34
36
|
callback();
|
|
35
37
|
});
|
|
36
38
|
}
|
|
@@ -59,6 +61,8 @@ class DirWebResponse {
|
|
|
59
61
|
payload: json
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
this.logger.debug("WebResponse payload: ", webResponse);
|
|
65
|
+
|
|
62
66
|
const topic = `/webhooks/${this.requestId}`;
|
|
63
67
|
|
|
64
68
|
try {
|
|
@@ -252,24 +252,24 @@ class TiledeskChatbotUtil {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
static fillCommandAttachments(command, variables
|
|
256
|
-
|
|
255
|
+
static fillCommandAttachments(command, variables) {
|
|
256
|
+
winston.debug("(TiledeskChatbotUtils) Filling command button: ", command)
|
|
257
257
|
if (command.message && command.message.attributes && command.message.attributes.attachment && command.message.attributes.attachment.buttons && command.message.attributes.attachment.buttons.length > 0) {
|
|
258
258
|
let buttons = command.message.attributes.attachment.buttons;
|
|
259
259
|
const filler = new Filler();
|
|
260
260
|
buttons.forEach(button => {
|
|
261
261
|
if (button.link) {
|
|
262
262
|
button.link = filler.fill(button.link, variables);
|
|
263
|
-
|
|
263
|
+
winston.debug("(TiledeskChatbotUtils) button.link filled: " + button.link)
|
|
264
264
|
}
|
|
265
265
|
if (button.value) {
|
|
266
266
|
button.value = filler.fill(button.value, variables);
|
|
267
|
-
|
|
267
|
+
winston.debug("(TiledeskChatbotUtils) button.value filled: " + button.value)
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
else {
|
|
272
|
-
|
|
272
|
+
winston.debug("(TiledeskChatbotUtils) No attachments to fill in command")
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
|
|
@@ -496,7 +496,7 @@ class TiledeskChatbotUtil {
|
|
|
496
496
|
static async updateRequestAttributes(chatbot, chatbotToken, message, projectId, requestId) {
|
|
497
497
|
// update request context
|
|
498
498
|
try {
|
|
499
|
-
|
|
499
|
+
winston.debug("Updating request variables. Message:", message);
|
|
500
500
|
const messageId = message._id;
|
|
501
501
|
const chat_url = `https://panel.tiledesk.com/v3/dashboard/#/project/${projectId}/wsrequest/${requestId}/messages`
|
|
502
502
|
|
|
@@ -567,12 +567,12 @@ class TiledeskChatbotUtil {
|
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
if (message && message.request && message.request.lead) {
|
|
570
|
-
|
|
570
|
+
winston.debug("(TiledeskChatbotUtil) Lead found with email: " + message.request.lead.email + " and lead.fullname " + message.request.lead.fullname);
|
|
571
571
|
let currentLeadEmail = await chatbot.getParameter(TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY);
|
|
572
|
-
|
|
572
|
+
winston.debug("(TiledeskChatbotUtil) You lead email from attributes: " + currentLeadEmail);
|
|
573
573
|
if (message.request.lead.email && !currentLeadEmail) {
|
|
574
574
|
// worth saving
|
|
575
|
-
|
|
575
|
+
winston.debug("(TiledeskChatbotUtil) worth saving email");
|
|
576
576
|
try {
|
|
577
577
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY, message.request.lead.email);
|
|
578
578
|
}
|
|
@@ -581,10 +581,10 @@ class TiledeskChatbotUtil {
|
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
let currentLeadName = await chatbot.getParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY);
|
|
584
|
-
|
|
584
|
+
winston.debug("(TiledeskChatbotUtil) You lead email from attributes: " + currentLeadEmail);
|
|
585
585
|
if (message.request.lead.fullname && !currentLeadName) {
|
|
586
586
|
// worth saving
|
|
587
|
-
|
|
587
|
+
winston.debug("(TiledeskChatbotUtil) worth saving email");
|
|
588
588
|
try {
|
|
589
589
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY, message.request.lead.fullname);
|
|
590
590
|
}
|
|
@@ -661,10 +661,10 @@ class TiledeskChatbotUtil {
|
|
|
661
661
|
message.attributes = {}
|
|
662
662
|
}
|
|
663
663
|
message.attributes.payload = { ...message.attributes.payload, ...message.request.attributes.payload }
|
|
664
|
-
|
|
664
|
+
winston.debug("(TiledeskChatbotUtil) Forced Set message.attributes.payload ", message.attributes.payload);
|
|
665
665
|
}
|
|
666
666
|
if (message.attributes) {
|
|
667
|
-
|
|
667
|
+
winston.debug("(TiledeskChatbotUtil) Ok message.attributes ", message.attributes);
|
|
668
668
|
|
|
669
669
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_END_USER_ID_KEY, message.attributes.requester_id);
|
|
670
670
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_END_USER_IP_ADDRESS_KEY, message.attributes.ipAddress);
|
|
@@ -698,12 +698,12 @@ class TiledeskChatbotUtil {
|
|
|
698
698
|
|
|
699
699
|
|
|
700
700
|
const _bot = chatbot.bot; // aka FaqKB
|
|
701
|
-
|
|
701
|
+
winston.debug("(TiledeskChatbotUtil) Adding Globals to context: ", _bot);
|
|
702
702
|
|
|
703
703
|
if (_bot.attributes && _bot.attributes.globals) {
|
|
704
|
-
|
|
704
|
+
winston.error("(TiledeskChatbotUtil) Got Globals: ", _bot.attributes.globals);
|
|
705
705
|
_bot.attributes.globals.forEach(async (global_var) => {
|
|
706
|
-
|
|
706
|
+
winston.error("(TiledeskChatbotUtil) Adding global: " + global_var.key + " value: " + global_var.value);
|
|
707
707
|
await chatbot.addParameter(global_var.key, global_var.value);
|
|
708
708
|
});
|
|
709
709
|
}
|
|
@@ -716,20 +716,6 @@ class TiledeskChatbotUtil {
|
|
|
716
716
|
// }
|
|
717
717
|
// );
|
|
718
718
|
|
|
719
|
-
if (chatbot.log) {
|
|
720
|
-
if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) requestId: " + requestId); }
|
|
721
|
-
if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) Key: " + TiledeskChatbotConst.REQ_PROJECT_ID_KEY); }
|
|
722
|
-
|
|
723
|
-
let proj_ = await chatbot.getParameter(TiledeskChatbotConst.REQ_PROJECT_ID_KEY);
|
|
724
|
-
if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) request parameter proj_: " + proj_); }
|
|
725
|
-
|
|
726
|
-
const all_parameters = await chatbot.allParameters();
|
|
727
|
-
for (const [key, value] of Object.entries(all_parameters)) {
|
|
728
|
-
const value_type = typeof value;
|
|
729
|
-
if (chatbot.log) { winston.debug("(TiledeskChatbotUtil) Request Attribute: " + key + " value: " + value + " type: " + value_type); }
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
719
|
} catch(error) {
|
|
734
720
|
winston.error("(TiledeskChatbotUtil) updateRequestAttributes Error: ", error);
|
|
735
721
|
process.exit(1)
|