@tiledesk/tiledesk-server 2.3.94 → 2.3.95

Sign up to get free protection for your applications and to get access to all the features.
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.3.94",
4
+ "version": "2.3.95",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -338,7 +338,12 @@ devi mandare un messaggio welcome tu altrimenti il bot inserito successivamente
338
338
  if (request.subject) {
339
339
  touchText = request.subject;
340
340
  }
341
- touchText.replace("\\",""); //Bugfix when a conversation has a first_text with \agent
341
+
342
+
343
+ // touchText.replace(String.fromCharCode(92),""); //Bugfix when a conversation has a first_text with \agent
344
+ touchText = touchText.replace(/\\/g, "");
345
+
346
+ winston.debug("touchText: " + touchText);
342
347
 
343
348
  // messageService.send(sender, senderFullname, recipient, text, id_project, createdBy, attributes, type);
344
349
  messageService.send(
package/routes/faq_kb.js CHANGED
@@ -17,7 +17,7 @@ const faq = require('../models/faq');
17
17
  let chatbot_templates_api_url = process.env.CHATBOT_TEMPLATES_API_URL
18
18
 
19
19
  router.post('/', function (req, res) {
20
- winston.info('create BOT ', req.body);
20
+ winston.debug('create BOT ', req.body);
21
21
  //create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language, template)
22
22
  faqService.create(req.body.name, req.body.url, req.projectid, req.user.id, req.body.type, req.body.description, undefined, undefined, req.body.language, req.body.template, req.body.mainCategory, req.body.intentsEngine).then(function (savedFaq_kb) {
23
23
  res.json(savedFaq_kb);
@@ -464,7 +464,7 @@ router.get('/', function (req, res) {
464
464
  }
465
465
 
466
466
 
467
- winston.info("query", query);
467
+ winston.debug("query", query);
468
468
 
469
469
  Faq_kb.find(query, function (err, faq_kb) {
470
470
  if (err) {
@@ -481,19 +481,19 @@ router.get('/', function (req, res) {
481
481
  router.post('/fork/:id_faq_kb', async (req, res) => {
482
482
 
483
483
  let id_faq_kb = req.params.id_faq_kb;
484
- winston.info('id_faq_kb: ' + id_faq_kb);
484
+ winston.debug('id_faq_kb: ' + id_faq_kb);
485
485
 
486
486
  const api_url = process.env.API_URL || configGlobal.apiUrl;
487
- winston.info("fork --> base_url: " + api_url); // check if correct
487
+ winston.debug("fork --> base_url: " + api_url); // check if correct
488
488
 
489
489
  let current_project_id = req.projectid;
490
- winston.info("current project id: " + current_project_id);
490
+ winston.debug("current project id: " + current_project_id);
491
491
 
492
492
  let landing_project_id = req.query.projectid;
493
- winston.info("landing project id " + landing_project_id)
493
+ winston.debug("landing project id " + landing_project_id)
494
494
 
495
495
  let public = req.query.public;
496
- winston.info("public " + public);
496
+ winston.debug("public " + public);
497
497
 
498
498
  let token = req.headers.authorization;
499
499
 
@@ -507,14 +507,14 @@ router.post('/fork/:id_faq_kb', async (req, res) => {
507
507
  }
508
508
 
509
509
  let savedChatbot = await cs.createBot(api_url, token, chatbot, landing_project_id);
510
- winston.info("savedChatbot: ", savedChatbot)
510
+ winston.debug("savedChatbot: ", savedChatbot)
511
511
 
512
512
  if (!savedChatbot) {
513
513
  return res.status(500).send({ success: false, message: "Unable to create new chatbot" });
514
514
  }
515
515
 
516
516
  let import_result = await cs.importFaqs(api_url, savedChatbot._id, token, chatbot, landing_project_id);
517
- winston.info("imported: ", import_result);
517
+ winston.debug("imported: ", import_result);
518
518
 
519
519
  if (import_result.success == "false") {
520
520
  return res.status(500).send({ success: false, message: "Unable to import intents in the new chatbot" });
@@ -528,7 +528,7 @@ router.post('/fork/:id_faq_kb', async (req, res) => {
528
528
  router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, res) => {
529
529
 
530
530
  let id_faq_kb = req.params.id_faq_kb;
531
- winston.info('import on id_faq_kb: ', id_faq_kb);
531
+ winston.debug('import on id_faq_kb: ', id_faq_kb);
532
532
 
533
533
  let json_string;
534
534
  let json;
@@ -539,11 +539,11 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
539
539
  json = req.body;
540
540
  }
541
541
 
542
- winston.info("json source " + json_string)
542
+ winston.debug("json source " + json_string)
543
543
 
544
544
  if (req.query.intentsOnly && req.query.intentsOnly == "true") {
545
545
 
546
- winston.info("intents only")
546
+ winston.debug("intents only")
547
547
 
548
548
  await json.intents.forEach((intent) => {
549
549
 
@@ -570,10 +570,10 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
570
570
  winston.error("findOneAndUpdate (upsert) FAQ ERROR ", err);
571
571
  } else {
572
572
  if (savingResult.lastErrorObject.updatedExisting == true) {
573
- winston.info("updated existing intent")
573
+ winston.debug("updated existing intent")
574
574
  faqBotEvent.emit('faq.update', savingResult.value);
575
575
  } else {
576
- winston.info("new intent created")
576
+ winston.debug("new intent created")
577
577
  faqBotEvent.emit('faq.create', savingResult.value);
578
578
  }
579
579
  }
@@ -586,9 +586,9 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
586
586
  winston.debug("create new FAQ ERROR ", err);
587
587
  if (err.code == 11000) {
588
588
  winston.error("Duplicate intent_display_name.");
589
- winston.info("Skip duplicated intent_display_name");
589
+ winston.debug("Skip duplicated intent_display_name");
590
590
  } else {
591
- winston.info("new intent created")
591
+ winston.debug("new intent created")
592
592
  faqBotEvent.emit('faq.create', savedFaq);
593
593
  }
594
594
  }
@@ -632,10 +632,10 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
632
632
  } else {
633
633
 
634
634
  if (savingResult.lastErrorObject.updatedExisting == true) {
635
- winston.info("updated existing intent")
635
+ winston.debug("updated existing intent")
636
636
  faqBotEvent.emit('faq.update', savingResult.value);
637
637
  } else {
638
- winston.info("new intent created")
638
+ winston.debug("new intent created")
639
639
  faqBotEvent.emit('faq.create', savingResult.value);
640
640
  }
641
641
 
@@ -650,9 +650,9 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
650
650
  winston.debug("create new FAQ ERROR ", err);
651
651
  if (err.code == 11000) {
652
652
  winston.error("Duplicate intent_display_name.");
653
- winston.info("Skip duplicated intent_display_name");
653
+ winston.debug("Skip duplicated intent_display_name");
654
654
  } else {
655
- winston.info("new intent created")
655
+ winston.debug("new intent created")
656
656
  faqBotEvent.emit('faq.create', savedFaq);
657
657
  }
658
658
  }
@@ -31,7 +31,7 @@ class ChatbotService {
31
31
 
32
32
  async getBotById(id_faq_kb, published, api_url, chatbot_templates_api_url, token, project_id) {
33
33
 
34
- winston.info("[CHATBOT SERVICE] getBotById");
34
+ winston.debug("[CHATBOT SERVICE] getBotById");
35
35
 
36
36
  // private bot
37
37
  if (published == "false") {
@@ -44,7 +44,7 @@ class ChatbotService {
44
44
  },
45
45
  method: 'GET'
46
46
  }).then((resbody) => {
47
- winston.info("(CHATBOT SERVICE) forking private chatbot " + resbody.data.name)
47
+ winston.debug("(CHATBOT SERVICE) forking private chatbot " + resbody.data.name)
48
48
  let chatbot = resbody.data;
49
49
  return chatbot;
50
50
  }).catch((err) => {
@@ -97,7 +97,7 @@ class ChatbotService {
97
97
 
98
98
  async importFaqs(api_url, id_faq_kb, token, chatbot, project_id) {
99
99
 
100
- winston.info("[CHATBOT SERVICE] importFaqs");
100
+ winston.debug("[CHATBOT SERVICE] importFaqs");
101
101
 
102
102
  return await axios({
103
103
  url: api_url + '/' + project_id + '/faq_kb/importjson/' + id_faq_kb + "?intentsOnly=true",
@@ -25,7 +25,7 @@ class TrainingService {
25
25
  }
26
26
 
27
27
  if (faq_kb.intentsEngine !== 'tiledesk-ai') {
28
- winston.info("intentsEngine: off")
28
+ winston.debug("intentsEngine: off")
29
29
  return null;
30
30
  }
31
31