@tiledesk/tiledesk-server 2.1.4-0.23 → 2.1.4-0.31

Sign up to get free protection for your applications and to get access to all the features.
package/models/faq_kb.js CHANGED
@@ -53,6 +53,11 @@ var Faq_kbSchema = new Schema({
53
53
  default: uuidv4(),
54
54
  select: false
55
55
  },
56
+ language: {
57
+ type: String,
58
+ required: false,
59
+ // index: true
60
+ },
56
61
  attributes: {
57
62
  type: Object,
58
63
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.1.40.23",
4
+ "version": "2.1.40.31",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -44,7 +44,7 @@
44
44
  "@tiledesk-ent/tiledesk-server-tags": "^1.1.1",
45
45
  "@tiledesk-ent/tiledesk-server-groups": "^1.1.2",
46
46
  "@tiledesk-ent/tiledesk-server-departments": "^1.1.2",
47
- "@tiledesk-ent/tiledesk-server-mt": "^1.1.5",
47
+ "@tiledesk-ent/tiledesk-server-mt": "^1.1.6",
48
48
  "@tiledesk-ent/tiledesk-server-visitorcounter": "^1.1.1"
49
49
  },
50
50
  "dependencies": {
@@ -81,7 +81,7 @@ listen() {
81
81
 
82
82
  requestEvent.on(requestParticipantsUpdateKey, function(data) {
83
83
 
84
- winston.info("requestEvent request.participants.update");
84
+ winston.debug("requestEvent request.participants.update");
85
85
 
86
86
  var request = data.request;
87
87
 
@@ -312,7 +312,7 @@ sendAgentEmail(projectid, savedRequest) {
312
312
  return winston.verbose("RequestNotification email notification for the project with id : " + projectid + " for all the conversations is blocked");
313
313
  }
314
314
 
315
- winston.info("savedRequest: " + JSON.stringify(savedRequest));
315
+ winston.debug("savedRequest: " + JSON.stringify(savedRequest));
316
316
 
317
317
  // TODO fare il controllo anche sul dipartimento con modalità assigned o pooled
318
318
  if (savedRequest.status==RequestConstants.UNASSIGNED) { //POOLED
@@ -338,9 +338,9 @@ sendAgentEmail(projectid, savedRequest) {
338
338
 
339
339
  // agents già c'è in quanto viene creato con departmentService.getOperator nella request.create ma nn c'è per request.participants.update
340
340
  snapshotAgents = await Request.findById(savedRequest.id).select({"snapshot":1}).exec();
341
- winston.info('load snapshotAgents with Request.findById ');
341
+ winston.debug('load snapshotAgents with Request.findById ');
342
342
  }
343
- winston.info('snapshotAgents', snapshotAgents);
343
+ winston.debug('snapshotAgents', snapshotAgents);
344
344
 
345
345
  if (!snapshotAgents.snapshot.agents) {
346
346
  return winston.warn("RequestNotification snapshotAgents.snapshot.agents is null :(. You are closing an old request?", savedRequest);
@@ -167,7 +167,7 @@ class PubModulesManager {
167
167
  if (this.messageTransformer) {
168
168
  try {
169
169
  this.messageTransformer.messageTransformerInterceptor.listen();
170
- this.messageTransformer.microLanguageTransformerInterceptor.listen();
170
+ // this.messageTransformer.microLanguageTransformerInterceptor.listen();
171
171
  winston.info("PubModulesManager messageTransformer started.");
172
172
  } catch(err) {
173
173
  winston.info("PubModulesManager error starting messageTransformer module", err);
@@ -43,7 +43,10 @@ devi mandare un messaggio welcome tu altrimenti il bot inserito successivamente
43
43
  // winston.debug(" ConciergeBot message.request.first_text: "+message.request.first_text);
44
44
 
45
45
  // lead_id used. Change it?
46
- if (message.request && message.request.preflight === true && message.sender == message.request.lead.lead_id && message.text != message.request.first_text ) {
46
+
47
+ if (message.request && message.request.preflight === true && message.sender == message.request.lead.lead_id && message.text != message.request.first_text) {
48
+ winston.debug("conciergebot: " + message.request.first_text );
49
+ // if (message.request && message.request.preflight === true && message.sender == message.request.lead.lead_id && message.text != message.request.first_text ) {
47
50
  // if (message.request.status < 100 && message.sender == message.request.lead.lead_id && message.text != message.request.first_text ) {
48
51
  // if (message.request.status < 100 && message.sender == message.request.lead.lead_id && message.text != message.request.first_text && !botId) {
49
52
 
@@ -64,13 +67,17 @@ devi mandare un messaggio welcome tu altrimenti il bot inserito successivamente
64
67
 
65
68
 
66
69
  requestService.changeFirstTextAndPreflightByRequestId(message.request.request_id, message.request.id_project, first_text, false).then(function (reqChanged) {
67
-
68
- // requestService.changeFirstTextByRequestId(message.request.request_id, message.request.id_project, message.text).then(function (reqChanged) {
69
- // requestService.changePreflightByRequestId(message.request.request_id, message.request.id_project, false).then(function (reqChanged) {
70
-
71
-
72
- // reroute(request_id, id_project, nobot)
73
- requestService.reroute(message.request.request_id, message.request.id_project, false );
70
+ //TESTA QUESTO
71
+
72
+ winston.debug("message.request.status: "+message.request.status);
73
+ winston.debug("message.request.department.id_bot: "+message.request.department.id_bot);
74
+ if (message.request.status === 50 && message.request.department.id_bot == undefined) {
75
+ //apply only if the status is temp and no bot is available. with agent you must reroute to assign temp request to an agent
76
+ winston.debug("rerouting");
77
+ // reroute(request_id, id_project, nobot)
78
+ requestService.reroute(message.request.request_id, message.request.id_project, false );
79
+ }
80
+
74
81
  // updateStatusWitId(lead_id, id_project, status)
75
82
  // lead_id used. Change it?
76
83
  leadService.updateStatusWitId(message.request.lead.lead_id, message.request.id_project, LeadConstants.NORMAL);
@@ -242,58 +249,58 @@ devi mandare un messaggio welcome tu altrimenti il bot inserito successivamente
242
249
 
243
250
 
244
251
  // unused
245
- welcomeOnJoin(request) {
246
- var botId = BotFromParticipant.getBotFromParticipants(request.participants);
247
- if (!botId) {
248
- // if (!request.department.id_bot) {
252
+ // welcomeOnJoin(request) {
253
+ // var botId = BotFromParticipant.getBotFromParticipants(request.participants);
254
+ // if (!botId) {
255
+ // // if (!request.department.id_bot) {
249
256
 
250
- winston.debug("ConciergeBot send welcome bot message");
257
+ // winston.debug("ConciergeBot send welcome bot message");
251
258
 
252
- // TODO if (request is assigned allora manda we are putting inn touch )
253
- // controlla dopo reassing
254
- if (request.status == RequestConstants.ASSIGNED) {
255
- if (request.participants.length==0) {
256
- // if (request.availableAgents.length==0) {
259
+ // // TODO if (request is assigned allora manda we are putting inn touch )
260
+ // // controlla dopo reassing
261
+ // if (request.status == RequestConstants.ASSIGNED) {
262
+ // if (request.participants.length==0) {
263
+ // // if (request.availableAgents.length==0) {
257
264
 
258
- // messageService.send(sender, senderFullname, recipient, text, id_project, createdBy, attributes, type);
259
- messageService.send(
260
- 'system',
261
- 'Bot',
262
- request.request_id,
263
- i8nUtil.getMessage("NO_AVAILABLE_OPERATOR_MESSAGE", request.language, MessageConstants.LABELS),
264
- request.id_project,
265
- 'system',
266
- //{"updateconversation" : false, messagelabel: {key: "NO_AVAILABLE_OPERATOR_MESSAGE"}}
267
- {messagelabel: {key: "NO_AVAILABLE_OPERATOR_MESSAGE"}},
268
- undefined,
269
- request.language
265
+ // // messageService.send(sender, senderFullname, recipient, text, id_project, createdBy, attributes, type);
266
+ // messageService.send(
267
+ // 'system',
268
+ // 'Bot',
269
+ // request.request_id,
270
+ // i8nUtil.getMessage("NO_AVAILABLE_OPERATOR_MESSAGE", request.language, MessageConstants.LABELS),
271
+ // request.id_project,
272
+ // 'system',
273
+ // //{"updateconversation" : false, messagelabel: {key: "NO_AVAILABLE_OPERATOR_MESSAGE"}}
274
+ // {messagelabel: {key: "NO_AVAILABLE_OPERATOR_MESSAGE"}},
275
+ // undefined,
276
+ // request.language
270
277
 
271
278
 
272
- );
279
+ // );
273
280
 
274
281
 
275
- }else {
282
+ // }else {
276
283
 
277
- messageService.send(
278
- 'system',
279
- 'Bot',
280
- request.request_id,
281
- i8nUtil.getMessage("JOIN_OPERATOR_MESSAGE", request.language, MessageConstants.LABELS),
282
- request.id_project,
283
- 'system',
284
- {messagelabel: {key: "JOIN_OPERATOR_MESSAGE"}},
285
- // {"updateconversation" : false, messagelabel: {key: "JOIN_OPERATOR_MESSAGE"}}
286
- undefined,
287
- request.language
288
-
289
- );
284
+ // messageService.send(
285
+ // 'system',
286
+ // 'Bot',
287
+ // request.request_id,
288
+ // i8nUtil.getMessage("JOIN_OPERATOR_MESSAGE", request.language, MessageConstants.LABELS),
289
+ // request.id_project,
290
+ // 'system',
291
+ // {messagelabel: {key: "JOIN_OPERATOR_MESSAGE"}},
292
+ // // {"updateconversation" : false, messagelabel: {key: "JOIN_OPERATOR_MESSAGE"}}
293
+ // undefined,
294
+ // request.language
295
+
296
+ // );
290
297
 
291
298
 
292
- }
293
- }
299
+ // }
300
+ // }
294
301
 
295
- }
296
- }
302
+ // }
303
+ // }
297
304
 
298
305
 
299
306
 
package/routes/faq_kb.js CHANGED
@@ -58,8 +58,15 @@ router.post('/askbot', function (req, res) {
58
58
  }else {
59
59
  query = { "id_project": req.projectid, "id_faq_kb": req.body.id_faq_kb};
60
60
 
61
- query.$text = {"$search": req.body.question};
62
-
61
+ var search_obj = {"$search": req.body.question};
62
+
63
+ if (faq_kb.language) {
64
+ search_obj["$language"] = faq_kb.language;
65
+ }
66
+ query.$text = search_obj;
67
+ winston.info("fulltext search query", query);
68
+
69
+
63
70
  winston.debug('internal ft query: '+ query);
64
71
 
65
72
  Faq.find(query, {score: { $meta: "textScore" } })
@@ -167,6 +167,15 @@ class EmailService {
167
167
 
168
168
  var that = this;
169
169
 
170
+ //if the request came from rabbit mq?
171
+ if (savedRequest.toJSON) {
172
+ savedRequest = savedRequest.toJSON();
173
+ }
174
+
175
+ if (project.toJSON) {
176
+ project = project.toJSON();
177
+ }
178
+
170
179
  this.readHTMLFile('assignedRequest.html', function(err, html) {
171
180
 
172
181
 
@@ -188,8 +197,8 @@ class EmailService {
188
197
  // Stampa anche contact.email
189
198
 
190
199
  var replacements = {
191
- savedRequest: savedRequest.toJSON(),
192
- project: project.toJSON(),
200
+ savedRequest: savedRequest,
201
+ project: project,
193
202
  baseScope: baseScope
194
203
  };
195
204
 
@@ -212,6 +221,15 @@ class EmailService {
212
221
 
213
222
  var that = this;
214
223
 
224
+ //if the request came from rabbit mq?
225
+ if (savedRequest.toJSON) {
226
+ savedRequest = savedRequest.toJSON();
227
+ }
228
+
229
+ if (project.toJSON) {
230
+ project = project.toJSON();
231
+ }
232
+
215
233
  this.readHTMLFile('pooledRequest.html', function(err, html) {
216
234
 
217
235
 
@@ -232,8 +250,8 @@ class EmailService {
232
250
  // passa anche tutti i messages in modo da stampare tutto
233
251
  // Stampa anche contact.email
234
252
  var replacements = {
235
- savedRequest: savedRequest.toJSON(),
236
- project: project.toJSON(),
253
+ savedRequest: savedRequest,
254
+ project: project,
237
255
  baseScope: baseScope
238
256
  };
239
257
 
@@ -251,6 +269,11 @@ class EmailService {
251
269
 
252
270
  var that = this;
253
271
 
272
+ //if the request came from rabbit mq?
273
+ if (project.toJSON) {
274
+ project = project.toJSON();
275
+ }
276
+
254
277
  this.readHTMLFile('newMessage.html', function(err, html) {
255
278
 
256
279
 
@@ -270,7 +293,7 @@ class EmailService {
270
293
 
271
294
  var replacements = {
272
295
  message: message,
273
- project: project.toJSON(),
296
+ project: project,
274
297
  tokenQueryString: tokenQueryString,
275
298
  baseScope: baseScope
276
299
  };
@@ -468,6 +491,11 @@ class EmailService {
468
491
 
469
492
  var that = this;
470
493
 
494
+ if (savedUser.toJSON) {
495
+ savedUser = savedUser.toJSON();
496
+ }
497
+
498
+
471
499
  this.readHTMLFile('verify.html', function(err, html) {
472
500
 
473
501
 
@@ -487,7 +515,7 @@ class EmailService {
487
515
 
488
516
 
489
517
  var replacements = {
490
- savedUser: savedUser.toJSON(),
518
+ savedUser: savedUser,
491
519
  baseScope: baseScope
492
520
  };
493
521
 
@@ -520,6 +548,12 @@ class EmailService {
520
548
 
521
549
  var that = this;
522
550
 
551
+
552
+ //if the request came from rabbit mq?
553
+ if (request.toJSON) {
554
+ request = request.toJSON();
555
+ }
556
+
523
557
  this.readHTMLFile('sendTranscript.html', function(err, html) {
524
558
 
525
559
 
@@ -540,7 +574,7 @@ class EmailService {
540
574
 
541
575
  var replacements = {
542
576
  messages: messages,
543
- request: request.toJSON(),
577
+ request: request,
544
578
  formattedCreatedAt: request.createdAt.toLocaleString('en', { timeZone: 'UTC' }),
545
579
  transcriptAsHtml: transcriptAsHtml,
546
580
  baseScope: baseScope
@@ -182,7 +182,14 @@ class FaqBotHandler {
182
182
  } else {
183
183
 
184
184
  query = { "id_project": message.id_project, "id_faq_kb": faq_kb._id};
185
- query.$text = {"$search": message.text};
185
+
186
+ var search_obj = {"$search": message.text};
187
+
188
+ if (faq_kb.language) {
189
+ search_obj["$language"] = faq_kb.language;
190
+ }
191
+ query.$text = search_obj;
192
+ winston.verbose("fulltext search query", query);
186
193
 
187
194
  Faq.find(query, {score: { $meta: "textScore" } })
188
195
  .sort( { score: { $meta: "textScore" } } ) //https://docs.mongodb.com/manual/reference/operator/query/text/#sort-by-text-search-score