@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
|
@@ -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.
|
|
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.
|
|
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) {
|
|
@@ -73,7 +83,7 @@ class DirSendEmail {
|
|
|
73
83
|
replyto: reply_to
|
|
74
84
|
}
|
|
75
85
|
// console.log("email message:", JSON.stringify(message));
|
|
76
|
-
const message_echo = await this.
|
|
86
|
+
const message_echo = await this.tdclient.sendEmail(message);
|
|
77
87
|
if (this.log) {console.log("email sent. filled_subject:", filled_subject);}
|
|
78
88
|
if (this.log) {console.log("email sent. filled_text:", filled_text);}
|
|
79
89
|
if (this.log) {console.log("email sent. filled_to:", filled_to);}
|
|
@@ -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) {
|
|
@@ -81,7 +72,7 @@ class DirSetConversationTags {
|
|
|
81
72
|
subtype: "info"
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
|
-
this.
|
|
75
|
+
this.tdclient.sendSupportMessage(
|
|
85
76
|
this.requestId,
|
|
86
77
|
message, (err) => {
|
|
87
78
|
if (err) {
|
|
@@ -100,7 +91,7 @@ class DirSetConversationTags {
|
|
|
100
91
|
}
|
|
101
92
|
|
|
102
93
|
moveToDepartment(requestId, depName, callback) {
|
|
103
|
-
this.
|
|
94
|
+
this.tdclient.getAllDepartments((err, deps) => {
|
|
104
95
|
if (this.log) {console.log("deps:", JSON.stringify(deps));}
|
|
105
96
|
if (err) {
|
|
106
97
|
console.error("getAllDepartments() error:", err);
|
|
@@ -117,7 +108,7 @@ class DirSetConversationTags {
|
|
|
117
108
|
}
|
|
118
109
|
}
|
|
119
110
|
if (dep) {
|
|
120
|
-
this.
|
|
111
|
+
this.tdclient.updateRequestDepartment(requestId, dep._id, null, (err, res) => {
|
|
121
112
|
if (err) {
|
|
122
113
|
console.error("DirDepartment error:", err);
|
|
123
114
|
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);
|
|
@@ -10,7 +10,6 @@ class DirWhatsappByAttribute {
|
|
|
10
10
|
throw new Error('context object is mandatory');
|
|
11
11
|
}
|
|
12
12
|
this.context = context;
|
|
13
|
-
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
14
13
|
this.log = context.log;
|
|
15
14
|
}
|
|
16
15
|
|
|
@@ -36,12 +35,15 @@ class DirWhatsappByAttribute {
|
|
|
36
35
|
console.log("whatsapp by attributes action: ", JSON.stringify(action))
|
|
37
36
|
}
|
|
38
37
|
|
|
38
|
+
///////////
|
|
39
|
+
|
|
39
40
|
const whatsapp_api_url_pre = process.env.WHATSAPP_ENDPOINT;
|
|
41
|
+
const server_base_url = process.env.API_URL || process.env.API_ENDPOINT;
|
|
40
42
|
|
|
41
43
|
if (whatsapp_api_url_pre) {
|
|
42
44
|
whatsapp_api_url = whatsapp_api_url_pre;
|
|
43
45
|
} else {
|
|
44
|
-
whatsapp_api_url =
|
|
46
|
+
whatsapp_api_url = server_base_url + "/modules/whatsapp/api"
|
|
45
47
|
}
|
|
46
48
|
console.log("DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
47
49
|
|
|
@@ -92,6 +94,62 @@ class DirWhatsappByAttribute {
|
|
|
92
94
|
}, true);
|
|
93
95
|
})
|
|
94
96
|
|
|
97
|
+
|
|
98
|
+
// if (process.env.API_URL) {
|
|
99
|
+
// whatsapp_api_url = "https://tiledesk-whatsapp-connector.giovannitroisi3.repl.co/api";
|
|
100
|
+
// // whatsapp_api_url = process.env.API_URL + "/modules/whatsapp";
|
|
101
|
+
// console.log("(Tilebot) DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
102
|
+
// } else {
|
|
103
|
+
// console.error("(Tilebot) ERROR Missing whatsapp_api_url. Unable to use action WhatsApp By Attributes");
|
|
104
|
+
// callback();
|
|
105
|
+
// return;
|
|
106
|
+
// }
|
|
107
|
+
// if (action.attributeName) {
|
|
108
|
+
// if (this.log) { console.log("whatsapp attributeName:", action.attributeName); }
|
|
109
|
+
// let attribute_value = null;
|
|
110
|
+
// if (this.context.tdcache) {
|
|
111
|
+
|
|
112
|
+
// const attribute_value = await TiledeskChatbot.getParameterStatic(this.context.tdcache, this.context.requestId, action.attributeName)
|
|
113
|
+
// if (this.log) { console.log("attribute_value:", JSON.stringify(attribute_value)); }
|
|
114
|
+
|
|
115
|
+
// if (attribute_value == null) {
|
|
116
|
+
// console.error("(Tilebot) attribute_value is undefined");
|
|
117
|
+
// callback();
|
|
118
|
+
// return;
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
// const URL = whatsapp_api_url + '/tiledesk/broadcast';
|
|
122
|
+
// const HTTPREQUEST = {
|
|
123
|
+
// url: URL,
|
|
124
|
+
// headers: {
|
|
125
|
+
// 'Content-Type': 'application/json',
|
|
126
|
+
|
|
127
|
+
// },
|
|
128
|
+
// json: attribute_value,
|
|
129
|
+
// method: 'POST'
|
|
130
|
+
// };
|
|
131
|
+
// let promise = new Promise((resolve, reject) => {
|
|
132
|
+
// DirWhatsappByAttribute.myrequest(
|
|
133
|
+
// HTTPREQUEST,
|
|
134
|
+
// function (err, resbody) {
|
|
135
|
+
// if (err) {
|
|
136
|
+
// if (callback) {
|
|
137
|
+
// callback(err);
|
|
138
|
+
// }
|
|
139
|
+
// reject(err);
|
|
140
|
+
// }
|
|
141
|
+
// else {
|
|
142
|
+
// if (callback) {
|
|
143
|
+
// callback(null, resbody);
|
|
144
|
+
// }
|
|
145
|
+
// console.log("(tybot) broadcast sent: ", resbody);
|
|
146
|
+
// resolve(resbody);
|
|
147
|
+
// }
|
|
148
|
+
// }, true);
|
|
149
|
+
// })
|
|
150
|
+
// return promise;
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
95
153
|
}
|
|
96
154
|
|
|
97
155
|
// HTTP REQUEST
|
/package/tiledeskChatbotPlugs/directives/{DEPRECATED_DirOfflineHours.js → DirOfflineHours.js}
RENAMED
|
File without changes
|