@tiledesk/tiledesk-tybot-connector 0.2.131 → 0.2.132-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -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 +13 -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
|
@@ -16,6 +16,7 @@ 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;
|
|
19
20
|
this.log = context.log;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -73,12 +74,11 @@ class DirSendWhatsapp {
|
|
|
73
74
|
payload.broadcast = false;
|
|
74
75
|
|
|
75
76
|
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 = this.API_ENDPOINT + "/modules/whatsapp/api"
|
|
82
82
|
}
|
|
83
83
|
if (this.log) { console.log("DirSendWhatsapp whatsapp_api_url: ", whatsapp_api_url); };
|
|
84
84
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
1
2
|
const { Filler } = require('../Filler');
|
|
2
3
|
|
|
3
4
|
class DirSetConversationTags {
|
|
@@ -8,8 +9,16 @@ class DirSetConversationTags {
|
|
|
8
9
|
}
|
|
9
10
|
this.context = context;
|
|
10
11
|
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
|
+
});
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
execute(directive, callback) {
|
|
@@ -72,7 +81,7 @@ class DirSetConversationTags {
|
|
|
72
81
|
subtype: "info"
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
|
-
this.
|
|
84
|
+
this.tdClient.sendSupportMessage(
|
|
76
85
|
this.requestId,
|
|
77
86
|
message, (err) => {
|
|
78
87
|
if (err) {
|
|
@@ -91,7 +100,7 @@ class DirSetConversationTags {
|
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
moveToDepartment(requestId, depName, callback) {
|
|
94
|
-
this.
|
|
103
|
+
this.tdClient.getAllDepartments((err, deps) => {
|
|
95
104
|
if (this.log) {console.log("deps:", JSON.stringify(deps));}
|
|
96
105
|
if (err) {
|
|
97
106
|
console.error("getAllDepartments() error:", err);
|
|
@@ -108,7 +117,7 @@ class DirSetConversationTags {
|
|
|
108
117
|
}
|
|
109
118
|
}
|
|
110
119
|
if (dep) {
|
|
111
|
-
this.
|
|
120
|
+
this.tdClient.updateRequestDepartment(requestId, dep._id, null, (err, res) => {
|
|
112
121
|
if (err) {
|
|
113
122
|
console.error("DirDepartment error:", err);
|
|
114
123
|
callback();
|
|
@@ -10,7 +10,6 @@ class DirWebRequestV2 {
|
|
|
10
10
|
throw new Error('context object is mandatory.');
|
|
11
11
|
}
|
|
12
12
|
this.context = context;
|
|
13
|
-
this.tdclient = context.tdclient;
|
|
14
13
|
this.tdcache = context.tdcache;
|
|
15
14
|
this.requestId = context.requestId;
|
|
16
15
|
this.intentDir = new DirIntent(context);
|
|
@@ -10,6 +10,7 @@ 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;
|
|
13
14
|
this.log = context.log;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -35,15 +36,12 @@ class DirWhatsappByAttribute {
|
|
|
35
36
|
console.log("whatsapp by attributes action: ", JSON.stringify(action))
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
///////////
|
|
39
|
-
|
|
40
39
|
const whatsapp_api_url_pre = process.env.WHATSAPP_ENDPOINT;
|
|
41
|
-
const server_base_url = process.env.API_URL || process.env.API_ENDPOINT;
|
|
42
40
|
|
|
43
41
|
if (whatsapp_api_url_pre) {
|
|
44
42
|
whatsapp_api_url = whatsapp_api_url_pre;
|
|
45
43
|
} else {
|
|
46
|
-
whatsapp_api_url =
|
|
44
|
+
whatsapp_api_url = this.API_ENDPOINT + "/modules/whatsapp/api"
|
|
47
45
|
}
|
|
48
46
|
console.log("DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
49
47
|
|
|
@@ -94,62 +92,6 @@ class DirWhatsappByAttribute {
|
|
|
94
92
|
}, true);
|
|
95
93
|
})
|
|
96
94
|
|
|
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
|
-
// }
|
|
153
95
|
}
|
|
154
96
|
|
|
155
97
|
// HTTP REQUEST
|
/package/tiledeskChatbotPlugs/directives/{DirOfflineHours.js → DEPRECATED_DirOfflineHours.js}
RENAMED
|
File without changes
|