@tiledesk/tiledesk-tybot-connector 0.2.73 → 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,9 @@
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
+
8
11
  # v0.2.73 - debug
9
12
  - Fix. static getMachine with check on bot not null
10
13
 
package/index.js CHANGED
@@ -37,8 +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
- console.log("REQUEST BODY:", JSON.stringify(req.body));
41
-
40
+
42
41
  const botId = req.params.botid;
43
42
  if (log) {console.log(" :", botId);}
44
43
  const message = req.body.payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.73",
3
+ "version": "0.2.74",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -57,19 +57,27 @@ class DirIfOnlineAgentsV2 {
57
57
 
58
58
  let agents;
59
59
  if (selectedOption === "currentDep") {
60
- console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", this.context.departmentId);
61
- agents = await this.getDepartmentAvailableAgents(this.context.departmentId);
62
- console.log("(DirIfOnlineAgents) agents:", agents);
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
  }