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