@tiledesk/tiledesk-tybot-connector 2.0.10-rc9 → 2.0.11
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/CHANGELOG.md +2 -27
- package/ExtApi.js +8 -1
- package/ExtUtil.js +6 -5
- package/Logger.js +17 -26
- package/TdCache copy.js +242 -0
- package/engine/IntentForm.js +1 -0
- package/engine/IntentsMachineFactory.js +4 -4
- package/engine/MongodbBotsDataSource.js +1 -0
- package/engine/MongodbIntentsMachine.js +1 -0
- package/engine/TiledeskChatbot.js +16 -11
- package/engine/TiledeskIntentsMachine.js +2 -1
- package/engine/mock/MockBotsDataSource.js +2 -1
- package/index.js +25 -22
- package/logs/app.log +43056 -4268
- package/logs/app1.log +41129 -0
- package/logs/app2.log +14567 -45594
- package/logs/app6.log +29039 -0
- package/logs/app7.log +4726 -0
- package/package.json +2 -3
- package/services/AIService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +18 -38
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +2 -1
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +3 -1
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +3 -1
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +9 -7
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfNotOpenHours.js +10 -3
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfOpenHours.js +9 -2
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +4 -16
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +0 -16
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +4 -17
- package/tiledeskChatbotPlugs/directives/DirAssign.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirClose.js +2 -0
- package/tiledeskChatbotPlugs/directives/DirCode.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirCondition.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +5 -2
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirForm.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +55 -36
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +4 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +4 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +2 -0
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +12 -8
- package/tiledeskChatbotPlugs/directives/DirIntent.js +5 -6
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirMake.js +16 -1
- package/tiledeskChatbotPlugs/directives/DirMessage.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +4 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +3 -0
- package/tiledeskChatbotPlugs/directives/DirQapla.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +2 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirReply.js +18 -7
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +13 -8
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +4 -1
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +3 -1
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWait.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +19 -19
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +417 -0
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +40 -6
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -0
- package/tiledeskChatbotPlugs/directives/Directives.js +0 -3
- package/utils/TiledeskChatbotUtil.js +57 -19
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +0 -332
- package/tiledeskChatbotPlugs/directives/DirFlowLog.js +0 -88
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ let axios = require('axios');
|
|
|
18
18
|
router.use(bodyParser.json({limit: '50mb'}));
|
|
19
19
|
router.use(bodyParser.urlencoded({ extended: true , limit: '50mb'}));
|
|
20
20
|
|
|
21
|
+
let log = false;
|
|
21
22
|
/** @type {TdCache} */
|
|
22
23
|
let tdcache = null;
|
|
23
24
|
let MAX_STEPS = 1000;
|
|
@@ -86,7 +87,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
86
87
|
|
|
87
88
|
let botsDS;
|
|
88
89
|
if (!staticBots) {
|
|
89
|
-
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId});
|
|
90
|
+
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId, log: log});
|
|
90
91
|
winston.verbose("(tybotRoute) botsDS created with Mongo");
|
|
91
92
|
}
|
|
92
93
|
else {
|
|
@@ -98,15 +99,12 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
98
99
|
Promise.reject(err);
|
|
99
100
|
return;
|
|
100
101
|
});
|
|
101
|
-
|
|
102
|
-
winston.debug("(tybotRoute) Bot found: ", bot)
|
|
103
|
-
|
|
104
102
|
|
|
105
103
|
let intentsMachine;
|
|
106
104
|
let backupMachine;
|
|
107
105
|
if (!staticBots) {
|
|
108
|
-
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId);
|
|
109
|
-
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId);
|
|
106
|
+
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId, log);
|
|
107
|
+
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId, log);
|
|
110
108
|
winston.debug("(tybotRoute) Created backupMachine:", backupMachine)
|
|
111
109
|
}
|
|
112
110
|
else {
|
|
@@ -126,7 +124,8 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
126
124
|
requestId: requestId,
|
|
127
125
|
projectId: projectId,
|
|
128
126
|
MAX_STEPS: MAX_STEPS,
|
|
129
|
-
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME
|
|
127
|
+
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME,
|
|
128
|
+
log: log
|
|
130
129
|
});
|
|
131
130
|
winston.verbose("(tybotRoute) Message text: " + message.text)
|
|
132
131
|
|
|
@@ -163,6 +162,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
163
162
|
API_ENDPOINT: API_ENDPOINT,
|
|
164
163
|
TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
165
164
|
token: token,
|
|
165
|
+
log: log,
|
|
166
166
|
// HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT,
|
|
167
167
|
cache: tdcache
|
|
168
168
|
}
|
|
@@ -187,7 +187,8 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
187
187
|
reply.attributes.fillParams = true;
|
|
188
188
|
|
|
189
189
|
const apiext = new ExtApi({
|
|
190
|
-
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT
|
|
190
|
+
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
|
|
191
|
+
log: false
|
|
191
192
|
});
|
|
192
193
|
apiext.sendSupportMessageExt(reply, projectId, requestId, token, () => {
|
|
193
194
|
winston.verbose("(tybotRoute) sendSupportMessageExt reply sent: ", reply)
|
|
@@ -214,7 +215,8 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
214
215
|
projectId: projectId,
|
|
215
216
|
token: token,
|
|
216
217
|
APIURL: API_ENDPOINT,
|
|
217
|
-
APIKEY: "___"
|
|
218
|
+
APIKEY: "___",
|
|
219
|
+
log: false
|
|
218
220
|
});
|
|
219
221
|
|
|
220
222
|
let request;
|
|
@@ -240,10 +242,10 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
240
242
|
winston.debug("(tybotRoute) API_ENDPOINT: " + API_ENDPOINT);
|
|
241
243
|
winston.debug("(tybotRoute) request: " + TILEBOT_ENDPOINT);
|
|
242
244
|
|
|
243
|
-
let directivesPlug = new DirectivesChatbotPlug({supportRequest: request, API_ENDPOINT: API_ENDPOINT, TILEBOT_ENDPOINT: TILEBOT_ENDPOINT, token: token, HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT, cache: tdcache});
|
|
245
|
+
let directivesPlug = new DirectivesChatbotPlug({supportRequest: request, API_ENDPOINT: API_ENDPOINT, TILEBOT_ENDPOINT: TILEBOT_ENDPOINT, token: token, log: log, HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT, cache: tdcache});
|
|
244
246
|
|
|
245
247
|
const original_answer_text = answer.text;
|
|
246
|
-
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache);
|
|
248
|
+
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache, log);
|
|
247
249
|
winston.debug("(tybotRoute) bot_answer: ", bot_answer);
|
|
248
250
|
|
|
249
251
|
if (bot_answer) {
|
|
@@ -366,7 +368,8 @@ router.post('/echobot', (req, res) => {
|
|
|
366
368
|
projectId: projectId,
|
|
367
369
|
token: token,
|
|
368
370
|
APIURL: API_ENDPOINT,
|
|
369
|
-
APIKEY: "___"
|
|
371
|
+
APIKEY: "___",
|
|
372
|
+
log: false
|
|
370
373
|
});
|
|
371
374
|
|
|
372
375
|
// instantly reply "success" to TILEDESK
|
|
@@ -399,14 +402,8 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => {
|
|
|
399
402
|
|
|
400
403
|
// invoke block
|
|
401
404
|
// unique ID for each execution
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
request_id = body.preloaded_request_id;
|
|
405
|
-
} else {
|
|
406
|
-
const execution_id = uuidv4().replace(/-/g, '');
|
|
407
|
-
request_id = "automation-request-" + project_id + "-" + execution_id;
|
|
408
|
-
|
|
409
|
-
}
|
|
405
|
+
const execution_id = uuidv4().replace(/-/g, '');
|
|
406
|
+
const request_id = "automation-request-" + project_id + "-" + execution_id;
|
|
410
407
|
const command = "/#" + block_id;
|
|
411
408
|
let message = {
|
|
412
409
|
payload: {
|
|
@@ -500,7 +497,13 @@ async function startApp(settings, completionCallback) {
|
|
|
500
497
|
});
|
|
501
498
|
}
|
|
502
499
|
|
|
503
|
-
|
|
500
|
+
if (!settings.log) {
|
|
501
|
+
log = false;
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
log = true;
|
|
505
|
+
}
|
|
506
|
+
winston.info("(Tilebot) Log: " + log);
|
|
504
507
|
|
|
505
508
|
if (process.env.CHATBOT_MAX_STEPS) {
|
|
506
509
|
MAX_STEPS = Number(process.env.CHATBOT_MAX_STEPS);
|
|
@@ -579,7 +582,7 @@ async function checkRequest(request_id, id_project) {
|
|
|
579
582
|
// WARNING! Move this function in models/TiledeskChatbotUtil.js
|
|
580
583
|
}
|
|
581
584
|
|
|
582
|
-
function myrequest(options, callback) {
|
|
585
|
+
function myrequest(options, callback, log) {
|
|
583
586
|
winston.verbose("(tybotRoute) myrequest API URL:" + options.url);
|
|
584
587
|
winston.debug("(tybotRoute) myrequest Options:", options);
|
|
585
588
|
|