@tiledesk/tiledesk-tybot-connector 0.2.131-rc4 → 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 +19 -9
- 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 +1 -11
- package/tiledeskChatbotPlugs/directives/DirCondition.js +26 -0
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +13 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +2 -11
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +2 -11
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +5 -16
- 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 +25 -12
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +2 -12
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +30 -4
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +26 -12
- 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 +1 -11
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +1 -10
- package/tiledeskChatbotPlugs/directives/DirQapla.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +7 -18
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -10
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -10
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -11
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +21 -11
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +1 -10
- 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
|
@@ -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) {
|
|
@@ -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
|
}
|
|
@@ -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) {
|
|
@@ -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) {
|
|
@@ -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) {
|
|
@@ -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.tdclient.sendSupportMessage(
|
|
90
|
+
this.context.tdclient.sendSupportMessage(
|
|
101
91
|
this.requestId,
|
|
102
92
|
message,
|
|
103
93
|
(err) => {
|
|
@@ -1,27 +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.tdclient = context.tdclient;
|
|
12
|
-
this.requestId = context.requestId;
|
|
13
|
-
|
|
14
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
15
|
-
this.tdClient = new TiledeskClient({
|
|
16
|
-
projectId: this.context.projectId,
|
|
17
|
-
token: this.context.token,
|
|
18
|
-
APIURL: this.API_ENDPOINT,
|
|
19
|
-
APIKEY: "___",
|
|
20
|
-
log: this.log
|
|
21
|
-
});
|
|
8
|
+
this.tdclient = config.tdclient;
|
|
9
|
+
this.requestId = config.requestId;
|
|
22
10
|
}
|
|
23
11
|
|
|
24
12
|
execute(directive, callback) {
|
|
13
|
+
console.log("Remove current bot");
|
|
25
14
|
let action;
|
|
26
15
|
if (directive.action) {
|
|
27
16
|
action = directive.action;
|
|
@@ -38,7 +27,7 @@ class DirRemoveCurrentBot {
|
|
|
38
27
|
}
|
|
39
28
|
|
|
40
29
|
go(action, callback) {
|
|
41
|
-
|
|
30
|
+
tdclient.removeCurrentBot(this.requestId, (err) => {
|
|
42
31
|
callback();
|
|
43
32
|
});
|
|
44
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) {
|
|
@@ -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) {
|
|
@@ -2,7 +2,6 @@ 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');
|
|
6
5
|
|
|
7
6
|
class DirReply {
|
|
8
7
|
|
|
@@ -16,15 +15,6 @@ class DirReply {
|
|
|
16
15
|
this.token = context.token;
|
|
17
16
|
this.tdcache = context.tdcache;
|
|
18
17
|
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
|
-
});
|
|
28
18
|
}
|
|
29
19
|
|
|
30
20
|
execute(directive, callback) {
|
|
@@ -140,7 +130,7 @@ class DirReply {
|
|
|
140
130
|
if (this.log) {console.log("Reply:", JSON.stringify(cleanMessage))};
|
|
141
131
|
await TiledeskChatbotUtil.updateConversationTranscript(this.context.chatbot, cleanMessage);
|
|
142
132
|
// console.log("sending message!", cleanMessage);
|
|
143
|
-
this.tdclient.sendSupportMessage(
|
|
133
|
+
this.context.tdclient.sendSupportMessage(
|
|
144
134
|
this.requestId,
|
|
145
135
|
cleanMessage,
|
|
146
136
|
(err) => {
|
|
@@ -6,7 +6,6 @@ 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');
|
|
10
9
|
|
|
11
10
|
class DirReplyV2 {
|
|
12
11
|
|
|
@@ -24,15 +23,6 @@ class DirReplyV2 {
|
|
|
24
23
|
this.chatbot = context.chatbot;
|
|
25
24
|
this.reply = context.reply;
|
|
26
25
|
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
|
-
});
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
execute(directive, callback) {
|
|
@@ -273,7 +263,7 @@ class DirReplyV2 {
|
|
|
273
263
|
cleanMessage.senderFullname = this.context.chatbot.bot.name;
|
|
274
264
|
if (this.log) {console.log("Reply:", JSON.stringify(cleanMessage))};
|
|
275
265
|
await TiledeskChatbotUtil.updateConversationTranscript(this.context.chatbot, cleanMessage);
|
|
276
|
-
this.tdclient.sendSupportMessage(
|
|
266
|
+
this.context.tdclient.sendSupportMessage(
|
|
277
267
|
this.requestId,
|
|
278
268
|
cleanMessage,
|
|
279
269
|
(err) => {
|
|
@@ -2,7 +2,6 @@ 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');
|
|
6
5
|
// const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
7
6
|
|
|
8
7
|
class DirSendEmail {
|
|
@@ -12,18 +11,29 @@ class DirSendEmail {
|
|
|
12
11
|
throw new Error('context object is mandatory.');
|
|
13
12
|
}
|
|
14
13
|
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
|
-
|
|
17
|
+
this.log = context.log;
|
|
18
|
+
// let context = {
|
|
19
|
+
// projectId: projectId,
|
|
20
|
+
// token: token,
|
|
21
|
+
// supportRequest: supportRequest,
|
|
22
|
+
// requestId: supportRequest.request_id,
|
|
23
|
+
// TILEDESK_APIURL: API_URL,
|
|
24
|
+
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
25
|
+
// departmentId: depId,
|
|
26
|
+
// tdcache: tdcache,
|
|
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
|
+
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
execute(directive, callback) {
|
|
@@ -16,7 +16,6 @@ class DirSendWhatsapp {
|
|
|
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
|
|
|
@@ -74,11 +73,12 @@ class DirSendWhatsapp {
|
|
|
74
73
|
payload.broadcast = false;
|
|
75
74
|
|
|
76
75
|
const whatsapp_api_url_pre = process.env.WHATSAPP_ENDPOINT;
|
|
76
|
+
const server_base_url = process.env.API_URL || process.env.API_ENDPOINT;
|
|
77
77
|
|
|
78
78
|
if (whatsapp_api_url_pre) {
|
|
79
79
|
whatsapp_api_url = whatsapp_api_url_pre;
|
|
80
80
|
} else {
|
|
81
|
-
whatsapp_api_url =
|
|
81
|
+
whatsapp_api_url = server_base_url + "/modules/whatsapp/api"
|
|
82
82
|
}
|
|
83
83
|
if (this.log) { console.log("DirSendWhatsapp whatsapp_api_url: ", whatsapp_api_url); };
|
|
84
84
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
1
|
const { Filler } = require('../Filler');
|
|
3
2
|
|
|
4
3
|
class DirSetConversationTags {
|
|
@@ -9,16 +8,8 @@ class DirSetConversationTags {
|
|
|
9
8
|
}
|
|
10
9
|
this.context = context;
|
|
11
10
|
this.log = context.log;
|
|
11
|
+
this.tdclient = context.tdclient;
|
|
12
12
|
this.requestId = context.requestId;
|
|
13
|
-
|
|
14
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
15
|
-
this.tdClient = new TiledeskClient({
|
|
16
|
-
projectId: this.context.projectId,
|
|
17
|
-
token: this.context.token,
|
|
18
|
-
APIURL: this.API_ENDPOINT,
|
|
19
|
-
APIKEY: "___",
|
|
20
|
-
log: this.log
|
|
21
|
-
});
|
|
22
13
|
}
|
|
23
14
|
|
|
24
15
|
execute(directive, callback) {
|
|
@@ -10,6 +10,7 @@ class DirWebRequestV2 {
|
|
|
10
10
|
throw new Error('context object is mandatory.');
|
|
11
11
|
}
|
|
12
12
|
this.context = context;
|
|
13
|
+
this.tdclient = context.tdclient;
|
|
13
14
|
this.tdcache = context.tdcache;
|
|
14
15
|
this.requestId = context.requestId;
|
|
15
16
|
this.intentDir = new DirIntent(context);
|