@tiledesk/tiledesk-tybot-connector 2.0.8-rc2 → 2.0.8
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 +5 -31
- package/ExtApi.js +8 -1
- package/ExtUtil.js +6 -5
- package/Logger.js +13 -30
- 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/app1.log +1310 -0
- package/package.json +2 -3
- package/services/AIService.js +1 -1
- package/services/IntegrationService.js +1 -1
- package/services/TilebotService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +18 -24
- 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 +3 -1
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +1 -0
- 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 +16 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +417 -0
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +39 -0
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -0
- package/tiledeskChatbotPlugs/directives/Directives.js +0 -1
- package/utils/TiledeskChatbotUtil.js +57 -19
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;
|
|
@@ -99,7 +100,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
99
100
|
|
|
100
101
|
let botsDS;
|
|
101
102
|
if (!staticBots) {
|
|
102
|
-
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId});
|
|
103
|
+
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId, log: log});
|
|
103
104
|
winston.verbose("(tybotRoute) botsDS created with Mongo");
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
@@ -111,15 +112,12 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
111
112
|
Promise.reject(err);
|
|
112
113
|
return;
|
|
113
114
|
});
|
|
114
|
-
|
|
115
|
-
winston.debug("(tybotRoute) Bot found: ", bot)
|
|
116
|
-
|
|
117
115
|
|
|
118
116
|
let intentsMachine;
|
|
119
117
|
let backupMachine;
|
|
120
118
|
if (!staticBots) {
|
|
121
|
-
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId);
|
|
122
|
-
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId);
|
|
119
|
+
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId, log);
|
|
120
|
+
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId, log);
|
|
123
121
|
winston.debug("(tybotRoute) Created backupMachine:", backupMachine)
|
|
124
122
|
}
|
|
125
123
|
else {
|
|
@@ -139,7 +137,8 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
139
137
|
requestId: requestId,
|
|
140
138
|
projectId: projectId,
|
|
141
139
|
MAX_STEPS: MAX_STEPS,
|
|
142
|
-
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME
|
|
140
|
+
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME,
|
|
141
|
+
log: log
|
|
143
142
|
});
|
|
144
143
|
winston.verbose("(tybotRoute) Message text: " + message.text)
|
|
145
144
|
|
|
@@ -176,6 +175,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
176
175
|
API_ENDPOINT: API_ENDPOINT,
|
|
177
176
|
TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
178
177
|
token: token,
|
|
178
|
+
log: log,
|
|
179
179
|
// HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT,
|
|
180
180
|
cache: tdcache
|
|
181
181
|
}
|
|
@@ -200,7 +200,8 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
200
200
|
reply.attributes.fillParams = true;
|
|
201
201
|
|
|
202
202
|
const apiext = new ExtApi({
|
|
203
|
-
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT
|
|
203
|
+
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
|
|
204
|
+
log: false
|
|
204
205
|
});
|
|
205
206
|
apiext.sendSupportMessageExt(reply, projectId, requestId, token, () => {
|
|
206
207
|
winston.verbose("(tybotRoute) sendSupportMessageExt reply sent: ", reply)
|
|
@@ -227,7 +228,8 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
227
228
|
projectId: projectId,
|
|
228
229
|
token: token,
|
|
229
230
|
APIURL: API_ENDPOINT,
|
|
230
|
-
APIKEY: "___"
|
|
231
|
+
APIKEY: "___",
|
|
232
|
+
log: false
|
|
231
233
|
});
|
|
232
234
|
|
|
233
235
|
let request;
|
|
@@ -253,10 +255,10 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
253
255
|
winston.debug("(tybotRoute) API_ENDPOINT: " + API_ENDPOINT);
|
|
254
256
|
winston.debug("(tybotRoute) request: " + TILEBOT_ENDPOINT);
|
|
255
257
|
|
|
256
|
-
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});
|
|
258
|
+
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});
|
|
257
259
|
|
|
258
260
|
const original_answer_text = answer.text;
|
|
259
|
-
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache);
|
|
261
|
+
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache, log);
|
|
260
262
|
winston.debug("(tybotRoute) bot_answer: ", bot_answer);
|
|
261
263
|
|
|
262
264
|
if (bot_answer) {
|
|
@@ -379,7 +381,8 @@ router.post('/echobot', (req, res) => {
|
|
|
379
381
|
projectId: projectId,
|
|
380
382
|
token: token,
|
|
381
383
|
APIURL: API_ENDPOINT,
|
|
382
|
-
APIKEY: "___"
|
|
384
|
+
APIKEY: "___",
|
|
385
|
+
log: false
|
|
383
386
|
});
|
|
384
387
|
|
|
385
388
|
// instantly reply "success" to TILEDESK
|
|
@@ -412,14 +415,8 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => {
|
|
|
412
415
|
|
|
413
416
|
// invoke block
|
|
414
417
|
// unique ID for each execution
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
request_id = body.preloaded_request_id;
|
|
418
|
-
} else {
|
|
419
|
-
const execution_id = uuidv4().replace(/-/g, '');
|
|
420
|
-
request_id = "automation-request-" + project_id + "-" + execution_id;
|
|
421
|
-
|
|
422
|
-
}
|
|
418
|
+
const execution_id = uuidv4().replace(/-/g, '');
|
|
419
|
+
const request_id = "automation-request-" + project_id + "-" + execution_id;
|
|
423
420
|
const command = "/#" + block_id;
|
|
424
421
|
let message = {
|
|
425
422
|
payload: {
|
|
@@ -513,7 +510,13 @@ async function startApp(settings, completionCallback) {
|
|
|
513
510
|
});
|
|
514
511
|
}
|
|
515
512
|
|
|
516
|
-
|
|
513
|
+
if (!settings.log) {
|
|
514
|
+
log = false;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
log = true;
|
|
518
|
+
}
|
|
519
|
+
winston.info("(Tilebot) Log: " + log);
|
|
517
520
|
|
|
518
521
|
if (process.env.CHATBOT_MAX_STEPS) {
|
|
519
522
|
MAX_STEPS = Number(process.env.CHATBOT_MAX_STEPS);
|
|
@@ -592,7 +595,7 @@ async function checkRequest(request_id, id_project) {
|
|
|
592
595
|
// WARNING! Move this function in models/TiledeskChatbotUtil.js
|
|
593
596
|
}
|
|
594
597
|
|
|
595
|
-
function myrequest(options, callback) {
|
|
598
|
+
function myrequest(options, callback, log) {
|
|
596
599
|
winston.verbose("(tybotRoute) myrequest API URL:" + options.url);
|
|
597
600
|
winston.debug("(tybotRoute) myrequest Options:", options);
|
|
598
601
|
|