@tiledesk/tiledesk-tybot-connector 0.5.0 → 2.0.0
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 +4 -83
- package/ExtUtil.js +0 -1
- package/Logger.js +105 -0
- package/TdCache.js +5 -3
- package/TiledeskClientTest.js +5 -28
- package/TiledeskExpression.js +6 -47
- package/{models → engine}/IntentForm.js +30 -44
- package/{models → engine}/IntentsMachineFactory.js +5 -4
- package/{models → engine}/MongodbBotsDataSource.js +31 -55
- package/{models → engine}/MongodbIntentsMachine.js +6 -5
- package/{models → engine}/TiledeskChatbot.js +82 -259
- package/{models → engine}/TiledeskChatbotConst.js +9 -0
- package/{models → engine}/TiledeskIntentsMachine.js +5 -15
- package/{models → engine/mock}/MockBotsDataSource.js +3 -19
- package/{models → engine/mock}/MockTdCache.js +0 -9
- package/index.js +103 -380
- package/logs/app.log +12723 -277
- package/logs/app1.log +62258 -0
- package/logs/app2.log +46280 -0
- package/logs/app3.log +31686 -0
- package/logs/app4.log +46163 -0
- package/logs/app5.log +33173 -0
- package/models/faq.js +2 -5
- package/package.json +5 -2
- package/{TiledeskServices → services}/AIService.js +4 -3
- package/{models/faqKbService.js → services/FaqKbService.js} +1 -2
- package/{models/faqService.js → services/FaqService.js} +4 -3
- package/services/IntegrationService.js +43 -0
- package/services/TilebotService.js +47 -0
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +49 -135
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +8 -14
- package/tiledeskChatbotPlugs/Filler.js +0 -1
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +12 -20
- package/tiledeskChatbotPlugs/MessagePipeline.js +5 -15
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +4 -13
- package/tiledeskChatbotPlugs/TiledeskRequestVariables.js +1 -1
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +21 -89
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirSetAttribute.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +23 -140
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +42 -128
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +37 -127
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +52 -145
- package/tiledeskChatbotPlugs/directives/DirAssign.js +12 -23
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +16 -12
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +56 -198
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +41 -101
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +9 -19
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +4 -2
- package/tiledeskChatbotPlugs/directives/DirCode.js +16 -23
- package/tiledeskChatbotPlugs/directives/DirCondition.js +19 -25
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +9 -82
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +10 -22
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +34 -89
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +17 -22
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +8 -8
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -12
- package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +2 -6
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -4
- package/tiledeskChatbotPlugs/directives/DirForm.js +17 -24
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +49 -139
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +8 -53
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +31 -91
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +19 -26
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +24 -78
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +17 -68
- package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -100
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +15 -14
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +7 -12
- package/tiledeskChatbotPlugs/directives/DirMake.js +21 -53
- package/tiledeskChatbotPlugs/directives/DirMessage.js +35 -28
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +8 -87
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirQapla.js +26 -120
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +11 -19
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +5 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +12 -58
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +11 -57
- package/tiledeskChatbotPlugs/directives/DirReply.js +36 -30
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +30 -72
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +9 -10
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +15 -40
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +25 -113
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +14 -13
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirWait.js +5 -6
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +14 -49
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +22 -77
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +11 -14
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +13 -42
- package/tiledeskChatbotPlugs/directives/Directives.js +0 -3
- package/utils/HttpUtils.js +128 -0
- package/{models → utils}/TiledeskChatbotUtil.js +164 -234
- package/utils/winston.js +42 -0
- package/TiledeskServices/utils.js +0 -99
- /package/{models → engine/mock}/MockIntentsMachine.js +0 -0
package/utils/winston.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
var appRoot = require('app-root-path');
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
var level = process.env.LOG_LEVEL || "info";
|
|
5
|
+
|
|
6
|
+
var options = {
|
|
7
|
+
file: {
|
|
8
|
+
level:level ,
|
|
9
|
+
filename: `${appRoot}/logs/app.log`,
|
|
10
|
+
handleExceptions: true,
|
|
11
|
+
json: false,
|
|
12
|
+
maxsize: 5242880, // 5MB
|
|
13
|
+
maxFiles: 5,
|
|
14
|
+
colorize: false,
|
|
15
|
+
format: winston.format.simple()
|
|
16
|
+
},
|
|
17
|
+
console: {
|
|
18
|
+
level: level,
|
|
19
|
+
handleExceptions: true,
|
|
20
|
+
json: true,
|
|
21
|
+
colorize: true,
|
|
22
|
+
// timestamp: true,
|
|
23
|
+
format: winston.format.simple()
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let logger = winston.createLogger({
|
|
28
|
+
transports: [
|
|
29
|
+
new (winston.transports.Console)(options.console),
|
|
30
|
+
new (winston.transports.File)(options.file),
|
|
31
|
+
],
|
|
32
|
+
exitOnError: false, // do not exit on handled exceptions
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
logger.stream = {
|
|
36
|
+
write: function(message, encoding) {
|
|
37
|
+
logger.info(message);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
module.exports = logger;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
let axios = require('axios');
|
|
2
|
-
let https = require("https");
|
|
3
|
-
|
|
4
|
-
class Utils {
|
|
5
|
-
constructor(){}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
static myrequest(options, callback, log) {
|
|
9
|
-
if (log) {
|
|
10
|
-
console.log("** API URL:", options.url);
|
|
11
|
-
console.log("** Options:", JSON.stringify(options));
|
|
12
|
-
}
|
|
13
|
-
let axios_settings = {
|
|
14
|
-
url: options.url,
|
|
15
|
-
method: options.method,
|
|
16
|
-
data: options.json,
|
|
17
|
-
params: options.params,
|
|
18
|
-
headers: options.headers
|
|
19
|
-
}
|
|
20
|
-
// console.log("options.url.startsWith(https:)", options.url.startsWith("https:"))
|
|
21
|
-
// console.log("this.httpsOptions", this.httpsOptions)
|
|
22
|
-
|
|
23
|
-
if (options.url.startsWith("https:") && options.httpsOptions) {
|
|
24
|
-
// console.log("Tiledesk Client v 0.9.x: url.startsWith https: && httpsOptions");
|
|
25
|
-
const httpsAgent = new https.Agent(options.httpsOptions);
|
|
26
|
-
axios_settings.httpsAgent = httpsAgent;
|
|
27
|
-
}
|
|
28
|
-
else if (options.url.startsWith("https:") && !options.httpsOptions) {
|
|
29
|
-
// HTTPS default is rejectUnauthorized: false
|
|
30
|
-
// console.log("Tiledesk Client v 0.9.x: url.startsWith https: && NOT httpsOptions");
|
|
31
|
-
const httpsAgent = new https.Agent({
|
|
32
|
-
rejectUnauthorized: false,
|
|
33
|
-
});
|
|
34
|
-
axios_settings.httpsAgent = httpsAgent;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// console.log("Using axios settings:", axios_settings)
|
|
40
|
-
// axios(
|
|
41
|
-
// {
|
|
42
|
-
// url: options.url,
|
|
43
|
-
// method: options.method,
|
|
44
|
-
// data: options.json,
|
|
45
|
-
// params: options.params,
|
|
46
|
-
// httpsAgent: httpsAgent,
|
|
47
|
-
// headers: options.headers
|
|
48
|
-
// })
|
|
49
|
-
axios(axios_settings)
|
|
50
|
-
.then(function (res) {
|
|
51
|
-
if (log) {
|
|
52
|
-
console.log("Response for url:", options.url);
|
|
53
|
-
console.log("Response headers:\n", JSON.stringify(res.headers));
|
|
54
|
-
// console.log("******** Response for url:", res);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (res && res.status == 200 && res.data) {
|
|
58
|
-
if (callback) {
|
|
59
|
-
callback(null, res.data);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
|
|
64
|
-
if (callback) {
|
|
65
|
-
callback(Utils.getErr({message: "Response status not 200"}, options, res), null, null);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
.catch(function (error) {
|
|
70
|
-
// console.error(error);
|
|
71
|
-
if (callback) {
|
|
72
|
-
callback(error, null, null);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static getErr(err, request, response) {
|
|
78
|
-
let res_err = {}
|
|
79
|
-
res_err.http_err = err;
|
|
80
|
-
res_err.http_request = request;
|
|
81
|
-
res_err.http_response = response;
|
|
82
|
-
return res_err;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
static fixToken(token) {
|
|
86
|
-
if (token.startsWith('JWT ')) {
|
|
87
|
-
return token;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
return 'JWT ' + token;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
module.exports = Utils
|
|
File without changes
|