@tiledesk/tiledesk-server 2.3.93 → 2.3.95
Sign up to get free protection for your applications and to get access to all the features.
@@ -79,7 +79,7 @@ router.post('/', function (req, res) {
|
|
79
79
|
|
80
80
|
if (cacheEnabler.request) {
|
81
81
|
q.cache(cacheUtil.defaultTTL, "requests:request_id:"+message.recipient+":simple"); //request_cache
|
82
|
-
// project_id not available
|
82
|
+
// project_id not available //without project for chat21 webhook
|
83
83
|
winston.debug('request cache enabled');
|
84
84
|
}
|
85
85
|
return q.exec(function(err, request) {
|
@@ -391,6 +391,7 @@ router.post('/', function (req, res) {
|
|
391
391
|
var query = {request_id: recipient_id, id_project: projectId};
|
392
392
|
winston.debug('query:'+ projectId);
|
393
393
|
|
394
|
+
winston.debug('conversation-archived Request.findOne(query);:');
|
394
395
|
let q = Request.findOne(query);
|
395
396
|
// if (cacheEnabler.request) {
|
396
397
|
// q.cache(cacheUtil.defaultTTL, projectId+":requests:request_id:"+recipient_id+":simple"); //request_cache NOT IMPORTANT HERE
|
@@ -477,6 +478,7 @@ router.post('/', function (req, res) {
|
|
477
478
|
winston.debug("id_project: " + id_project);
|
478
479
|
|
479
480
|
// requestcachefarequi populaterequired
|
481
|
+
winston.debug('join-member Request.findOne(query);:');
|
480
482
|
return Request.findOne({request_id: request_id, id_project: id_project})
|
481
483
|
.populate('lead') //TODO posso prenderlo da snapshot senza populate cache_attention
|
482
484
|
.exec(function(err, request) {
|
@@ -647,6 +649,7 @@ else if (req.body.event_type == "typing-start") {
|
|
647
649
|
|
648
650
|
|
649
651
|
// requestcachefarequi nocachepopulatereqired
|
652
|
+
winston.debug('typing-start Request.findOne(query);:');
|
650
653
|
return Request.findOne({request_id: recipient_id})
|
651
654
|
//TOD errore cache sistemare e riabbilitare->
|
652
655
|
// .cache(cacheUtil.defaultTTL, req.projectid+":requests:request_id:"+recipient_id) cache_attention
|
@@ -847,7 +850,7 @@ else if (req.body.event_type == "new-group") {
|
|
847
850
|
res.json("new-group event_type is not implemented");
|
848
851
|
}
|
849
852
|
else {
|
850
|
-
winston.
|
853
|
+
winston.debug("Chat21WebHook error event_type not implemented", req.body);
|
851
854
|
res.json("Not implemented");
|
852
855
|
}
|
853
856
|
|
package/package.json
CHANGED
@@ -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
|
-
|
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.
|
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.
|
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.
|
484
|
+
winston.debug('id_faq_kb: ' + id_faq_kb);
|
485
485
|
|
486
486
|
const api_url = process.env.API_URL || configGlobal.apiUrl;
|
487
|
-
winston.
|
487
|
+
winston.debug("fork --> base_url: " + api_url); // check if correct
|
488
488
|
|
489
489
|
let current_project_id = req.projectid;
|
490
|
-
winston.
|
490
|
+
winston.debug("current project id: " + current_project_id);
|
491
491
|
|
492
492
|
let landing_project_id = req.query.projectid;
|
493
|
-
winston.
|
493
|
+
winston.debug("landing project id " + landing_project_id)
|
494
494
|
|
495
495
|
let public = req.query.public;
|
496
|
-
winston.
|
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.
|
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.
|
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.
|
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.
|
542
|
+
winston.debug("json source " + json_string)
|
543
543
|
|
544
544
|
if (req.query.intentsOnly && req.query.intentsOnly == "true") {
|
545
545
|
|
546
|
-
winston.
|
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.
|
573
|
+
winston.debug("updated existing intent")
|
574
574
|
faqBotEvent.emit('faq.update', savingResult.value);
|
575
575
|
} else {
|
576
|
-
winston.
|
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.
|
589
|
+
winston.debug("Skip duplicated intent_display_name");
|
590
590
|
} else {
|
591
|
-
winston.
|
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.
|
635
|
+
winston.debug("updated existing intent")
|
636
636
|
faqBotEvent.emit('faq.update', savingResult.value);
|
637
637
|
} else {
|
638
|
-
winston.
|
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.
|
653
|
+
winston.debug("Skip duplicated intent_display_name");
|
654
654
|
} else {
|
655
|
-
winston.
|
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.
|
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.
|
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.
|
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",
|