@tiledesk/tiledesk-tybot-connector 0.5.0-rc2 → 0.5.1-rc1
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 +7 -0
- package/ExtApi.js +2 -71
- package/Logger.js +32 -5
- package/{models → engine}/IntentsMachineFactory.js +1 -1
- package/{models → engine}/MongodbBotsDataSource.js +2 -2
- package/{models → engine}/MongodbIntentsMachine.js +1 -1
- package/{models → engine}/TiledeskChatbot.js +3 -1
- package/{models → engine}/TiledeskIntentsMachine.js +1 -2
- package/{models → engine/mock}/MockBotsDataSource.js +1 -2
- package/index.js +23 -111
- package/logs/app.log +3041 -4469
- package/logs/app3.log +2822 -0
- package/logs/app4.log +46163 -0
- package/logs/app5.log +33173 -0
- package/models/faq.js +2 -5
- package/package.json +1 -1
- package/{TiledeskServices → services}/AIService.js +4 -3
- package/{models/faqKbService.js → services/FaqKbService.js} +1 -1
- 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 +2 -3
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +1 -1
- package/tiledeskChatbotPlugs/TiledeskRequestVariables.js +1 -1
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirSetAttribute.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +8 -42
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +42 -128
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +9 -74
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +14 -83
- package/tiledeskChatbotPlugs/directives/DirAssign.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +13 -106
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +5 -34
- 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/DirConnectBlock.js +3 -72
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +5 -33
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirForm.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +13 -76
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +8 -53
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +5 -34
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +3 -39
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +2 -38
- package/tiledeskChatbotPlugs/directives/DirIntent.js +2 -77
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +3 -72
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirQapla.js +7 -72
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +3 -38
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +3 -39
- package/tiledeskChatbotPlugs/directives/DirReply.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +3 -29
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +3 -38
- package/tiledeskChatbotPlugs/directives/DirWait.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +32 -22
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +23 -64
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +3 -29
- package/utils/HttpUtils.js +128 -0
- package/{models → utils}/TiledeskChatbotUtil.js +8 -50
- package/TiledeskServices/utils.js +0 -99
- /package/{models → engine}/IntentForm.js +0 -0
- /package/{models → engine}/TiledeskChatbotConst.js +0 -0
- /package/{models → engine/mock}/MockIntentsMachine.js +0 -0
- /package/{models → engine/mock}/MockTdCache.js +0 -0
|
@@ -3,6 +3,7 @@ let https = require("https");
|
|
|
3
3
|
const { v4: uuidv4 } = require('uuid');
|
|
4
4
|
const ms = require('minimist-string');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
|
+
const tilebotService = require('../../services/TilebotService');
|
|
6
7
|
|
|
7
8
|
class DirIntent {
|
|
8
9
|
|
|
@@ -72,7 +73,7 @@ class DirIntent {
|
|
|
72
73
|
}
|
|
73
74
|
winston.debug("DirIntent move to intent message: ", intent_command_request);
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
tilebotService.sendMessageToBot(intent_command_request, botId, () => {
|
|
76
77
|
callback(true);
|
|
77
78
|
});
|
|
78
79
|
|
|
@@ -109,82 +110,6 @@ class DirIntent {
|
|
|
109
110
|
return intentDirective;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
/**
|
|
113
|
-
* A stub to send message to the "ext/botId" endpoint, hosted by tilebot on:
|
|
114
|
-
* /${TILEBOT_ROUTE}/ext/${botId}
|
|
115
|
-
*
|
|
116
|
-
* @param {Object} message. The message to send
|
|
117
|
-
* @param {string} botId. Tiledesk botId
|
|
118
|
-
* @param {string} token. User token
|
|
119
|
-
*/
|
|
120
|
-
sendMessageToBot(TILEBOT_ENDPOINT, message, botId, callback) {
|
|
121
|
-
const url = `${TILEBOT_ENDPOINT}/ext/${botId}`;
|
|
122
|
-
const HTTPREQUEST = {
|
|
123
|
-
url: url,
|
|
124
|
-
headers: {
|
|
125
|
-
'Content-Type' : 'application/json'
|
|
126
|
-
},
|
|
127
|
-
json: message,
|
|
128
|
-
method: 'POST'
|
|
129
|
-
};
|
|
130
|
-
this.myrequest(
|
|
131
|
-
HTTPREQUEST,
|
|
132
|
-
function(err, resbody) {
|
|
133
|
-
if (err) {
|
|
134
|
-
if (callback) {
|
|
135
|
-
callback(err);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
if (callback) {
|
|
140
|
-
callback(null, resbody);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}, false
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
myrequest(options, callback, log) {
|
|
148
|
-
winston.debug("DirIntent API URL:" + options.url);
|
|
149
|
-
winston.debug("DirIntent Options:", options);
|
|
150
|
-
|
|
151
|
-
let axios_options = {
|
|
152
|
-
url: options.url,
|
|
153
|
-
method: options.method,
|
|
154
|
-
data: options.json,
|
|
155
|
-
params: options.params,
|
|
156
|
-
headers: options.headers
|
|
157
|
-
}
|
|
158
|
-
if (options.url.startsWith("https:")) {
|
|
159
|
-
const httpsAgent = new https.Agent({
|
|
160
|
-
rejectUnauthorized: false,
|
|
161
|
-
});
|
|
162
|
-
axios_options.httpsAgent = httpsAgent;
|
|
163
|
-
}
|
|
164
|
-
axios(axios_options)
|
|
165
|
-
.then((res) => {
|
|
166
|
-
if (this.log) {
|
|
167
|
-
winston.debug("DirIntent Response for url: " + options.url);
|
|
168
|
-
winston.debug("DirIntentResponse headers:\n", res.headers);
|
|
169
|
-
}
|
|
170
|
-
if (res && res.status == 200 && res.data) {
|
|
171
|
-
if (callback) {
|
|
172
|
-
callback(null, res.data);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
if (callback) {
|
|
177
|
-
callback(TiledeskClient.getErr({message: "Response status not 200"}, options, res), null, null);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
.catch( (error) => {
|
|
182
|
-
winston.error("(DirIntent) Axios error: ", error.response.data);
|
|
183
|
-
if (callback) {
|
|
184
|
-
callback(error, null, null);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
113
|
}
|
|
189
114
|
|
|
190
115
|
module.exports = { DirIntent };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { DirIntent } = require('./DirIntent');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
|
-
const { TiledeskChatbot } = require("../../
|
|
2
|
+
const { TiledeskChatbot } = require("../../engine/TiledeskChatbot");
|
|
3
3
|
const { Filler } = require("../Filler");
|
|
4
4
|
const { DirIntent } = require("./DirIntent");
|
|
5
5
|
let https = require("https");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Directives } = require('./Directives.js');
|
|
2
2
|
const { TiledeskClient } = require("@tiledesk/tiledesk-client");
|
|
3
|
-
const { TiledeskChatbot } = require("../../
|
|
3
|
+
const { TiledeskChatbot } = require("../../engine/TiledeskChatbot.js");
|
|
4
4
|
const { Filler } = require("../Filler");
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
6
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
let axios = require('axios');
|
|
2
2
|
let https = require("https");
|
|
3
3
|
const { v4: uuidv4 } = require('uuid');
|
|
4
|
-
const winston = require('../../utils/winston')
|
|
4
|
+
const winston = require('../../utils/winston');
|
|
5
|
+
const tilebotService = require('../../services/TilebotService');
|
|
5
6
|
|
|
6
7
|
class DirMessageToBot {
|
|
7
8
|
|
|
@@ -45,81 +46,11 @@ class DirMessageToBot {
|
|
|
45
46
|
}
|
|
46
47
|
winston.debug("(DirMessageToBot) sending message: ", outgoing_message);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
tilebotService.sendMessageToBot(outgoing_message, botId, () => {
|
|
49
50
|
callback(true);
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
/**
|
|
54
|
-
* A stub to send message to the "ext/botId" endpoint, hosted by tilebot on:
|
|
55
|
-
* /${TILEBOT_ROUTE}/ext/${botId}
|
|
56
|
-
*
|
|
57
|
-
* @param {Object} message. The message to send
|
|
58
|
-
* @param {string} botId. Tiledesk botId
|
|
59
|
-
* @param {string} token. User token
|
|
60
|
-
*/
|
|
61
|
-
sendMessageToBot(TILEBOT_ENDPOINT, message, botId, callback) {
|
|
62
|
-
|
|
63
|
-
const url = `${TILEBOT_ENDPOINT}/ext/${botId}`;
|
|
64
|
-
winston.verbose("sendMessageToBot URL" + url);
|
|
65
|
-
const HTTPREQUEST = {
|
|
66
|
-
url: url,
|
|
67
|
-
headers: {
|
|
68
|
-
'Content-Type' : 'application/json'
|
|
69
|
-
},
|
|
70
|
-
json: message,
|
|
71
|
-
method: 'POST'
|
|
72
|
-
};
|
|
73
|
-
this.myrequest(
|
|
74
|
-
HTTPREQUEST,
|
|
75
|
-
function(err, resbody) {
|
|
76
|
-
if (err) {
|
|
77
|
-
if (callback) {
|
|
78
|
-
callback(err);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (callback) {
|
|
83
|
-
callback(null, resbody);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}, false
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
myrequest(options, callback, log) {
|
|
91
|
-
let axios_options = {
|
|
92
|
-
url: options.url,
|
|
93
|
-
method: options.method,
|
|
94
|
-
data: options.json,
|
|
95
|
-
params: options.params,
|
|
96
|
-
headers: options.headers
|
|
97
|
-
}
|
|
98
|
-
if (options.url.startsWith("https:")) {
|
|
99
|
-
const httpsAgent = new https.Agent({
|
|
100
|
-
rejectUnauthorized: false,
|
|
101
|
-
});
|
|
102
|
-
axios_options.httpsAgent = httpsAgent;
|
|
103
|
-
}
|
|
104
|
-
axios(axios_options).then((res) => {
|
|
105
|
-
if (res && res.status == 200 && res.data) {
|
|
106
|
-
if (callback) {
|
|
107
|
-
callback(null, res.data);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
if (callback) {
|
|
112
|
-
callback(TiledeskClient.getErr({message: "Response status not 200"}, options, res), null, null);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
.catch( (error) => {
|
|
117
|
-
winston.error("(DirMessageToBot) Axios error: ", error.response.data);
|
|
118
|
-
if (callback) {
|
|
119
|
-
callback(error, null, null);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
54
|
}
|
|
124
55
|
|
|
125
56
|
module.exports = { DirMessageToBot };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { Directives } = require('./Directives');
|
|
3
|
-
const { TiledeskChatbot } = require('../../
|
|
4
|
-
const { TiledeskChatbotConst } = require('../../
|
|
3
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
|
+
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { Directives } = require('./Directives');
|
|
3
|
-
const { TiledeskChatbot } = require('../../
|
|
4
|
-
const { TiledeskChatbotConst } = require('../../
|
|
3
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
|
+
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
7
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
|
-
const { TiledeskChatbot } = require("../../
|
|
2
|
+
const { TiledeskChatbot } = require("../../engine/TiledeskChatbot");
|
|
3
3
|
const { Filler } = require("../Filler");
|
|
4
4
|
let https = require("https");
|
|
5
5
|
const { DirIntent } = require("./DirIntent");
|
|
6
6
|
require('dotenv').config();
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const httpUtils = require("../../utils/HttpUtils");
|
|
9
|
+
const integrationService = require("../../services/IntegrationService");
|
|
8
10
|
|
|
9
11
|
class DirQapla {
|
|
10
12
|
|
|
@@ -15,6 +17,8 @@ class DirQapla {
|
|
|
15
17
|
this.context = context;
|
|
16
18
|
this.tdcache = this.context.tdcache;
|
|
17
19
|
this.requestId = this.context.requestId;
|
|
20
|
+
this.projectId = this.context.projectId;
|
|
21
|
+
this.token = this.context.token;
|
|
18
22
|
this.intentDir = new DirIntent(context);
|
|
19
23
|
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
20
24
|
this.log = context.log;
|
|
@@ -88,7 +92,7 @@ class DirQapla {
|
|
|
88
92
|
|
|
89
93
|
if (!key) {
|
|
90
94
|
winston.debug("(DirQapla) DirQapla - Key not found into action. Searching in integrations...");
|
|
91
|
-
key = await
|
|
95
|
+
key = await integrationService.getKeyFromIntegrations(this.projectId, 'qapla', this.token);
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
if (!key) {
|
|
@@ -117,7 +121,7 @@ class DirQapla {
|
|
|
117
121
|
}
|
|
118
122
|
winston.debug("(DirQapla) HttpRequest ", QAPLA_HTTPREQUEST);
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
httpUtils.request(
|
|
121
125
|
QAPLA_HTTPREQUEST, async (err, resbody) => {
|
|
122
126
|
if (err) {
|
|
123
127
|
if (callback) {
|
|
@@ -218,75 +222,6 @@ class DirQapla {
|
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
|
-
|
|
222
|
-
#myrequest(options, callback) {
|
|
223
|
-
let axios_options = {
|
|
224
|
-
url: options.url,
|
|
225
|
-
method: options.method,
|
|
226
|
-
params: options.params,
|
|
227
|
-
headers: options.headers
|
|
228
|
-
}
|
|
229
|
-
if (options.json !== null) {
|
|
230
|
-
axios_options.data = options.json
|
|
231
|
-
}
|
|
232
|
-
if (options.url.startsWith("https:")) {
|
|
233
|
-
const httpsAgent = new https.Agent({
|
|
234
|
-
rejectUnauthorized: false,
|
|
235
|
-
});
|
|
236
|
-
axios_options.httpsAgent = httpsAgent;
|
|
237
|
-
}
|
|
238
|
-
axios(axios_options)
|
|
239
|
-
.then((res) => {
|
|
240
|
-
if (res && res.status == 200 && res.data) {
|
|
241
|
-
if (callback) {
|
|
242
|
-
callback(null, res.data);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
if (callback) {
|
|
247
|
-
callback(new Error("Response status is not 200"), null);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
})
|
|
251
|
-
.catch((error) => {
|
|
252
|
-
winston.error("(DirQapla) Axios error: ", error.response.data);
|
|
253
|
-
if (callback) {
|
|
254
|
-
callback(error, null);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async getKeyFromIntegrations() {
|
|
260
|
-
return new Promise((resolve) => {
|
|
261
|
-
|
|
262
|
-
const INTEGRATIONS_HTTPREQUEST = {
|
|
263
|
-
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/qapla",
|
|
264
|
-
headers: {
|
|
265
|
-
'Content-Type': 'application/json',
|
|
266
|
-
'Authorization': 'JWT ' + this.context.token
|
|
267
|
-
},
|
|
268
|
-
method: "GET"
|
|
269
|
-
}
|
|
270
|
-
winston.debug("(DirQapla) Integrations HttpRequest ", INTEGRATIONS_HTTPREQUEST)
|
|
271
|
-
|
|
272
|
-
this.#myrequest(
|
|
273
|
-
INTEGRATIONS_HTTPREQUEST, async (err, integration) => {
|
|
274
|
-
if (err) {
|
|
275
|
-
resolve(null);
|
|
276
|
-
} else {
|
|
277
|
-
|
|
278
|
-
if (integration &&
|
|
279
|
-
integration.value) {
|
|
280
|
-
resolve(integration.value.apikey)
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
resolve(null)
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
}
|
|
289
|
-
|
|
290
225
|
}
|
|
291
226
|
|
|
292
227
|
module.exports = { DirQapla }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Filler } = require('../Filler');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
3
|
-
const { TiledeskChatbotUtil } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
|
+
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
4
4
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { Filler } = require('../Filler');
|
|
4
4
|
const winston = require('../../utils/winston');
|
|
5
5
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { Filler } = require('../Filler');
|
|
4
4
|
|
|
5
5
|
const axios = require("axios").default;
|
|
6
6
|
let https = require("https");
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const httpUtils = require('../../utils/HttpUtils');
|
|
8
9
|
|
|
9
10
|
class DirReplaceBotV2 {
|
|
10
11
|
|
|
@@ -76,7 +77,7 @@ class DirReplaceBotV2 {
|
|
|
76
77
|
method: 'PUT'
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
httpUtils.request(
|
|
80
81
|
HTTPREQUEST, async (err, resbody) => {
|
|
81
82
|
if (err) {
|
|
82
83
|
winston.error("(DirReplaceBotV2) DirReplaceBot error: ", err);
|
|
@@ -135,42 +136,6 @@ class DirReplaceBotV2 {
|
|
|
135
136
|
// });
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
#myrequest(options, callback) {
|
|
139
|
-
let axios_options = {
|
|
140
|
-
url: options.url,
|
|
141
|
-
method: options.method,
|
|
142
|
-
params: options.params,
|
|
143
|
-
headers: options.headers
|
|
144
|
-
}
|
|
145
|
-
if (options.json !== null) {
|
|
146
|
-
axios_options.data = options.json
|
|
147
|
-
}
|
|
148
|
-
if (options.url.startsWith("https:")) {
|
|
149
|
-
const httpsAgent = new https.Agent({
|
|
150
|
-
rejectUnauthorized: false,
|
|
151
|
-
});
|
|
152
|
-
axios_options.httpsAgent = httpsAgent;
|
|
153
|
-
}
|
|
154
|
-
axios(axios_options)
|
|
155
|
-
.then((res) => {
|
|
156
|
-
if (res && res.status == 200 && res.data) {
|
|
157
|
-
if (callback) {
|
|
158
|
-
callback(null, res.data);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
if (callback) {
|
|
163
|
-
callback(new Error("Response status is not 200"), null);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
.catch((error) => {
|
|
168
|
-
winston.error("(DirAskGPT) Axios error: ", error.response.data);
|
|
169
|
-
if (callback) {
|
|
170
|
-
callback(error, null);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
139
|
}
|
|
175
140
|
|
|
176
141
|
module.exports = { DirReplaceBotV2 };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { Filler } = require('../Filler');
|
|
4
4
|
|
|
5
5
|
const axios = require("axios").default;
|
|
6
6
|
let https = require("https");
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const httpUtils = require('../../utils/HttpUtils');
|
|
8
9
|
|
|
9
10
|
class DirReplaceBotV3 {
|
|
10
11
|
|
|
@@ -75,7 +76,7 @@ class DirReplaceBotV3 {
|
|
|
75
76
|
method: 'PUT'
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
httpUtils.request(
|
|
79
80
|
HTTPREQUEST, async (err, resbody) => {
|
|
80
81
|
if (err) {
|
|
81
82
|
winston.error("(DirReplaceBotV3) error: ", err);
|
|
@@ -111,43 +112,6 @@ class DirReplaceBotV3 {
|
|
|
111
112
|
)
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
#myrequest(options, callback) {
|
|
115
|
-
let axios_options = {
|
|
116
|
-
url: options.url,
|
|
117
|
-
method: options.method,
|
|
118
|
-
params: options.params,
|
|
119
|
-
headers: options.headers
|
|
120
|
-
}
|
|
121
|
-
if (options.json !== null) {
|
|
122
|
-
axios_options.data = options.json
|
|
123
|
-
}
|
|
124
|
-
if (options.url.startsWith("https:")) {
|
|
125
|
-
const httpsAgent = new https.Agent({
|
|
126
|
-
rejectUnauthorized: false,
|
|
127
|
-
});
|
|
128
|
-
axios_options.httpsAgent = httpsAgent;
|
|
129
|
-
}
|
|
130
|
-
axios(axios_options)
|
|
131
|
-
.then((res) => {
|
|
132
|
-
if (res && res.status == 200 && res.data) {
|
|
133
|
-
if (callback) {
|
|
134
|
-
callback(null, res.data);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
if (callback) {
|
|
139
|
-
callback(new Error("Response status is not 200"), null);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
.catch((error) => {
|
|
144
|
-
winston.error("(DirAskGPT) Axios error: ", error.response.data);
|
|
145
|
-
if (callback) {
|
|
146
|
-
callback(error, null);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
115
|
}
|
|
152
116
|
|
|
153
117
|
module.exports = { DirReplaceBotV3 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Filler } = require('../Filler');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
3
|
-
const { TiledeskChatbotUtil } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
|
+
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
4
4
|
let axios = require('axios');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Filler } = require('../Filler');
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
3
|
-
const { TiledeskChatbotConst } = require('../../
|
|
4
|
-
const { TiledeskChatbotUtil } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
|
+
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst');
|
|
4
|
+
const { TiledeskChatbotUtil } = require('../../utils/TiledeskChatbotUtil');
|
|
5
5
|
const { DirIntent } = require("./DirIntent");
|
|
6
6
|
// const { defaultOptions } = require('liquidjs');
|
|
7
7
|
const { DirMessageToBot } = require('./DirMessageToBot');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { param } = require('express/lib/request');
|
|
2
2
|
const ms = require('minimist-string');
|
|
3
|
-
const { TiledeskChatbot } = require('../../
|
|
3
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
4
4
|
const { Filler } = require('../Filler');
|
|
5
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
6
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
|
-
const { TiledeskChatbot } = require('../../
|
|
2
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { Filler } = require("../Filler");
|
|
4
4
|
const { DirIntent } = require("./DirIntent");
|
|
5
5
|
const winston = require('../../utils/winston');
|
|
6
|
+
const httpUtils = require("../../utils/HttpUtils");
|
|
6
7
|
|
|
7
8
|
let whatsapp_api_url;
|
|
8
9
|
|
|
@@ -94,7 +95,7 @@ class DirSendWhatsapp {
|
|
|
94
95
|
|
|
95
96
|
winston.debug("(DirSendWhatsapp) HttpRequest: ", HTTPREQUEST);
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
httpUtils.request(
|
|
98
99
|
HTTPREQUEST, async (err, resbody) => {
|
|
99
100
|
if (err) {
|
|
100
101
|
winston.error("(DirSendWhatsapp) error: ", err)
|
|
@@ -216,33 +217,6 @@ class DirSendWhatsapp {
|
|
|
216
217
|
|
|
217
218
|
})
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
-
// HTTP REQUEST
|
|
221
|
-
async #myrequest(options, callback, log) {
|
|
222
|
-
return await axios({
|
|
223
|
-
url: options.url,
|
|
224
|
-
method: options.method,
|
|
225
|
-
data: options.json,
|
|
226
|
-
params: options.params,
|
|
227
|
-
headers: options.headers
|
|
228
|
-
}).then((res) => {
|
|
229
|
-
if (res && res.status == 200 && res.data) {
|
|
230
|
-
if (callback) {
|
|
231
|
-
callback(null, res.data);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
if (callback) {
|
|
236
|
-
callback(TiledeskClient.getErr({ message: "Response status not 200" }, options, res), null, null);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}).catch((err) => {
|
|
240
|
-
winston.error("(DirSendWhatsapp) Axios errro: ", err);
|
|
241
|
-
if (callback) {
|
|
242
|
-
callback(err, null, null);
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
}
|
|
246
220
|
}
|
|
247
221
|
|
|
248
222
|
module.exports = { DirSendWhatsapp }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { TiledeskChatbot } = require('../../
|
|
1
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
2
2
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
3
3
|
const { TiledeskMath } = require('../../TiledeskMath');
|
|
4
4
|
const { TiledeskString } = require('../../TiledeskString');
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const { TiledeskChatbot } = require('../../
|
|
1
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
2
2
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
3
3
|
const { TiledeskMath } = require('../../TiledeskMath');
|
|
4
4
|
const { TiledeskString } = require('../../TiledeskString');
|
|
5
5
|
const { Filler } = require('../Filler');
|
|
6
6
|
const validate = require('jsonschema').validate;
|
|
7
7
|
const winston = require('../../utils/winston');
|
|
8
|
+
const httpUtils = require('../../utils/HttpUtils');
|
|
8
9
|
|
|
9
10
|
const schema = {
|
|
10
11
|
"type": "object",
|
|
@@ -195,7 +196,7 @@ class DirSetAttributeV2 {
|
|
|
195
196
|
method: 'POST'
|
|
196
197
|
}
|
|
197
198
|
winston.debug("(DirSetAttributeV2) HttpRequest: ", HTTPREQUEST);
|
|
198
|
-
|
|
199
|
+
httpUtils.request(
|
|
199
200
|
HTTPREQUEST, async (err, resbody) => {
|
|
200
201
|
if (err) {
|
|
201
202
|
if (this.log) {
|
|
@@ -291,42 +292,6 @@ class DirSetAttributeV2 {
|
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
294
|
|
|
294
|
-
#myrequest(options, callback) {
|
|
295
|
-
let axios_options = {
|
|
296
|
-
url: options.url,
|
|
297
|
-
method: options.method,
|
|
298
|
-
params: options.params,
|
|
299
|
-
headers: options.headers
|
|
300
|
-
}
|
|
301
|
-
if (options.json !== null) {
|
|
302
|
-
axios_options.data = options.json
|
|
303
|
-
}
|
|
304
|
-
if (options.url.startsWith("https:")) {
|
|
305
|
-
const httpsAgent = new https.Agent({
|
|
306
|
-
rejectUnauthorized: false,
|
|
307
|
-
});
|
|
308
|
-
axios_options.httpsAgent = httpsAgent;
|
|
309
|
-
}
|
|
310
|
-
axios(axios_options)
|
|
311
|
-
.then((res) => {
|
|
312
|
-
if (res && res.status == 200 && res.data) {
|
|
313
|
-
if (callback) {
|
|
314
|
-
callback(null, res.data);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
if (callback) {
|
|
319
|
-
callback(new Error("Response status is not 200"), null);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
.catch((error) => {
|
|
324
|
-
if (callback) {
|
|
325
|
-
callback(error, null);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
295
|
fixToken(token) {
|
|
331
296
|
if (token.startsWith('JWT ')) {
|
|
332
297
|
return token
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let axios = require('axios');
|
|
2
2
|
let https = require("https");
|
|
3
3
|
const { Filler } = require('../Filler');
|
|
4
|
-
const { TiledeskChatbot } = require('../../
|
|
4
|
+
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
5
5
|
const { TiledeskJSONEval } = require('../../TiledeskJSONEval');
|
|
6
6
|
const winston = require('../../utils/winston');
|
|
7
7
|
|