@tiledesk/tiledesk-tybot-connector 0.2.131-rc5 → 0.2.131
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 -4
- package/TdCache.js +1 -1
- package/index.js +12 -12
- package/models/TiledeskChatbot.js +2 -3
- package/models/TiledeskChatbotUtil.js +4 -8
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +8 -6
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +20 -20
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +13 -10
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +57 -18
- package/tiledeskChatbotPlugs/directives/DirAssign.js +11 -0
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +21 -11
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +5 -4
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +28 -1
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirClose.js +2 -13
- package/tiledeskChatbotPlugs/directives/DirCondition.js +26 -0
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +13 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +3 -12
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +5 -14
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +6 -17
- package/tiledeskChatbotPlugs/directives/DirForm.js +2 -12
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +18 -14
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +7 -4
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +27 -14
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +3 -13
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +31 -5
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +27 -13
- package/tiledeskChatbotPlugs/directives/DirIntent.js +23 -1
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +26 -0
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +13 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +2 -12
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +2 -11
- package/tiledeskChatbotPlugs/directives/DirQapla.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +7 -17
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +2 -11
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +3 -12
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +22 -12
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +4 -13
- package/tiledeskChatbotPlugs/directives/DirWait.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +60 -2
- /package/tiledeskChatbotPlugs/directives/{DEPRECATED_DirOfflineHours.js → DirOfflineHours.js} +0 -0
|
@@ -16,7 +16,6 @@ class DirHubspot {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
-
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
20
19
|
this.log = context.log;
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -72,10 +71,14 @@ class DirHubspot {
|
|
|
72
71
|
return;
|
|
73
72
|
}
|
|
74
73
|
|
|
74
|
+
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
75
75
|
const hubspot_base_url = process.env.HUBSPOT_ENDPOINT || "https://api.hubapi.com/crm/v3/";
|
|
76
|
-
if (this.log) {
|
|
76
|
+
if (this.log) {
|
|
77
|
+
console.log("DirHubspot server_base_url ", server_base_url);
|
|
78
|
+
console.log("DirHubspot hubspot_base_url ", hubspot_base_url);
|
|
79
|
+
}
|
|
77
80
|
|
|
78
|
-
let key = await this.getKeyFromIntegrations();
|
|
81
|
+
let key = await this.getKeyFromIntegrations(server_base_url);
|
|
79
82
|
if (!key) {
|
|
80
83
|
if (this.log) { console.log("DirHubspot - Key not found in Integrations."); }
|
|
81
84
|
if (falseIntent) {
|
|
@@ -286,11 +289,11 @@ class DirHubspot {
|
|
|
286
289
|
}
|
|
287
290
|
}
|
|
288
291
|
|
|
289
|
-
async getKeyFromIntegrations() {
|
|
292
|
+
async getKeyFromIntegrations(server_base_url) {
|
|
290
293
|
return new Promise((resolve) => {
|
|
291
294
|
|
|
292
295
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
293
|
-
url:
|
|
296
|
+
url: server_base_url + "/" + this.context.projectId + "/integration/name/hubspot",
|
|
294
297
|
headers: {
|
|
295
298
|
'Content-Type': 'application/json',
|
|
296
299
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
3
2
|
const { DirIntent } = require('./DirIntent');
|
|
4
3
|
const ms = require('minimist-string');
|
|
5
4
|
|
|
@@ -9,19 +8,33 @@ class DirIfOnlineAgents {
|
|
|
9
8
|
if (!context) {
|
|
10
9
|
throw new Error('context object is mandatory.');
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
this.
|
|
11
|
+
this.tdclient = context.tdclient;
|
|
12
|
+
// this.tdclient = new TiledeskClient({
|
|
13
|
+
// projectId: context.projectId,
|
|
14
|
+
// token: context.token,
|
|
15
|
+
// APIURL: context.TILEDESK_APIURL,
|
|
16
|
+
// APIKEY: "___",
|
|
17
|
+
// log: context.log
|
|
18
|
+
// });
|
|
19
|
+
// let context = {
|
|
20
|
+
// projectId: projectId,
|
|
21
|
+
// token: token,
|
|
22
|
+
// requestId: supportRequest,
|
|
23
|
+
// APIURL: API_URL,
|
|
24
|
+
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
25
|
+
// departmentId: depId,
|
|
26
|
+
// log: false
|
|
27
|
+
// }
|
|
14
28
|
this.intentDir = new DirIntent(context);
|
|
15
|
-
|
|
29
|
+
// {
|
|
30
|
+
// API_ENDPOINT: context.TILEDESK_APIURL,
|
|
31
|
+
// TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
|
|
32
|
+
// supportRequest: context.supportRequest,
|
|
33
|
+
// token: context.token,
|
|
34
|
+
// log: context.log
|
|
35
|
+
// }
|
|
36
|
+
// );
|
|
16
37
|
this.log = context.log;
|
|
17
|
-
|
|
18
|
-
this.tdClient = new TiledeskClient({
|
|
19
|
-
projectId: this.context.projectId,
|
|
20
|
-
token: this.context.token,
|
|
21
|
-
APIURL: this.API_ENDPOINT,
|
|
22
|
-
APIKEY: "___",
|
|
23
|
-
log: this.log
|
|
24
|
-
});
|
|
25
38
|
}
|
|
26
39
|
|
|
27
40
|
execute(directive, callback) {
|
|
@@ -70,7 +83,7 @@ class DirIfOnlineAgents {
|
|
|
70
83
|
const trueIntentAttributes = action.trueIntentAttributes;
|
|
71
84
|
const falseIntentAttributes = action.falseIntentAttributes;
|
|
72
85
|
let stopOnConditionMet = action.stopOnConditionMet;
|
|
73
|
-
this.
|
|
86
|
+
this.tdclient.openNow((err, result) => {
|
|
74
87
|
if (this.log) {console.log("openNow():", result);}
|
|
75
88
|
if (err) {
|
|
76
89
|
console.error("IfOnlineAgents:tdclient.openNow Error:", err);
|
|
@@ -79,7 +92,7 @@ class DirIfOnlineAgents {
|
|
|
79
92
|
}
|
|
80
93
|
else {
|
|
81
94
|
if (result && result.isopen) {
|
|
82
|
-
this.
|
|
95
|
+
this.tdclient.getProjectAvailableAgents((err, agents) => {
|
|
83
96
|
if (this.log) {console.log("Agents", agents);}
|
|
84
97
|
if (err) {
|
|
85
98
|
console.error("IfOnlineAgents:Error getting available agents:", err);
|
|
@@ -4,7 +4,6 @@ const { DirIntent } = require('./DirIntent');
|
|
|
4
4
|
const axios = require("axios").default;
|
|
5
5
|
let https = require("https");
|
|
6
6
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
7
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
8
7
|
|
|
9
8
|
class DirIfOnlineAgentsV2 {
|
|
10
9
|
|
|
@@ -14,18 +13,9 @@ class DirIfOnlineAgentsV2 {
|
|
|
14
13
|
}
|
|
15
14
|
this.context = context;
|
|
16
15
|
this.chatbot = context.chatbot;
|
|
16
|
+
this.tdclient = context.tdclient;
|
|
17
17
|
this.intentDir = new DirIntent(context);
|
|
18
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
19
18
|
this.log = context.log;
|
|
20
|
-
|
|
21
|
-
this.tdClient = new TiledeskClient({
|
|
22
|
-
projectId: this.context.projectId,
|
|
23
|
-
token: this.context.token,
|
|
24
|
-
APIURL: this.API_ENDPOINT,
|
|
25
|
-
APIKEY: "___",
|
|
26
|
-
log: this.log
|
|
27
|
-
});
|
|
28
|
-
|
|
29
19
|
}
|
|
30
20
|
|
|
31
21
|
execute(directive, callback) {
|
|
@@ -171,7 +161,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
171
161
|
|
|
172
162
|
async openNow() {
|
|
173
163
|
return new Promise( (resolve, reject) => {
|
|
174
|
-
this.
|
|
164
|
+
this.tdclient.openNow(async (err, result) => {
|
|
175
165
|
if (this.log) {console.log("(DirIfOnlineAgents) openNow():", result);}
|
|
176
166
|
if (err) {
|
|
177
167
|
reject(err);
|
|
@@ -185,7 +175,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
185
175
|
|
|
186
176
|
async getProjectAvailableAgents(departmentId, raw, callback) {
|
|
187
177
|
return new Promise( (resolve, reject) => {
|
|
188
|
-
let URL = `${this.
|
|
178
|
+
let URL = `${this.context.TILEDESK_APIURL}/projects/${this.context.projectId}/users/availables?raw=${raw}`
|
|
189
179
|
if (departmentId) {
|
|
190
180
|
URL = URL + `&department=${departmentId}`
|
|
191
181
|
}
|
|
@@ -10,11 +10,34 @@ class DirIfOpenHours {
|
|
|
10
10
|
if (!context) {
|
|
11
11
|
throw new Error('context object is mandatory.');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
this.tdclient = context.tdclient;
|
|
14
14
|
this.context = context;
|
|
15
|
-
this.
|
|
15
|
+
// this.tdclient = new TiledeskClient({
|
|
16
|
+
// projectId: context.projectId,
|
|
17
|
+
// token: context.token,
|
|
18
|
+
// APIURL: context.TILEDESK_APIURL,
|
|
19
|
+
// APIKEY: "___",
|
|
20
|
+
// log: context.log
|
|
21
|
+
// });
|
|
22
|
+
// let context = {
|
|
23
|
+
// projectId: projectId,
|
|
24
|
+
// token: token,
|
|
25
|
+
// requestId: supportRequest,
|
|
26
|
+
// APIURL: API_URL,
|
|
27
|
+
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
28
|
+
// departmentId: depId,
|
|
29
|
+
// log: false
|
|
30
|
+
// }
|
|
16
31
|
this.intentDir = new DirIntent(context);
|
|
17
|
-
|
|
32
|
+
// {
|
|
33
|
+
// API_ENDPOINT: context.TILEDESK_APIURL,
|
|
34
|
+
// TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
|
|
35
|
+
// supportRequest: context.supportRequest,
|
|
36
|
+
// token: context.token,
|
|
37
|
+
// log: context.log
|
|
38
|
+
// }
|
|
39
|
+
// );
|
|
40
|
+
//this.log = context.log;
|
|
18
41
|
}
|
|
19
42
|
|
|
20
43
|
execute(directive, callback) {
|
|
@@ -72,7 +95,10 @@ class DirIfOpenHours {
|
|
|
72
95
|
slot_id = action.slotId;
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
|
|
98
|
+
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
99
|
+
if (this.log) { console.log("DirAskGPT ApiEndpoint URL: ", server_base_url); }
|
|
100
|
+
|
|
101
|
+
let isopen_url = server_base_url + "/projects/" + this.context.projectId + "/isopen";
|
|
76
102
|
if (slot_id) {
|
|
77
103
|
isopen_url = isopen_url.concat("?timeSlot=" + slot_id);
|
|
78
104
|
}
|
|
@@ -130,7 +156,7 @@ class DirIfOpenHours {
|
|
|
130
156
|
}
|
|
131
157
|
)
|
|
132
158
|
|
|
133
|
-
// this.
|
|
159
|
+
// this.tdclient.openNow(action.slot_id, (err, result) => {
|
|
134
160
|
// console.log("openNow():", result);
|
|
135
161
|
// if (this.log) {console.log("openNow():", result);}
|
|
136
162
|
// if (err) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
1
|
+
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { DirIntent } = require('./DirIntent');
|
|
3
3
|
const ms = require('minimist-string');
|
|
4
4
|
|
|
@@ -8,19 +8,33 @@ class DirIfOpenHours {
|
|
|
8
8
|
if (!context) {
|
|
9
9
|
throw new Error('context object is mandatory.');
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
this.
|
|
11
|
+
this.tdclient = context.tdclient;
|
|
12
|
+
// this.tdclient = new TiledeskClient({
|
|
13
|
+
// projectId: context.projectId,
|
|
14
|
+
// token: context.token,
|
|
15
|
+
// APIURL: context.TILEDESK_APIURL,
|
|
16
|
+
// APIKEY: "___",
|
|
17
|
+
// log: context.log
|
|
18
|
+
// });
|
|
19
|
+
// let context = {
|
|
20
|
+
// projectId: projectId,
|
|
21
|
+
// token: token,
|
|
22
|
+
// requestId: supportRequest,
|
|
23
|
+
// APIURL: API_URL,
|
|
24
|
+
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
25
|
+
// departmentId: depId,
|
|
26
|
+
// log: false
|
|
27
|
+
// }
|
|
13
28
|
this.intentDir = new DirIntent(context);
|
|
29
|
+
// {
|
|
30
|
+
// API_ENDPOINT: context.TILEDESK_APIURL,
|
|
31
|
+
// TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
|
|
32
|
+
// supportRequest: context.supportRequest,
|
|
33
|
+
// token: context.token,
|
|
34
|
+
// log: context.log
|
|
35
|
+
// }
|
|
36
|
+
// );
|
|
14
37
|
this.log = context.log;
|
|
15
|
-
|
|
16
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
|
-
this.tdClient = new TiledeskClient({
|
|
18
|
-
projectId: this.context.projectId,
|
|
19
|
-
token: this.context.token,
|
|
20
|
-
APIURL: this.API_ENDPOINT,
|
|
21
|
-
APIKEY: "___",
|
|
22
|
-
log: this.log
|
|
23
|
-
});
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
execute(directive, callback) {
|
|
@@ -72,7 +86,7 @@ class DirIfOpenHours {
|
|
|
72
86
|
callback();
|
|
73
87
|
return;
|
|
74
88
|
}
|
|
75
|
-
this.
|
|
89
|
+
this.tdclient.openNow((err, result) => {
|
|
76
90
|
if (this.log) {console.log("openNow():", result);}
|
|
77
91
|
if (err) {
|
|
78
92
|
console.error("*** DirIfOpenHours Error:", err);
|
|
@@ -6,16 +6,38 @@ const ms = require('minimist-string');
|
|
|
6
6
|
|
|
7
7
|
class DirIntent {
|
|
8
8
|
|
|
9
|
+
// constructor(settings) {
|
|
10
|
+
// if (!settings.API_ENDPOINT) {
|
|
11
|
+
// throw new Error("settings.API_ENDPOINT is mandatory!");
|
|
12
|
+
// }
|
|
13
|
+
// this.API_ENDPOINT = settings.API_ENDPOINT;
|
|
14
|
+
// this.TILEBOT_ENDPOINT = settings.TILEBOT_ENDPOINT;
|
|
15
|
+
// this.log = settings.log;
|
|
16
|
+
// this.supportRequest = settings.supportRequest;
|
|
17
|
+
// this.token = settings.token;
|
|
18
|
+
// }
|
|
9
19
|
constructor(context) {
|
|
10
20
|
if (!context) {
|
|
11
21
|
throw new Error('context object is mandatory.');
|
|
12
22
|
}
|
|
13
23
|
this.context = context;
|
|
14
|
-
this.API_ENDPOINT = context.
|
|
24
|
+
this.API_ENDPOINT = context.TILEDESK_APIURL,
|
|
15
25
|
this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
|
|
16
26
|
this.supportRequest = context.supportRequest;
|
|
17
27
|
this.token = context.token;
|
|
18
28
|
this.log = context.log;
|
|
29
|
+
// let context = {
|
|
30
|
+
// projectId: projectId,
|
|
31
|
+
// token: token,
|
|
32
|
+
// supportRequest: supportRequest,
|
|
33
|
+
// requestId: supportRequest.request_id,
|
|
34
|
+
// TILEDESK_APIURL: API_URL,
|
|
35
|
+
// TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
|
|
36
|
+
// departmentId: depId,
|
|
37
|
+
// tdcache: tdcache,
|
|
38
|
+
// tdclient: tdclient,
|
|
39
|
+
// log: true
|
|
40
|
+
// }
|
|
19
41
|
}
|
|
20
42
|
|
|
21
43
|
execute(directive, callback) {
|
|
@@ -10,8 +10,34 @@ class DirJSONCondition {
|
|
|
10
10
|
}
|
|
11
11
|
this.context = context;
|
|
12
12
|
this.chatbot = context.chatbot;
|
|
13
|
+
// let context = {
|
|
14
|
+
// projectId: projectId,
|
|
15
|
+
// token: token,
|
|
16
|
+
// supportRequest: supportRequest,
|
|
17
|
+
// requestId: supportRequest.request_id,
|
|
18
|
+
// TILEDESK_APIURL: API_URL,
|
|
19
|
+
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
20
|
+
// departmentId: depId,
|
|
21
|
+
// tdcache: tdcache,
|
|
22
|
+
// log: false
|
|
23
|
+
// }
|
|
24
|
+
// this.tdclient = new TiledeskClient({
|
|
25
|
+
// projectId: context.projectId,
|
|
26
|
+
// token: context.token,
|
|
27
|
+
// APIURL: context.TILEDESK_APIURL,
|
|
28
|
+
// APIKEY: "___",
|
|
29
|
+
// log: context.log
|
|
30
|
+
// });
|
|
13
31
|
this.chatbot = context.chatbot;
|
|
14
32
|
this.intentDir = new DirIntent(context);
|
|
33
|
+
// {
|
|
34
|
+
// API_ENDPOINT: context.TILEDESK_APIURL,
|
|
35
|
+
// TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
|
|
36
|
+
// supportRequest: context.supportRequest,
|
|
37
|
+
// token: context.token,
|
|
38
|
+
// log: context.log
|
|
39
|
+
// }
|
|
40
|
+
// );
|
|
15
41
|
this.log = context.log;
|
|
16
42
|
}
|
|
17
43
|
|
|
@@ -19,7 +19,7 @@ class DirMessage {
|
|
|
19
19
|
throw new Error('context object is mandatory.');
|
|
20
20
|
}
|
|
21
21
|
this.context = context;
|
|
22
|
-
this.API_ENDPOINT = context.
|
|
22
|
+
this.API_ENDPOINT = context.TILEDESK_APIURL,
|
|
23
23
|
this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
|
|
24
24
|
this.projectId = context.projectId;
|
|
25
25
|
this.requestId = context.requestId;
|
|
@@ -9,11 +9,23 @@ class DirMessageToBot {
|
|
|
9
9
|
throw new Error('context object is mandatory.');
|
|
10
10
|
}
|
|
11
11
|
this.context = context;
|
|
12
|
-
this.API_ENDPOINT = context.
|
|
12
|
+
this.API_ENDPOINT = context.TILEDESK_APIURL,
|
|
13
13
|
this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
|
|
14
14
|
this.supportRequest = context.supportRequest;
|
|
15
15
|
this.token = context.token;
|
|
16
16
|
this.log = context.log;
|
|
17
|
+
// let context = {
|
|
18
|
+
// projectId: projectId,
|
|
19
|
+
// token: token,
|
|
20
|
+
// supportRequest: supportRequest,
|
|
21
|
+
// requestId: supportRequest.request_id,
|
|
22
|
+
// TILEDESK_APIURL: API_URL,
|
|
23
|
+
// TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
|
|
24
|
+
// departmentId: depId,
|
|
25
|
+
// tdcache: tdcache,
|
|
26
|
+
// tdclient: tdclient,
|
|
27
|
+
// log: true
|
|
28
|
+
// }
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
execute(directive, callback) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const { Directives } = require('./Directives');
|
|
3
3
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
4
4
|
const { TiledeskChatbotConst } = require('../../models/TiledeskChatbotConst');
|
|
5
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
5
|
|
|
7
6
|
class DirMoveToAgent {
|
|
8
7
|
|
|
@@ -11,19 +10,10 @@ class DirMoveToAgent {
|
|
|
11
10
|
throw new Error('context object is mandatory.');
|
|
12
11
|
}
|
|
13
12
|
this.context = context;
|
|
13
|
+
this.tdclient = context.tdclient;
|
|
14
14
|
this.tdcache = context.tdcache;
|
|
15
15
|
this.requestId = context.requestId;
|
|
16
16
|
this.log = context.log;
|
|
17
|
-
|
|
18
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
19
|
-
this.tdClient = new TiledeskClient({
|
|
20
|
-
projectId: this.context.projectId,
|
|
21
|
-
token: this.context.token,
|
|
22
|
-
APIURL: this.API_ENDPOINT,
|
|
23
|
-
APIKEY: "___",
|
|
24
|
-
log: this.log
|
|
25
|
-
});
|
|
26
|
-
|
|
27
17
|
}
|
|
28
18
|
|
|
29
19
|
execute(directive, callback) {
|
|
@@ -34,7 +24,7 @@ class DirMoveToAgent {
|
|
|
34
24
|
}
|
|
35
25
|
|
|
36
26
|
async go(action, callback) {
|
|
37
|
-
this.
|
|
27
|
+
this.tdclient.moveToAgent(this.requestId, (err) => {
|
|
38
28
|
if (err) {
|
|
39
29
|
console.error("Error moving to agent:", err);
|
|
40
30
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const { Directives } = require('./Directives');
|
|
3
3
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
4
4
|
const { TiledeskChatbotConst } = require('../../models/TiledeskChatbotConst');
|
|
5
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
5
|
|
|
7
6
|
class DirMoveToUnassigned {
|
|
8
7
|
|
|
@@ -11,17 +10,9 @@ class DirMoveToUnassigned {
|
|
|
11
10
|
throw new Error('context object is mandatory.');
|
|
12
11
|
}
|
|
13
12
|
this.context = context;
|
|
13
|
+
this.tdclient = context.tdclient;
|
|
14
14
|
this.requestId = context.requestId;
|
|
15
15
|
this.log = context.log;
|
|
16
|
-
|
|
17
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
18
|
-
this.tdClient = new TiledeskClient({
|
|
19
|
-
projectId: this.context.projectId,
|
|
20
|
-
token: this.context.token,
|
|
21
|
-
APIURL: this.API_ENDPOINT,
|
|
22
|
-
APIKEY: "___",
|
|
23
|
-
log: this.log
|
|
24
|
-
});
|
|
25
16
|
}
|
|
26
17
|
|
|
27
18
|
execute(directive, callback) {
|
|
@@ -45,7 +36,7 @@ class DirMoveToUnassigned {
|
|
|
45
36
|
|
|
46
37
|
async moveToUnassigned(requestId, callback) {
|
|
47
38
|
const empty_participants = [] // STATUS WILL MOVE AUTOMATICALLY TO UNASSIGNED (100)
|
|
48
|
-
this.
|
|
39
|
+
this.tdclient.updateRequestParticipants(requestId, empty_participants, (err) => {
|
|
49
40
|
if (callback) {
|
|
50
41
|
callback(err);
|
|
51
42
|
}
|
|
@@ -15,7 +15,6 @@ class DirQapla {
|
|
|
15
15
|
this.tdcache = this.context.tdcache;
|
|
16
16
|
this.requestId = this.context.requestId;
|
|
17
17
|
this.intentDir = new DirIntent(context);
|
|
18
|
-
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
19
18
|
this.log = context.log;
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -83,14 +82,18 @@ class DirQapla {
|
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
84
|
|
|
85
|
+
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
86
86
|
const qapla_base_url = process.env.QAPLA_ENDPOINT || "https://api.qapla.it/1.2"
|
|
87
|
-
if (this.log) {
|
|
87
|
+
if (this.log) {
|
|
88
|
+
console.log("DirQapla server_base_url: ", qapla_base_url);
|
|
89
|
+
console.log("DirQapla qapla_base_url: ", qapla_base_url);
|
|
90
|
+
}
|
|
88
91
|
|
|
89
92
|
let key = action.apiKey;
|
|
90
93
|
|
|
91
94
|
if (!key) {
|
|
92
95
|
if (this.log) { console.log("DirQapla - Key not found into action. Searching in integrations..."); }
|
|
93
|
-
key = await this.getKeyFromIntegrations();
|
|
96
|
+
key = await this.getKeyFromIntegrations(server_base_url);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
if (!key) {
|
|
@@ -285,11 +288,11 @@ class DirQapla {
|
|
|
285
288
|
});
|
|
286
289
|
}
|
|
287
290
|
|
|
288
|
-
async getKeyFromIntegrations() {
|
|
291
|
+
async getKeyFromIntegrations(server_base_url) {
|
|
289
292
|
return new Promise((resolve) => {
|
|
290
293
|
|
|
291
294
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
292
|
-
url:
|
|
295
|
+
url: server_base_url + "/" + this.context.projectId + "/integration/name/qapla",
|
|
293
296
|
headers: {
|
|
294
297
|
'Content-Type': 'application/json',
|
|
295
298
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { Filler } = require('../Filler');
|
|
2
2
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
3
3
|
const { TiledeskChatbotUtil } = require('../../models/TiledeskChatbotUtil');
|
|
4
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
5
4
|
|
|
6
5
|
class DirRandomReply {
|
|
7
6
|
|
|
@@ -15,15 +14,6 @@ class DirRandomReply {
|
|
|
15
14
|
this.token = context.token;
|
|
16
15
|
this.tdcache = context.tdcache;
|
|
17
16
|
this.log = context.log;
|
|
18
|
-
|
|
19
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
20
|
-
this.tdClient = new TiledeskClient({
|
|
21
|
-
projectId: this.context.projectId,
|
|
22
|
-
token: this.context.token,
|
|
23
|
-
APIURL: this.API_ENDPOINT,
|
|
24
|
-
APIKEY: "___",
|
|
25
|
-
log: this.log
|
|
26
|
-
});
|
|
27
17
|
}
|
|
28
18
|
|
|
29
19
|
execute(directive, callback) {
|
|
@@ -97,7 +87,7 @@ class DirRandomReply {
|
|
|
97
87
|
}
|
|
98
88
|
// send!
|
|
99
89
|
if (this.log) {console.log("Reply:", JSON.stringify(message))};
|
|
100
|
-
this.
|
|
90
|
+
this.context.tdclient.sendSupportMessage(
|
|
101
91
|
this.requestId,
|
|
102
92
|
message,
|
|
103
93
|
(err) => {
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
const { TiledeskClient } = require("@tiledesk/tiledesk-client");
|
|
2
1
|
|
|
3
2
|
class DirRemoveCurrentBot {
|
|
4
3
|
|
|
5
|
-
constructor(
|
|
6
|
-
if (!
|
|
7
|
-
throw new Error('
|
|
4
|
+
constructor(config) {
|
|
5
|
+
if (!config.tdclient) {
|
|
6
|
+
throw new Error('tdclient (TiledeskClient) object is mandatory.');
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
this.requestId = context.requestId;
|
|
12
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
13
|
-
|
|
14
|
-
this.tdClient = new TiledeskClient({
|
|
15
|
-
projectId: this.context.projectId,
|
|
16
|
-
token: this.context.token,
|
|
17
|
-
APIURL: this.API_ENDPOINT,
|
|
18
|
-
APIKEY: "___",
|
|
19
|
-
log: this.log
|
|
20
|
-
});
|
|
8
|
+
this.tdclient = config.tdclient;
|
|
9
|
+
this.requestId = config.requestId;
|
|
21
10
|
}
|
|
22
11
|
|
|
23
12
|
execute(directive, callback) {
|
|
13
|
+
console.log("Remove current bot");
|
|
24
14
|
let action;
|
|
25
15
|
if (directive.action) {
|
|
26
16
|
action = directive.action;
|
|
@@ -37,7 +27,7 @@ class DirRemoveCurrentBot {
|
|
|
37
27
|
}
|
|
38
28
|
|
|
39
29
|
go(action, callback) {
|
|
40
|
-
|
|
30
|
+
tdclient.removeCurrentBot(this.requestId, (err) => {
|
|
41
31
|
callback();
|
|
42
32
|
});
|
|
43
33
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
3
2
|
const { Filler } = require('../Filler');
|
|
4
3
|
|
|
@@ -9,17 +8,9 @@ class DirReplaceBot {
|
|
|
9
8
|
throw new Error('context object is mandatory.');
|
|
10
9
|
}
|
|
11
10
|
this.context = context;
|
|
11
|
+
this.tdclient = context.tdclient;
|
|
12
12
|
this.requestId = context.requestId;
|
|
13
13
|
this.log = context.log;
|
|
14
|
-
|
|
15
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
16
|
-
this.tdClient = new TiledeskClient({
|
|
17
|
-
projectId: this.context.projectId,
|
|
18
|
-
token: this.context.token,
|
|
19
|
-
APIURL: this.API_ENDPOINT,
|
|
20
|
-
APIKEY: "___",
|
|
21
|
-
log: this.log
|
|
22
|
-
});
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
execute(directive, callback) {
|
|
@@ -51,7 +42,7 @@ class DirReplaceBot {
|
|
|
51
42
|
);
|
|
52
43
|
const filler = new Filler();
|
|
53
44
|
botName = filler.fill(botName, variables);
|
|
54
|
-
this.
|
|
45
|
+
this.tdclient.replaceBotByName(this.requestId, botName, () => {
|
|
55
46
|
callback();
|
|
56
47
|
});
|
|
57
48
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
3
2
|
const { Filler } = require('../Filler');
|
|
4
3
|
|
|
@@ -9,17 +8,9 @@ class DirReplaceBotV2 {
|
|
|
9
8
|
throw new Error('context object is mandatory.');
|
|
10
9
|
}
|
|
11
10
|
this.context = context;
|
|
11
|
+
this.tdclient = context.tdclient;
|
|
12
12
|
this.requestId = context.requestId;
|
|
13
13
|
this.log = context.log;
|
|
14
|
-
|
|
15
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
16
|
-
this.tdClient = new TiledeskClient({
|
|
17
|
-
projectId: this.context.projectId,
|
|
18
|
-
token: this.context.token,
|
|
19
|
-
APIURL: this.API_ENDPOINT,
|
|
20
|
-
APIKEY: "___",
|
|
21
|
-
log: this.log
|
|
22
|
-
});
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
execute(directive, callback) {
|
|
@@ -52,7 +43,7 @@ class DirReplaceBotV2 {
|
|
|
52
43
|
);
|
|
53
44
|
const filler = new Filler();
|
|
54
45
|
botName = filler.fill(botName, variables);
|
|
55
|
-
this.
|
|
46
|
+
this.tdclient.replaceBotByName(this.requestId, botName, () => {
|
|
56
47
|
if (blockName) {
|
|
57
48
|
if (this.log) {console.log("Sending hidden /start message to bot in dept");}
|
|
58
49
|
const message = {
|
|
@@ -62,7 +53,7 @@ class DirReplaceBotV2 {
|
|
|
62
53
|
subtype: "info"
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
|
-
this.
|
|
56
|
+
this.tdclient.sendSupportMessage(
|
|
66
57
|
this.requestId,
|
|
67
58
|
message, (err) => {
|
|
68
59
|
if (err) {
|