@tiledesk/tiledesk-tybot-connector 0.2.72 → 0.2.74
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
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
# v0.2.74 - online
|
|
9
|
+
- Fix. Get DepartmentId in test-mode in IfOnelineAgentsV2
|
|
10
|
+
|
|
11
|
+
# v0.2.73 - debug
|
|
12
|
+
- Fix. static getMachine with check on bot not null
|
|
8
13
|
|
|
9
14
|
# v0.2.72
|
|
10
15
|
- Fix. userParams not in /reserved...
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
37
37
|
console.log("Removed req.body.payload.request.snapshot field");
|
|
38
38
|
}
|
|
39
39
|
if (log) {console.log("REQUEST BODY:", JSON.stringify(req.body));}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
const botId = req.params.botid;
|
|
42
42
|
if (log) {console.log(" :", botId);}
|
|
43
43
|
const message = req.body.payload;
|
|
@@ -5,17 +5,20 @@ class IntentsMachineFactory {
|
|
|
5
5
|
|
|
6
6
|
static getMachine(bot, botId, projectId, log) {
|
|
7
7
|
let machine;
|
|
8
|
-
if (bot.intentsEngine === "tiledesk-ai") {
|
|
8
|
+
if (bot && bot.intentsEngine === "tiledesk-ai") {
|
|
9
9
|
console.log("bot.intentsEngine is tiledesk-ai");
|
|
10
10
|
machine = new TiledeskIntentsMachine(
|
|
11
11
|
{
|
|
12
12
|
botId: botId
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
else {
|
|
15
|
+
else if (bot) {
|
|
16
16
|
if (log) {console.log("Setting MongodbIntentsMachine with bot:", JSON.stringify(bot));}
|
|
17
17
|
machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language, log});
|
|
18
18
|
}
|
|
19
|
+
else {
|
|
20
|
+
console.error("bot is null for:", botId, "on projectId:", projectId);
|
|
21
|
+
}
|
|
19
22
|
return machine;
|
|
20
23
|
}
|
|
21
24
|
|
package/package.json
CHANGED
|
@@ -57,19 +57,27 @@ class DirIfOnlineAgentsV2 {
|
|
|
57
57
|
|
|
58
58
|
let agents;
|
|
59
59
|
if (selectedOption === "currentDep") {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let departmentId;
|
|
61
|
+
// console.log("checking supportRequest:", this.context.supportRequest);
|
|
62
|
+
if (this.context.departmentId) {
|
|
63
|
+
departmentId = this.context.departmentId;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
departmentId = this.context?.supportRequest?.attributes?.departmentId;
|
|
67
|
+
}
|
|
68
|
+
if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", departmentId); }
|
|
69
|
+
agents = await this.getDepartmentAvailableAgents(departmentId);
|
|
70
|
+
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
63
71
|
}
|
|
64
72
|
else if (selectedOption === "selectedDep") {
|
|
65
|
-
console.log("(DirIfOnlineAgents) selectedOption === selectedDep", action.selectedDepartmentId);
|
|
73
|
+
if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === selectedDep", action.selectedDepartmentId); }
|
|
66
74
|
agents = await this.getDepartmentAvailableAgents(action.selectedDepartmentId);
|
|
67
|
-
console.log("(DirIfOnlineAgents) agents:", agents);
|
|
75
|
+
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
68
76
|
}
|
|
69
77
|
else { // if (checkAll) => go project-wide
|
|
70
|
-
console.log("(DirIfOnlineAgents) selectedOption === all");
|
|
78
|
+
if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === all"); }
|
|
71
79
|
agents = await this.getProjectAvailableAgents();
|
|
72
|
-
console.log("(DirIfOnlineAgents) agents:", agents);
|
|
80
|
+
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
if (agents && agents.length > 0) {
|
|
@@ -81,7 +89,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
else {
|
|
84
|
-
console.log("(DirIfOnlineAgents) No IfOnlineAgents trueIntent defined. callback()") // prod
|
|
92
|
+
if (this.log) { console.log("(DirIfOnlineAgents) No IfOnlineAgents trueIntent defined. callback()"); } // prod
|
|
85
93
|
this.chatbot.addParameter("flowError", "(If online Agents) No IfOnlineAgents success path defined.");
|
|
86
94
|
callback();
|
|
87
95
|
return;
|
|
@@ -142,20 +150,20 @@ class DirIfOnlineAgentsV2 {
|
|
|
142
150
|
reject(error);
|
|
143
151
|
}
|
|
144
152
|
else {
|
|
145
|
-
console.log("(DirIfOnlineAgents) got department:", JSON.stringify(dep));
|
|
153
|
+
if (this.log) {console.log("(DirIfOnlineAgents) got department:", JSON.stringify(dep)); }
|
|
146
154
|
const groupId = dep.id_group;
|
|
147
|
-
console.log("(DirIfOnlineAgents) department.groupId:", groupId);
|
|
155
|
+
if (this.log) {console.log("(DirIfOnlineAgents) department.groupId:", groupId); }
|
|
148
156
|
try {
|
|
149
157
|
if (groupId) {
|
|
150
158
|
const group = await this.getGroup(groupId);
|
|
151
|
-
console.log("(DirIfOnlineAgents) got group info:", group);
|
|
159
|
+
if (this.log) { console.log("(DirIfOnlineAgents) got group info:", group); }
|
|
152
160
|
if (group) {
|
|
153
161
|
if (group.members) {
|
|
154
|
-
console.log("(DirIfOnlineAgents) group members ids:", group.members);
|
|
162
|
+
if (this.log) { console.log("(DirIfOnlineAgents) group members ids:", group.members);}
|
|
155
163
|
// let group_members = await getTeammates(group.members);
|
|
156
164
|
// console.log("group members details:", group_members);
|
|
157
165
|
let all_teammates = await this.getAllTeammates();
|
|
158
|
-
console.log("(DirIfOnlineAgents) all teammates:", all_teammates);
|
|
166
|
+
if (this.log) { console.log("(DirIfOnlineAgents) all teammates:", all_teammates); }
|
|
159
167
|
if (all_teammates && all_teammates.length > 0){
|
|
160
168
|
// [
|
|
161
169
|
// {
|
|
@@ -180,13 +188,13 @@ class DirIfOnlineAgentsV2 {
|
|
|
180
188
|
console.log("(DirIfOnlineAgents) filtering available agents for group:", groupId);
|
|
181
189
|
let available_agents = [];
|
|
182
190
|
all_teammates.forEach((agent) => {
|
|
183
|
-
console.log("Checking teammate:", agent.id_user._id, "(", agent.id_user.email ,") Available:", agent.user_available, ") with members:",group.members );
|
|
191
|
+
if (this.log) { console.log("Checking teammate:", agent.id_user._id, "(", agent.id_user.email ,") Available:", agent.user_available, ") with members:",group.members ); }
|
|
184
192
|
if (agent.user_available === true && group.members.includes(agent.id_user._id)) {
|
|
185
193
|
console.log("Adding teammate:", agent.id_user._id);
|
|
186
194
|
available_agents.push(agent);
|
|
187
195
|
}
|
|
188
196
|
});
|
|
189
|
-
console.log("(DirIfOnlineAgents) available agents in group:", available_agents);
|
|
197
|
+
if (this.log) { console.log("(DirIfOnlineAgents) available agents in group:", available_agents); }
|
|
190
198
|
resolve(available_agents);
|
|
191
199
|
}
|
|
192
200
|
}
|